Arduino based PWM diversion control system

Started by WillEert, May 29, 2015, 10:09:50 AM

Previous topic - Next topic

ClassicCrazy

I use Terra Term for some things. The other popular terminal program is Putty but I like Terra Term better.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

paul alting

Great to hear Larry.
I just downloaded Tera Term 4.87 as a Windows exe file from the last site I mentioned.
http://logmett.com/index.php?/download/tera-term-487-freeware.html

I might fire up VirtualBox and dust off a very tweaked version of XP I have in there and give it a spin and see what it looks like connected to the Mega running that code.

Will report back, send a search party if I don't return from the depths of VirtualBox :)
____
Paul
6 x 200W PV into home-brew 6 stage MOSFET charge controller : Microhydro 220Vac 3 phase IMAG
8 x 400Ah LiFeYPO4 Winston : Latronics LS2412 inverter
QuadlogSCADA control and monitoring system : Tasmania, Australia : http://paulalting.com

paul alting

I can confirm Tera term works well, in fact it is a capable terminal program.
It only took a minute to setup and here is the proof.

The image capture is not good quality, possibly due to the way the screen capture is working with the refresh rate of Windows in VirtualBox, but on my Mac screen, it looks as good as running my native terminal app on the Mac. This is running in VirtualBox with Microsoft Windows XP super tweaked.

The Tera Term program is quick and easy to install, and can suggest it for this use.
____
Paul
6 x 200W PV into home-brew 6 stage MOSFET charge controller : Microhydro 220Vac 3 phase IMAG
8 x 400Ah LiFeYPO4 Winston : Latronics LS2412 inverter
QuadlogSCADA control and monitoring system : Tasmania, Australia : http://paulalting.com

WillEert

      I have finished looking at the changes to my code that Paul made and have moved many of them into the latest iteration of the Uno diversion controller (udc). Thanks Paul for taking the time to go over the code and critique it. the code looks nicer now and does not use up so much memory.  I also used # define for the setpoint values of the diversion voltage bias and the diversion frequency selection which now makes them easier to find and use. Much Better.
      I downloaded the REED controller package and started setting it up. Glanced at the code and a lot of it is beyond me at this time however I need to print it out and study it. I am having a hard time getting it to compile due to the PID library not being seen by the IDE. Ran out of time and my brain got tired however I will make it work. I am a Windows based computing person so will have to get my old laptop dusted off and configured to run the REED program. Thanks again Paul. You did lots of thinking and work to create this code.
      My power supply was 5V however what I was doing was accidentally grounding out the barrel plug when I installed it into the board already powered up. The m7 diode definitely did not like this and rebelled. I have ordered some m7s and will try to replace the one on the board that has lost its magic smoke. Thinking the power supply issue through I also ordered a barrel connector splitter and some adapters that give me a screw connection from the barrel jack. This will let me power up the lcd remotely from the board and then turn them off when the Classic rests through use of a transistor. Thanks dgd.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

     Tomorrow I hope to get the wire and fittings I need to change the HWT over to the lead  / lag element format. Should be done on Thursday so on  Friday if it is sunny I should be able to see how it works. Already the udc is heating the tank to SP much sooner than the AUX1 system used to.
     Next I want to get the udc controlling diversion based on WBJr amp flow. It would control diversion based on voltage however if amp flow to the batteries reaches the udc amp limit SP then it would control on amps while the Classic controls the volts. This would let me over array my batteries and run the arrays up to the comfortable maximum for the Classics. If the diversion load should not be available then the udc would write a lower amp limit setpoint to the Classic in order to protect the batteries. I configured the sketch to bring in the WBJr amps and Classic amp limit registers which is working well however when I tried to write to the Classic I was not successful at all - well not very. I think this problem is suitable for the RS232 Modbus to Classic topic so will post a message there.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

Back in business. Following my last post in the" RS 232 to Classic" topic I believe that I have resolved my unreliability issues with the diversion controller and can move forward. Since removing the button and waiting a few months I have had no issues with the sketch.

Question:

For amp diversion control of the Classic it is necessary to write to the Classic amp limit register which I can do now however a concern of mine is that the arduino writes to it each time through the loop as I have the sketch configured. I know eeprom can be written to a finite large number of times but I cannot find out if the Classic registers may be damaged by / prematurely worn out  by a sketch writing to the same register each time through the loop. Is this a valid concern? I am thinking I could configure if / else statements to only write to the register when required if need be.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

dgd

Will,

Having a modbus register written to every time the loop() executes is something I also wanted to avoid. To achieve this I simply had a test in the loop to test if the write was wanted and if so then call another function to adjust the modbus configure appropriately then do a few modbus_update calls, test if successful, then readjust the configure to remove the write and exit back to the reading loop.
Seems to work quite well.
The classics modbus registers are not stored in EEPROM, only some values that need to be retained between resets AFAIK.

Dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

paul alting

Hi Will and David, it is good to hear of your success Will.

Yes, I suspect all this data is not stored in EEPROM, but either battery backed RAM or some other form of non-volatile memory that should not be effected by writes.
The controller also stores its real time data in there, so it really can't be memory that will suffer from over writing.

Yes, as David mentions, with the register write back to the controller, simply hold a copy of the value which can then be used to check on pass of the main loop() to see if it is any different.
You can set a small amount of 'deadband' whereby even if it is ±1 or ±2 counts either side of the register value it will not update.
This will reduce the writes.

This technique is commonly done in industrial control applications, where reducing the amount of data being transferred is sought after to improve system response between PLCs and SCADA systems.

David, I am currently building that 6 stage MOSFET solar charge controller I talked about, err, finally.
As summer approaches, the water flow is reducing and I will need to switch across to solar soon, hence the need for a charge controller.
Nice to get my hands back into electronics and designing and building.

Paul
6 x 200W PV into home-brew 6 stage MOSFET charge controller : Microhydro 220Vac 3 phase IMAG
8 x 400Ah LiFeYPO4 Winston : Latronics LS2412 inverter
QuadlogSCADA control and monitoring system : Tasmania, Australia : http://paulalting.com

dgd

Hi Paul,
I would be very interested in how you progress with the controller. I had some fun writing a recursive c++ routine to do a zero current mppt algorithm after figuring out the hill climbing p&o method. All really academic as I'm leaning more toward a brute force pwm controller with perhaps some sort of front end voltage tracker/converter.
Anyway, the arduino due web server progresses with some better report features although it's all mostly client side js code and highcharts graphs, they look just so nice.
Not a lot of interest though from midnite users although I installed servers in all 11 MN sites I support and a couple of local systems I helped set up that liked the iPad version.
Strange thing is I'm getting a fair amount of enquiries about using arduino web server with outback MX60 and FMs, using direct connection to mate port on controller. I managed to borrow an MX60
(From Able Solar in Auckland) so I'm determined to suss out that interface, seems questions have been asked about it on various forums for about 10 years now but nobody appears to have solved it
The boring answer is always to buy the mate and use its rs232 port.

Dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

ClassicCrazy

Yeah  - I don't like having to borrow my friends Outback Mate just to make a few changes to the inverter setting now and then. Some real time monitoring of an Outback inverter would be nice so you will certainly be popular if you ever get the direct connection figured out instead of having to go through a Mate.

I was kind of hoping Midnite would have their inverter on the market soon - but doesn't sound like it will be for a year or two - and in the states here the federal income tax deductions will expire by then.
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

WillEert

I am finally finding time to get back to developing a  diversion control to maximize PV array output using the Classic and an Arduino.

I configured a thermostat to turn the PID PWM diversion on/off in response to the HWT temperature. The sensor is a conventional 10K thermistor. This thermostat is set lower than the conventional thermostat on the tank which permits very good control of temperature setpoints and on / off differential while having the conventional thermostat function as a High Temperature shut down if needed.

I also got my “button” working reliably for automatically turning the lcd display off automatically after a tunable time period. Yay!!

I am increasing the size of my array to 6.4 Kw STC and adding another Classic to handle the additional power. The system will end up at 2 arrays of 3.2 kw each â€" each with their own Classic. This much power means that the system will be able to exceed the amp maximum for charging the battery bank so I have been working on adding a battery amp limit controller to the diversion control. The long term intention is to divert excess amps to the HWT if the HWT load is available and if the HWT load is not available then the battery amp limiter will limit amps to the battery while permitting full array power to flow to the inverters.

I have attached the working stand alone PID battery amp limiter sketch. Dgd helped me with turning the RS232 write on and off as required â€" Thanks David. The control manipulates the Classic battery current limiter in response to the WBJr amp flow to maintain the amp flow to the battery at or below setpoint while permitting the current to the Classic to also rise to the Classic maximum if inverter load is available. The control works quite well but can be tuned using the PID if need be.

I am very new to arduinoing and programming. A fault with the PID amp limiter control is that when it pushes the WBJr battery amps down by reducing the Classic amp limit the Classic amps from the array will not increase again to a new larger limit setpoint until a “sweep” occurs. This means the Classic “waits” to increase amps until the next sweep. This sweep time interval is adjustable in Mode however I want to be able to force a one time only sweep in certain circumstances in order to overcome this problem. I have not done any bit shifting and I am struggling to get this to work. The control needs to read what looks like the 10th bit in table 4130 ( bit 9?) and then write to the 12th bit in table 4160 (Bit 11?) to force a sweep when the amp limit controller logic calls for a sweep. I have tried a number of sketch configurations to access these bits but I have not been successful so far. I can get values of 0 and 12288(?) however these values do not change when the load limit turns on. Part of my problem with this is that I do not understand how these tables are organized. I suspect each bit can have 2 values. I am guessing value 1 would be 0 or off and then the table hex value when on. I have studied what books I have but so far are making no meaningful progress. I have read the first few pages of the MODBUS Network Spec and I am sure the information I want is there but I do not understand it. I have also attached the read and write sketch (RW) to show how far I have made it with this latest configuration. Any help or suggestions about how to read and write to these registers  will be appreciated.

Thanks

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

Hmmmm......
I think I see how to do multiple attachments now.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

Westbranch

what  is a XXXXX.ino file type for?  can't seem to open it...  tks
KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come

WillEert

 

.ino files are the designation for program files that the Arduino IDE uses. I am sure many IDEs will open these program files. I have one called Code Blocks that opens .ino files. The Arduino IDE can be downloaded from the following site:

https://www.arduino.cc/en/Main/Software

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

dgd

Hi Will,

Good stuff, just downloaded your files and had a look at what you are doing. Nice straightforward C++ coding.
I like it  :)

I could not help thinking it would be a neat project to replace those 4 line LCD displays with a couple of web pages being updated via AJAX so an ipad. phone, PC etc, could be used to access and monitor the system via interweb.
It would probably need a Mega 2560 with the 8k ram, or Due with 96k to get the ethernet, metering web pages and SD card for web pages all working.
But you have done the real leg work here.

Nearly completed my MX60 and KID web interfaces, so this looks interesting, might look at web interface over Xmas holiday.

Will post some exampe bit field extraction and posting code soon.
Are you using ide1.6.6?  its more finnicky to get clean code compiles  :o

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand