Author Topic: Arduino based PWM diversion control system  (Read 10022 times)

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #60 on: January 24, 2016, 10:30:47 AM »
Hi Ancell,

I have not used any other boards than the arduino so my experience is limited however I am enjoying coding and physical computing.

My diversion control development has slowed lately due to it being (for me ) a very cloudy winter. I am reluctant to lose Kw developing the control when I need all the power I can get. I have a stand alone PID PWM diversion control configured that diverts excess energy using amps to the batteries as a set point. This needs to be debugged and then operated long enough to gain confidence in it. Then I will add it to the existing control to divert on amps when in bulk. If the diversion load is not available the variable amp limiter will protect the system. Diversion in absorb would be as presently configured.

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #61 on: February 20, 2016, 09:12:12 AM »

I am gathering what I need to install the power system upgrade. The upgrade requires the addition of another Classic that is now resting in garage together with 6 330w mono panels. One thing I am unsure about is how to wire the two Classics to one arduino. I am guessing that I would just get a RJ11 splitter and length of suitable wire  and plug them both in to the splitter however I am unsure about this. I have a remote MNGP which I would also like connect both the Classics to although I do prefer the arduino based display that I have configured to that shows me what I want to see on one screen.  I use the centre RJ11 connection for my MNGP. Each Classic would have to have a separate address (10,11). I have read somewhere about being able to change which Classic a MNGP will read from. I am guessing that I could just use a splitter for this as well and wire the MNGP to the centre connection on both Classics.

Any help would be appreciated.

I have figured out how to add "pages" to the I2C 4X20 lcd. I think if I was building the diversion control again it would not have 4 lcds...

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

dgd

  • Hero Member
  • *****
  • Posts: 1691
    • Lorylink
Re: Arduino based PWM diversion control system
« Reply #62 on: February 20, 2016, 05:41:08 PM »
Will,

You could wire each Classic into a separate serial port on the Mega or DUE, it has four serial ports.
However, this becomes complicated with the modbus library as you need to constantly rerun the modus configure with a different serial port since the lib is designed to work with only one serial port (usually rs485 with multiple devices on the rs485 bus)

You can daisy chain Classic together via serial ports, look at the online docs for the Midnite SMA Comms adaptor and in there is a nice explanation of how to do this.
You then just have the first Classic at address 10, the second at 11, third at 12 and fourth at 13
In the Arduino code just add additional modbus configures etc for devices on the additional addresses

This works very nice for me in my DUE multiple Classic web reporting system
I suppose with the decent grunt cpu in the DUE (or Cubie or BBB)  and four available serial ports it would be feasible to connect up to 16 Classics to one web reporting system  :P

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

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #63 on: February 21, 2016, 04:43:37 PM »
Hmmmm....Nothing is easy. Since I have the Classics faceplate MNGP on the upper serial port, the remote MNGP on the centre serial port and the diversion control on the lower serial port I am out of ports and daisy chaining is not in the cards. I am running a mega for the diversion control and so could use a second serial port on the mega for the second Classic. I mostly just want to able to force a float ( if need be ) on the second Classic if it does not go to float in a reasonable time after the first one does or vice versa. If that is all I would do then I could just turn on the second port, force the float and then turn it off again. Once the system goes into operation I will learn if that is needed.

I am thinking if I am not reading from the second Classic but only writing and do not have to worry about data collisions that the splitter idea should work?

modbus_construct(packet8, 10, PRESET_MULTIPLE_REGISTERS, 4159, 1, writeRegsg);

 The packet slaved device id would change from 10 to the second Classics id - assume 11 and then the modbus would just write to the second Classic????

Thanks

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

dgd

  • Hero Member
  • *****
  • Posts: 1691
    • Lorylink
Re: Arduino based PWM diversion control system
« Reply #64 on: February 25, 2016, 06:49:05 AM »
I am thinking if I am not reading from the second Classic but only writing and do not have to worry about data collisions that the splitter idea should work?
 

rs232 is strictly a point to point electrical interface, you cannot have point to multi-point which is what you are proposing with a splitter
rs485 is multi point and is electrically designed to do that
..but the Classic only has rs232 hardware

Your solution looks to be having each Classic on its own serial port on the Mega.
Then re0run the modbus configure each time you want the modbus state engine to point to a different serial port.

Also just thinking you do have enough serial ports to daisy chain if the chain starts with the new Classic
Mega connects to serial 2 on new Classic, serial 3 on new Classic connects to seriall 3 on old Classic

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

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #65 on: February 27, 2016, 03:23:01 PM »
Hi David,

Thanks for your reply and sharing your rs232 / 485 bus knowledge. I am hoping that I do not have to force floats with the new system configuration but would like to be ready if need be. I plan to split my array into two arrays and get the new Classic working before adding the additional panels. This should give me the experience to see if the second Classic going into float in a timely fashion is a problem.

I have been watching the diversion control work and have changed the logic in the lag element in order to get more Kw production. The new logic is working well but with the increased output  another problem ? opportunity ? becomes apparent. When the Classic sweeps it momentarily reduces its output. This causes the PID control to also reduce its output. When the sweep is over the PID must now increase its output back to where it was before the sweep. Sometimes this reduces Kw output by 50% every sweep interval. I am thinking if I could predict when a sweep is about to occur and then momentarily "lock" the PID output during the sweep time  that the sweep induced output reduction could be prevented.

Question : I am searching for the sweep countdown timer register which I think must exist. I know that I can set the sweep interval time manually. When I read register 4197 what I get is the sweep interval time setpoint in minutes. If I read 4284 what get is the number 200 which does not seem to change??? I am hoping to find a register or other indication of some kind which would show the time remaining and counting down before the Classic performs a scheduled sweep. I do not find anything on the Network Spec table that seems to be what I am looking for. Any ideas are appreciated.

Thanks

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #66 on: February 28, 2016, 08:52:10 AM »
On the other hand I see that the Classic has a built in RTC. Maybe sweep timing is done by noting the time of the last sweet and then adding the sweep time interval onto the the clock time. The sweep would then occur when the clock time matched the sweep target time.

Hmmmm.......

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

dgd

  • Hero Member
  • *****
  • Posts: 1691
    • Lorylink
Re: Arduino based PWM diversion control system
« Reply #67 on: February 28, 2016, 07:01:42 PM »
.. I am hoping that I do not have to force floats with the new system configuration but would like to be ready if need be. I plan to split my array into two arrays and get the new Classic working before adding the additional panels. This should give me the experience to see if the second Classic going into float in a timely fashion is a problem.
 

I think you will find that an interesting exercise. In theory, if the voltmeters in the two Classics are closely matched then both should get to float near the same time.
However in practice, I never found this to always be the case
Worst case is one goes to Float and the other which is in Absorb can't by itself maintain the Absorb voltage so drops back in BulkMPPT, probably at the Float voltage setting. Then if suddenly more PV power becomes available it will push battery back towards Absorb voltage.
Now the first Classic in Float will drop its output to Zero and after 30 seconds with FW 2079 will go to Resting.
This gets ugly and could lead to battery overcharging.

Even when both are in Absorb or Float the required current will often reach a point, especially in Float, when one Classic will supply all the power and the other will gradually supply less until its zero.
Then this Classic will go into Resting after 30 seconds.
If the first Classic moves into FloatMPPT as input power reduces then the Resting Classic will awaken but in BulkMPPT mode rather than FloatMPPT mode.
Ugly again
You will probably have to implement a form of follow-me or at least force Float to keep them synced.
The going into Resting from Float then reawakening in BulkMPPT is an issue I have not resolved yet
boB made that zero output going to Resting quite soon change to resolve a problem with the so-called reversing BUT it created another problem when using two or more Classics  ???

Anyway it will be interesting to see how you progress..

Midnite's Follow Me prevents strange things happening with different charge states, problem is it uses up all the serial ports so is of no use here.

Have Fun

dgd
« Last Edit: February 28, 2016, 07:05:02 PM by 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

dgd

  • Hero Member
  • *****
  • Posts: 1691
    • Lorylink
Re: Arduino based PWM diversion control system
« Reply #68 on: February 28, 2016, 09:37:44 PM »
Will,
I mostly resolved the changing charge states, especially from Absorb to Float by using the 'Absorb Ending Amps' termination that needs the WBjr.
Without the follow me cabling the only way to implement that across several Classics is to monitor the EA from the Classic with WBjr and when EA set point is reached do a force Float to the other Classics, easy enough on the Arduino with modbus lib.
Since my hot water diversion method watches the PV input voltage to Classic then when it exceeds a set point the Arduino starts PWM diversion, it gets to 100% rather promptly when one Classic takes over the Float voltage maintenance leaving the other with zero output and soon going into Resting state.
The PV input voltage on the resting Classic(s) rises towards OCV hence triggering the PWM diversion using an SSR between PV output and Classic input.
I am still surprised how cleanly this works, I just needed to understand my Classics and realise which was the Boss and who were the Sleepers  ???

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

dgd

  • Hero Member
  • *****
  • Posts: 1691
    • Lorylink
Re: Arduino based PWM diversion control system
« Reply #69 on: February 29, 2016, 01:17:13 AM »
I'm also not sure how the EA sharing over Classics is implemented in Follow-Me, ie if it requires the loopback, although that would seem unlikely as the command to follow-me could only originate with the Classic that has the WBjr.
I haven't experimented with it yet but I was rather hoping (wishful thinking) that the daisy chaining of Classics using serial ports and setting Modbus addresses from 10 through to 13 for four Classics would also allow the EA setting on Classic 10 (first in chain) to be shared to the other Classics, and perhaps battery temperature probe as well.
Does anyone know if this would work? boB? Ryan?

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

  • Jr. Member
  • **
  • Posts: 63
    • http://paulalting.com
Re: Arduino based PWM diversion control system
« Reply #70 on: February 29, 2016, 05:35:14 AM »
A quick hello to you guys to say I am still about and reading all the posts while lurking in the background.
Currently busy working on another industrial control system for the next few months.
I find it interesting the topics and ideas that are coming up.
Will, you really are getting into things now I see, great to see.

David, I'm keen to get back into my Cubie again soon as part of that long term web based control system I am developing.
Keep the good ideas flowing.

Paul
6 x 200W PV into home-brew 6 stage MOSFET charge controller : Microhydro 220Vac 3 phase IMAG
Primary 8 x 400Ah LiFeYPO4 Winston : Secondary 4 x 225Ah Pb : Dual SEA 700W inverters
QuadlogSCADA control and monitoring system : Tasmania, Australia : http://paulalting.com

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #71 on: February 29, 2016, 10:39:34 AM »
I am very grateful  to people on this forum who have helped me out with knowledge and suggestions as I continue to develop this Diversion Controller. I know that the control would be working anywhere near as well as it does now with out this help.  In particular Thank You Dgd for all your knowledge and insight of the Classic and communications methods - I know you have taken a lot of time to help me and reply to my questions. I am also very grateful to Paul for all the work on the preliminary controller. Thanks Paul.

I had not considered nor puzzled out the absorb / rest / bulk situation that two controls would find themselves in if there is not some form of Follow Me. There are some things that are better not to learned from your own experience. I not sure cycling the battery charge stages would be "fun"so I think I will do what I can to prevent this form of battery stage "control". This is what I think may work for me. The lead Classic (10)  ends absorb on WbJr amps. The lag Classic(s) (11+) will end on time however the timer is set so that they never get to Float before the day ends and the Classic Rests. When the lead Classic goes to Float then a float is forced on the other Classic. I think this should give good control of the end of charge using the WbJr amps and also permit coordination of the other Classics. I would have to use one of the other serial ports on the mega as Dgd suggests for this to happen. More learning for me regarding serial port configuration.......

Thanks again.

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #72 on: March 01, 2016, 11:07:55 AM »
Looks like register 4284 is the sweep timer I was looking for. It appears to count up until the sweep is toggled. I haven't quite figured out the conversion factor for it yet. Watching it for a while I can see why keeping delays out of the loop is very desirable because it seems like my loop update time may be too long to let this timer be of use.

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150

dgd

  • Hero Member
  • *****
  • Posts: 1691
    • Lorylink
Re: Arduino based PWM diversion control system
« Reply #73 on: March 02, 2016, 03:14:42 AM »
Hi Paul,
Good to see you are still watching the Midnite forums.
I have spent a lot of time playing with the Cubie and using a Chinese, from Ebay, max3232 ttl to rs232 serial board, I have libmodbus pulling data from multipe Classics. I just wish there was a bootable disk interface and software as using the SD interface, just like the DUE, is slow slow. With Apache, web page loading is not great but near acceptable, its also nice to use a better (Than Arduino IDE) gcc compiler.
Anyway, I'm getting much more code development time now and I have a couple of spare Classics in a software test bench setup. Just got a couple of 12v 150Ah (C20) SLA and some 30v 250watt PVs, all just for testing.
Also have a couple of Kids, again just for software development, I really want to get an Arduino and RPi web server and modbus interface for the Kid

dgd

PS I enjoyed reading all you Arduino forum postings, you have the patience of a saint in dealing with all those posters asking about SimpleModbus libs and other stuff. You certainly know your stuff  ;)
« Last Edit: March 02, 2016, 03:20:08 AM by 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

WillEert

  • Full Member
  • ***
  • Posts: 121
Re: Arduino based PWM diversion control system
« Reply #74 on: March 15, 2016, 10:53:27 AM »
Progress. I have mounted the second Classic ,which is needed for the array upgrade, and powered it up. I have not split my existing array yet and connected the new array to the new Classic yet so all I can do is power it up and play with it.

I continued thinking about the problem of coordinating the charge state of two or more Classics if "follow me" is not available. I do not want to lose control of diversion while transmitting charge state to a second Classic. I changed the second arduino in the diversion control to a Mega from an Uno and got the new Classic (11) talking to the new mega (Mega 2) over serial1. The old Classic (10) is also using serial1 to talk to the old mega (Mega 1). My plan is get the 2 megas exchanging data over another of their serial ports. At present - using a matrix of digital pins I am sending charge state data between the two megas. This will let me force a float on Classic 11 when needed.

I have not seen follow me work so I am unfamiliar with how it really functions. Does it always put the following Classic in the state of the leading Classic? If the lead Classic should come out of Resting and go into Bulk I don't know if it would make sense or do harm to put the following Classic into Bulk at that time if it can't make power. Also just because one Classic goes Resting the other Classic may still be able to produce some power - would it also go Resting? I have looked for more information about what actually happens when "follow me" is in service but so far have not found to much.

I installed the second battery temperature sensor for the second Classic. The two temps read .9C different from each other although they are located within an inch of each other on the same battery. I think coordinating two Classics to work at maximum safely and get diversion happening smoothly may be more interesting? challenging? than I thought. Of interest also is that the two Classics sense the battery voltage .8 different from each other also but possibly that will change when Classic2 produces power or I can tweak that.

Will
24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 3x Magnum 4448, homecooked diversion system
+ 15 Heliene 330 mono, Classic 150