Arduino based PWM diversion control system

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

Previous topic - Next topic

WillEert

I am very new to Arduino and writing code and electronics in general. I live off grid and have done for a number of years. I have a classic 150 that I enjoy using. I have not been able to find a setpoint for the Aux 2 PWM threshold and width that works well consistently. My diversion control problem symptoms are similar to cpfl on the Raspberry pi section of this forum. I believe what is needed is a means of turning the diversion on when excess power is available, regulating the PWM rate to control battery voltage and then turning the diversion off when the excess power is no longer available. If a WBjr is used then AUX2 is no longer available for diversion use.

Thanks to dgd and Paul Alting who have been giving me advice and assistance. I have obtained an Arduino Uno R3 and have achieved making an LED blink at a variable rate. I have ordered an ethernet shield, rs 232 shield and a suitable DB 9 rs232 to RJ 11 cable ( Thanks dgd). I am on my way.

Question - If the Arduino connects to the Classic at the centre RJ 11 connection then can Follow Me still be used? I know my system will have to get bigger and that I will need to stack another Classic in order to get the capacitymy system requires. Maybe a splitter?

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

dgd

WillEert,
It's good to read you are getting into electronics and micro controller coding. The Aduino is, IMHO, just about the best introduction with the bonus that it's straightforward to create some real world useful applications - in this case some very nice extensions, both hardware and software, for the Classic.
Keep us informed of your progress  :)

When you extend your RE system to include a second Classic then follow me can be implemented using the Arduino. I have experimented with this but have not yet found it absolutely necessary as my Classics track battery voltage very accurately and change charge state at almost same time.

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

Waiting for my parts and manuals to arrive. What to do. One of the manuals I ordered - Arduino for Dummies (I do not feel like a dummy) has arrived so I am reading that. I cannot do the exercises as I lack the hardware but that will come. Learning lots.

Found the MODBUS Network Spec. rev B.3 --- May 28,2013. Reading that and attempting to understand it. I think I will have to almost memorize this document by the time I am done. Looking for registers that hold data that would be needed for a controller to operate.

Questions - The document references tables that I do not find in the document ; for example table 4146 - 1 USBcommMODE. Are there more tables somewhere else? Maybe these are internal tables that can only be seen when viewing the registers? Maybe the document is not complete or has been modified? I am thinking I may cut and paste this document to organize the tables in numerical order to make them easier to find.

                - Is register 4149 the Absorb set point voltage as it states or actually the Absorb voltage set point?

                - Are the voltage setpoints, 4150,4151,4149?,  the Tcomp set point that the Classic is actually controlling the stage voltage  to? I do not find a TComp setpoint register anywhere in this list.

Thanks

Will the Noobie
(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

ClassicCrazy

Somewhere on the web was an Arduino simulator where you could build circuits that would work .
For some good Arduino tutorials check out Adafruit  .
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

More of my textbooks and hardware has arrived. Went to Adafruit and downloaded the lessons and other info. Thanks ClassicCrazy for the tip. Studying like wild when I am not building our new house or gardening or doing life.

Success - I was able to compile and upload dgd's sketches from the rs232 and uno webserver topics. Thanks again dgd for all your thought and work.  Had problems compiling at first but once I did more learning about libraries and also found the correct modbus library things worked very well. Ordered an LCD shield and waiting for my RJ11 to db9 cable. I suspect that I will have to be careful about the pinouts  on this connection???

Cheers

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

paul alting

#5
I'm looking for some input into this diversion control code I am writing for the Arduino for Will to use.
At present I have most of the basic code skeleton there to support various parts of the functionality, but am undecided about the a central core part of the control methodology.

To summarise, the code is designed such that it talks to the Classic to get the current situation of the charge controller, the PV array and battery bank.
Based on the situation, it should be able to work out when not to allow diversion to occur or when to allow it.

The Arduino code will provide two outputs that will be PWM independently to their respective loads, but in a lead / lag control.
This form of control will initially bring on the lead output under PWM to provide smooth ramping up of the diversion energy to the load.
As energy becomes available from the PV array and knowing the battery bank has completed the charge process and is in 'float' mode, the control will continue to ramp up the PWM output on one of the outputs.
If the energy form the PV array is such that there is more available than the load can consume, the controller will at that point bring on the second output at full 100% on while zeroing the PWM on the initial output. If the two loads are equal in power dissipation then this will be seen as a transparent and smooth condition change, from lead load being 100% PWM to lag load being 100% on (not PWM) and lead load being 0% PWM.

All that is good and I have no problems with that part, having done these things in PLC's for industrial compressor systems.

But, my thinking is that with a charge controller, if the energy diversion is such that the load is to be via an inverter that is connected back to the battery bank, then essentially the load is being powered by the battery bank, based on the condition that energy diversion is allowed only when the battery bank has completed its charge cycle and is in 'float' mode.
In 'float' mode, the charge controller just maintains the voltage according to the float setpoint.

My understanding is all charge controllers will drop back to 'bulk' mode when the battery voltage falls to another predefined setpoint.
With this, it is also true that to get the energy from the PV array to the load, via the charge controller and battery bank, the energy diversion controller will not want the charge controller to be in 'float' mode. It will need to be in full on charge mode, whether that is 'bulk' mode or whatever. The idea is that we want maximum energy flow though the circuit so that it can be 'diverted' to the load.

The reason I am thinking that this controller will need to force the Classic back into 'bulk' mode is so that no or very little energy is taken form the battery bank to support the diversion system.
We want the battery bank to remain fully charge and ready for when it is needed after sun down.

So, my thoughts are, if the diversion controller manually forces the Classic to go back into 'bulk' mode, what impact does this have on the way the Classic handles things and does it then confuse the Classic in anyway ?

So, to confirm, the energy diversion system is essentially connected to the battery bank and will have its own inverter to supply the two AC loads.
The other side of this dedicated diversion inverter will have two AC SSRs that will be controlled by the Arduino at a rate the AC SSRs can handle, which is slower than the inverter line frequency, due to zero-crossing switch on and the fundamental function of how a SSR (internally a TRIAC) only switches off at the zero point as well.

I have mentioned to Will, the other concept of taking the energy pick up point directly at the PV array input to the charge controller, if the PV array VOC matches the specifications of the load.
He mentions this might be a workable idea as well. The PV array VOC is around 110Vdc, which would suggest it could be used to feed the approximate 110Vac load heating elements.
In this case, we could use a DC SSR to feed the PV array directly to the load elements without any need for a dedicated inverter.
Also, since it would not be connected to the battery bank, there is little risk of depleting the store energy form the battery under any condition.
Added to this would be the small increase in efficiency of transferred energy from the PV array to the diversion loads, having not to pass through the charge controller and then back through the dedicated diversion inverter.

I would like to hear what thoughts and ideas other might have or tricks about the Classic that I don't yet know that would help me formulate the correct control methodologies for this Arduino controller.

The Arduino project is named SEnDArd - Solar Energy Diversion control program for Arduino, any other suggestions ?
____
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

cpfl

#6
QuoteMy understanding is all charge controllers will drop back to 'bulk' mode when the battery voltage falls to another predefined setpoint.
With this, it is also true that to get the energy from the PV array to the load, via the charge controller and battery bank, the energy diversion controller will not want the charge controller to be in 'float' mode. It will need to be in full on charge mode, whether that is 'bulk' mode or whatever. The idea is that we want maximum energy flow though the circuit so that it can be 'diverted' to the load.

The reason I am thinking that this controller will need to force the Classic back into 'bulk' mode is so that no or very little energy is taken form the battery bank to support the diversion system.
We want the battery bank to remain fully charge and ready for when it is needed after sun down.

So, my thoughts are, if the diversion controller manually forces the Classic to go back into 'bulk' mode, what impact does this have on the way the Classic handles things and does it then confuse the Classic in anyway ?

Paul,

As per my thread on the RPi side, "Continuous tweaking of AUX2 threshold for maximum PWM output", you can redirect all available power to the diversion load without it affecting the charge controller mode.

current battery volts    = modbus register(4115)
target battery volts      = modbus register(4244)

Any controlled changes to the diversion load (by adjusting the PWM value) should make sure that the current battery voltage remains as close as possible to the target battery voltage. As long as the current battery voltage is within about 0.4 volts of the target battery voltage then it will not affect the charge controller mode, ie BULK, ABSORB, FLOAT, EQ. Ideally, the current battery voltage should be kept at 0.2 volts under the target battery voltage.

Attempting to maintain the 0.2 volts under target will ensure that even when the sun sets or is obscured by clouds temporarily, the system will compensate and reduce the power going to the diversion load. The battery bank should never be discharged due to the diversion load.

Chris
Off-Grid in a 320 sqft tiny home (plus 320 sqft attached workshop) in Texas, USA: Midnite Solar Classic 150, Magnum Energy MS4448PAE, 9 x Kyocera KD240 (2160 watts) + 9 x Kyocera KU265 (2385 watts), 16 x GC2 (400AH 48V), Raspberry Pi (ethernet & RS485 monitoring).

paul alting

Chris, that clarifies it for me nicely, thank you.
Now I have the a better understanding and the missing piece of the puzzle is found.

I'll re-read what you say and have identified this section in your C code where you do this.
I think if I utilise what you say above and use that to be the input to the PID block which then provides output to the PWM, I hope that will be getting closer to what is needed.

Just trying to calculate what 320 sqft is in square meters, I think we have similar size little cabins :)
____
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

cpfl

#8
Paul,

I think you'll have Will's project cracked now.

If and when I decide to get a WBjr for my system, I will be looking at implementing the same thing.

Yes, the 320 sqft (30 sq meter) cabin is cosy.

Chris.
Off-Grid in a 320 sqft tiny home (plus 320 sqft attached workshop) in Texas, USA: Midnite Solar Classic 150, Magnum Energy MS4448PAE, 9 x Kyocera KD240 (2160 watts) + 9 x Kyocera KU265 (2385 watts), 16 x GC2 (400AH 48V), Raspberry Pi (ethernet & RS485 monitoring).

WillEert

I am very grateful to all the people who are contributing to this diversion control project. Thank You. We are building a new house and optimizing the power supply is important to us as we want to get to net  zero carbon  with our lives.  I am on my 6th book now about Arduino and its capability's and am gradually learning to speak the language. I have done a little basic coding and can see that it will take me a long time to reach the level of expertise of Paul, Cpfl and dgd. I am learning a lot which I enjoy. Paul is teaching me much which is very helpful - Thanks Paul for taking me under your wing. 

I have been buying hardware and getting ready to go. I think I have  figured out the pinout for the RJ11 - DB9 cable and have ordered the parts needed to make a nice one. We decided to use a Mega 2560 R3 for this control and it has now arrived as has the RS232 shield. As I have time I will try to get dgd's LCD Uno system ( I have the parts for that) up and running to prove out the cable. I want to use the lower RJ11 port as I presently have a remote MNGP connected to the middle one. I don't see downside that except possibly we cannot write to that port?

Thanks again. I guess I will know if I got the pinout correct if any magic smoke comes out of some of this equipment when I plug it in

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

T

#10
Here is my Arduino based diversion control code.

I have 2 aux outputs on this. I'm using aux1 for an air conditioner and aux2 for a dc water heater element.

I went with a PWM frequency of 30hz because it produces much less heat in the SSR compared to the aux2 of the classic which I believe is 500hz.The 30hz frequency does track slower. It takes a few seconds to go from 0% duty cycle to 100%, or back down, but it really doesn't seem to matter in my system.

The settings are easily adjustable by changing the variable values at the beginning of the code.

The only input I'm getting from the classic is the Float High signal from Aux1. I configured the Aux1 jumpers for relay operation and use it to switch 5v from the Arduino to a digital input pin on the Arduino.

For battery voltage measurement, I just use 2 resistors as a voltage divider and input the voltage between the two to an Arduino analog pin.

I power the Arduino with an adjustable voltage regulator which I configured to output 9.8 volts. The SSR's are fed from this 9.8 volts through transistors that are switched by the Arduino output pins... not sure if the Arduino pins could power the SSR's by themselves or not.

I have the voltage settings at a point where my batteries will typically be over 90% before the water heater begins to PWM. However,I am giving priority to hot water over Absorb with these settings because I hate cold showers.

I've had this up and running for about 2 weeks now and it works very well. I can now use the Classic Aux2 port for the WBjr if I want to...I do have a separate SOC monitor already. The main reason I did this was to PWM the water heater at a lower frequency and get more control over the diversion outputs.

I think one advantage of this design (with minimum input from the charge controller) is that it can easily be made to work with a different charge controller. This would be great if my Classic had problems and I needed to switch back to my cheap pwm charge controllers temporarily.

Hope this can help with your project.






unsigned long timeOfLastFloat = 0;
float aux1BulkSetPoint = 50.0;   // I set this high to run only in float
float aux1FloatSetPoint = 13.4;
float aux1SetPoint;
unsigned long minOnTime = 300000; // aux1 delay in milliseconds
unsigned long minOffTime = 180000;
unsigned long timeOn;
unsigned long timeOff;
boolean aux1State = false;

int aux1 = 10;  // using aux1 for window air conditioner through inverter.
int aux2 = 11;  // using aux2 for 300w dc water heater element.
int floatRelay = 2;
int voltagePin = A0;
float voltage;
float voltageFactor = .0206;
float aux2BulkSetPoint = 13.8;
float aux2FloatSetPoint = 13.2;
float aux2SetPoint;
unsigned int pwmSetPoint = 0; // start with duty cycle of zero. 100% duty cycle = 255
unsigned int pwmSetPointInc = 2; // amount to increase or decrease duty cycle each loop
//unsigned int ctr = 0;

void setup() {

  TCCR2B = TCCR2B & 0b11111000 | 0x07;   //set timer2(pins 3 and 11) to 30hz

// Serial.begin(9600);
  pinMode(aux1, OUTPUT);
  pinMode(aux2, OUTPUT);
  pinMode(floatRelay, INPUT);
  digitalWrite(aux1,LOW);
  timeOn = millis();
  timeOff = millis();
}


void loop() {


// Get float signal from aux1 of classic (with aux1 set up in relay mode). 5v from arduino through classics
// aux1 relay provides the input to floatRelay. Aux1 on classic set to float high mode.
// Then set voltage points to their bulk or float values.
// timeOfLastFloat is set to keep voltages at float values when Classic goes into float mppt mode.
 
  if (digitalRead(floatRelay) == HIGH){
    aux2SetPoint = aux2FloatSetPoint;
    aux1SetPoint = aux1FloatSetPoint;
    timeOfLastFloat = millis();
   
  }
  else if ((timeOfLastFloat == 0) || ((millis()-timeOfLastFloat) > (28800000))) {  //28800000 is 8 hrs in milliseconds
    aux2SetPoint = aux2BulkSetPoint;
    aux1SetPoint = aux1BulkSetPoint;
  }

 
//read battery voltage


  voltage=analogRead(voltagePin) * voltageFactor;

// aux2 logic (PWM)

  if (voltage >= aux2SetPoint) {
     if ((pwmSetPoint + pwmSetPointInc) <= 255){
       pwmSetPoint += pwmSetPointInc;
     }
     else{
       pwmSetPoint = 255;
     }
     
  }
  else if (voltage < aux2SetPoint) {
    if (pwmSetPoint >= pwmSetPointInc) {
      pwmSetPoint -= pwmSetPointInc;
    }
    else{
      pwmSetPoint = 0;
    }
  }
 
  analogWrite(aux2,pwmSetPoint);
 



//aux1 logic (ON/OFF with delays)
 
  if ((voltage >= aux1SetPoint) && (!aux1State) && ((millis() - timeOff) >= minOffTime)) {
    aux1State = true;
    pwmSetPoint = 0;  // turn off power to aux2 to ease starting of motor on aux1
    analogWrite(aux2,pwmSetPoint);
    timeOn = millis();
    digitalWrite(aux1,HIGH); //turn on aux1
    delay(2000);  // delay starting aux2 for 2 seconds
  }
 
 
  else if ((voltage < (aux1SetPoint - .4)) && (aux1State) && ((millis() -timeOn) >= minOnTime)) {
    aux1State = false;
    timeOff = millis();
    digitalWrite(aux1,LOW);
  }
 
 
 
/*  used for debugging only
  ctr++;
  if (ctr >= 90){
    Serial.print(aux1SetPoint); Serial.print(" ");
    Serial.print(aux1State); Serial.print(" ");
    Serial.print(voltage); Serial.print(" ");
    Serial.print(millis()); Serial.print(" ");
    Serial.print(pwmSetPoint); Serial.println("");
    ctr = 0;
  }

*/
  delay(33); //This delay equals approximately 1 period of a 30hz signal

 
}
Classic 150. 12 - 100 watt panels(6 strings with 2 panels in each string, 24v nominal). 12v 500ah battery bank.

paul alting

#11
Hi T, welcome to the forum.
Thanks for your insight and code that you use, just soaking it in with the way you do it.

Yes, I have found the Arduino is quite capable to switch the SSR directly, though going through a level transistor can only be better as not all SSR's are the same.

With your battery measuring, only using two resistors, I am guessing you are working at the lowest workable level, yes, I think you are on a 12 volt system
Anything higher becomes problematic with using two resistors as your scaling and then resolution is lost.
I do use this for my system at present and am on a 24 volt setup.

Will is on a 48 volt system, so using a resistor divider is not going to work.

Instead, we are using Modbus to get all this data from the Classic, which will be far superior in terms of accuracy, resolution and stability.

Like you, I am making my code adaptable to be used with other charge controllers, with the code making allowances for Modbus register maps for other charge controllers, such as TriStar units.
At present the code I am working on for Will is designed now to operate in a Mega based board due to the need for controlling two loads.
An Arduino UNO has the capacity for two PWM, but that gets reduced to one if there is ever the need for Ethernet.
Again, the design behind what I am doing is that a lot of this is sorted out by the pre-process before compilation.

One thing with SSR, which you will probably know, and that is that AC SSR's are limited to how fast they can operate due to the zero-crossing point used for on switching and the same point as a function of how the internal TRIAC works anyhow. This means that a typical AC SSR can only be switched on and then off, no more than once every cycle of the AC waveform, as there are two zero-crossing points in a single cycle.

With DC SSR's, they are essentially a MOSFET and can operate quite fast, and the ability to PWM this at a higher rate is something that can improve the overall control effectiveness.
As with any semiconductor device, working in the digital domain, components will get hotter with higher switching rates, especially with MOSFET based devices.

You say you are using DC for water heating, can I assume you are taking the DC direct from the PV array via a low voltage high current DC SSR, such as a 60V 40Amp device ?
Can you tell more about your setup, in terms of the PV size and batter capacity ?

I am sure I see 'T' over on the Arduino forums just in the last few days :)
Well, all this brings in new ideas and it is good to see how other people are doing things.

Hopefully I will have some code and a document to share in the coming week or two. The code itself is over a number of files and over 1k lines, errr, so far :)

Thanks 'T', whoever is behind that, for your input, and hope you can share more as things develop.
Edit: oh, can you edit you last post and place your code in code tags please.
I only asked someone in Arduinoland a few hours ago to do same. One day, these forum software's will be able to detect it automatically, one would hope.
____
Paul (aka Rockwallaby in Arduinoland)
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

#12
T
With your code, a few things pop up for me.
First is the method of controlling the PWM, it will bounce back and forth between the setpoint dead-band limits, continually oscillating in a sawtooth waveform.
Obviously this will work, but can be improved by using a PID loop control function to provide nice smooth and stable signal which then can be applied to the PWM function.

The other thing is you have a delay(2000) in your main loop.
I'm just now writing an email to another who is writing Arduino code about the pitfalls of over use of the delay(x) function.
Short delays are mostly not a problem, where the delay is only a few mSec, but a delay of 2000mS (2 seconds) really does have the potential to mess up a control system.
Many people put delay(big) in so many places that they often don't understand why their code does not perform the functionality they expect.
I ask everyone to first check for these delay(big) statements and remove them or refactor the code differently so the delay is not needed.

For AC SSR's I found the Arduino statement analogWrite(..) produces a PWM that is far too fast, typically I recall around 490Hz.
Instead, I use a timer library, such as Timer1 or Timer3 and then generate a PWM cycle period of a much lower rate.
I guess if you are using a DC SSR, then that will allow you to use the analogWrite(..).

Another area where you can save time on processing is to do away with all the floats and only use integer based types for everything.
Again, many folks think to do things they need to represent the data as they would, and that is typically as floating point data.
With virtually all the code I have written, I never use floats, not unless a sensor library provides it to me as a float, to which I quickly then and there scale it to an integer type.

For example, if you are reading a battery voltage of 12.6 volts, why work with a float of 12.6, instead, work with a scaled representation of this, typically scale by a factor of 10 or 100, but be consistent.
So, your 12.6 will become 126 as an integer. This is far easier for the poor Arduino CPU and when you are really needing to reduce processing time, then this is a method that has dramatic effect.

I go one step further, and that is I work with raw data where I can.
For example, if I read the analog port, I simply use that data throughout the program.
It will be from 0 to 1023, so 1024 counts of raw ADC data.
This means you loose no resolution along the way and all condition checking will be as accurate as possible as you have the raw data, you can't get better than that.
Typically I only convert from raw to more meaningful human readable data at the point of display, whether that be on a simple LCD or at once it enters the SCADA system and gets to a web page.

Hope what I have mentioned can be helpful :)
Right, back to coding for me  8)
____
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

T

Hey Paul, thanks for the input and suggestions.

My solar setup consists of 1200 watts of solar panels, wired for 24v nominal output. I have a 500ah 12v battery bank.

I am feeding the water heater from the 12v nominal of the battery bank (not directly from the solar array). Actually with my controller all current to the water heater will come from the output of the Classic, without drawing from the batteries.

I like your PID idea.  I may incorporate that into the code for the water heater control...probably just the PI part of it.

I am going to take out the delay(2000) statement in the code. It's not detrimental, but not really necessary after setting the duty cycle of the PWM to zero. This section of the code will only run when the air conditioner is switched from off to on...no more than once every 8 minutes minimum with my current settings.

I'm getting 30hz by using analogWrite(). The following statement in the code is what makes it happen: TCCR2B = TCCR2B & 0b11111000 | 0x07;

I could PWM the water heater at a higher frequency, but it's very inefficient on those very cloudy days where the duty cycle may be low for extended periods of time. This is the main reason I built this controller instead of just using Aux2 on the classic.

I can understand the performance advantages of using only integers in your code. I will keep that in mind for future projects that place greater demands on the processor.

Also, I haven't posted anything on the Arduino Forums. Must be a different T over there.












Classic 150. 12 - 100 watt panels(6 strings with 2 panels in each string, 24v nominal). 12v 500ah battery bank.

WillEert



Hi T,

Thanks for posting the code for your diversion controller. I will download the code and look at it. It is very interesting the various methods of diversion used and I find I can learn from each system. Thanks again.

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