Author Topic: Automatic Inverter Cycling, Low Voltage Disconnect  (Read 1186 times)

0 Members and 1 Guest are viewing this topic.


  • Hero Member
  • *****
  • Posts: 1084
  • Country: us
Automatic Inverter Cycling, Low Voltage Disconnect
« on: December 15, 2016, 06:51:42 AM »
I was on another site where someone was asking what the name of a relay was
that would turn off his inverter with low battery and transfer the refrigerator to
grid power.  Then revert back to batteries when battery recovered. Another had
his inverter shutting off with alarm, but he manually had to reset the inverter
to restart. So what was the name of this magic relay they asked. I forget all the
trade names for devices, but I used to make them and got on the company website.
I couldn't find them. I know they still make them, but 90% of what they make is
custom and the standard products are there to just bait and switch to something
private label. Surely ebay had this under some name for cheap. Searching key words
came up with nothing. The item is just a voltage set/reset relay that drops out at
a low voltage and pulls in at a higher reset voltage.

I later found it as Low voltage Disconnect, don't know why these didn't show up in my initial search.
A few less features.

Seemed like a nice project for a UNO.  I started programming a complex one that had
timers to prevent hot starts, and sequencers to control a transfer relay and turn on
the inverter separately. His application was for a refrigerator. Do you do a hot swap
with everything running or transfer power lines and then start the inverter.  There
are reasons for both. So, that program is tabled for a while. I did repurpose it for
a simpler program that could be useful.  My first refrigerator control worked on a
similar idea.

This program operates the inverter any time switch pin #2 is left open to common.
That switch could be a float switch or thermostat contact. It can be left unconnected
as the micro has an internal pull up.  It then just operates as a low voltage disconnect,
just better. I waits till the battery has significantly recovered and for startup battery
slumps of motors, it requires the low voltage to exist for continuously for 25 seconds.
Any voltage rise resets the timer.  Also, the relay state can change no faster than that.
This lockout can be easily changed.  This is a must for any voltage relay to prevent
false triggering and short cycling when the battery is in a fairly discharged condition.
A debug screen displays all the variables so program operation can be watched. The relay
driver is PWM reducing heat and power consumption. Quite useful as it is presented and
other options could be added to this program.

The restart voltage is arbitrarily set to 13.5 volts.  I use a higher restart voltage
in my system. It is fairly easy to get a nearly dead battery up to that voltage with
a moderate charge current. I feel it is better to wait till the battery has a fuller
charge than keep cycling at a discharged state. This voltage is highly dependent on
your situation such as battery and panel size. A second analog input has been stubbed
in. A radiance sensor could be added. With a larger array and bright sun, the inverter
could be turned on at a lower voltage if charging could also be supported. Grid power
could also be monitored. In a power outage the dropout voltage could be lowered to
power critical devices longer.  A grid/inverter transfer relay can be easily added.
Just use a 120V AC DPDT relay powered from the inverter.  This will transfer the power
any time the inverter is operating. I prefer software controls to prevent hot starts
of refrigerators, but they are designed to withstand short voltage outages. Statistically
these hot starts will be a fairly rare occurrence anyway.

heck your inverter manual to see at what over voltage it trips out at. The over voltage
trip in this software is intentionally quick. You don't want to get into a situation
where the inverter trips and then it has to be manually reset. It might be a good idea
to add an extra LED saving that trip. It could be an early alert that a problem exists
like a bad connection. The same could be said for the low voltage drop out. There are
plenty of pins to add a few extra LED. Light an additional one for each drop out. A PWM
output could do the same thing by changing voltage.  This could indicate when batteries
are aging or more panels are needed.  Data can give insight to your system. There are
lots of possibilities. Add that automatic outdoor light or add ventilation when batteries
are full.

The optional switch input is on pin #2 to GND. Leave this open and the inverter will
run till an under or over voltage condition exists. Close the contact and the inverter
will turn off. Battery voltage is read on pin A0 from a voltage divider creating about
3.5 volt. The debug screen allows you to adjust a pot till the voltage reads correctly.
The miltiplier can be changed to adjust to the divider.  Have at least 47K, high side
resistor, between the battery and the analog input pin.  Avoid having potentially more
than 5V on that pin. A 1-4.7uF capacitor should be placed at the analog input to GND to
filter noise spikes and smooth out voltage changes that may be caused by the charge
controller pulses. PWM output is at pin #10. Drive a FET through a 100 ohm resistor.
The relay MUST have a diode across the coil. Ideal supply for the uno is about 8v. Those
little LM2596 switching regulators selling for $1 are ideal for this because it will
reduce current draw. Always make multiple GND pin connections to the board.

Again this is a demonstrator program.  It seems to work as designed, but hasn't been
extensively tested.  I hope you will load it into your, try to follow the code and
logic using the debug screen.  Decisions are made by identifying all the possible
conditions and testing those for each case. Think of it like being in a room and watching
meters and lights. Just think what you would do given what you were seeing. That becomes
the program. If there is some part that is hard to understand, pick out six or so lines
and post them. I will explain what is happening in more detail. It is hard to anticipate
sticking points a new learner will have.

1 and 0 are ON and OFF. That is becoming universal for powered devices. If it makes reading
the code easier these could be changed to variables YES and NO.  That may make it easier
to read the logic, if(INVERTERon == YES) digitalWrite(LED13, ON; may be more obvious at
first glance. Directly using numbers instead of making the screen look like alphabet soup
may work for you. Assigning names to numbers will make it easier in large programs to make
changes. If a number is used multiple times in a program, it is easier to change it in one
place rather than searching through the program for where it could have been used. Choosing
names is difficult when the same type operation is done in multiple parts of the program.
Inhibit, delay, lockout, dropout can be applied to similar operations. It is easy to lose
your reference.  I often go back and change variable names when a better one comes to mind.
Make it self explanatory. Six months or a year later those self explanatory names will keep
you from wondering what the program is doing. A lot to juggle in your head. It just gets
easier the more times you look at different programs.  This is a language. You can't be just
dropped in a new country and start speaking.  Give it a chance to sink in.

The other day I was looking at a post where a resistive temperature sensor was used to
turn a LED on and off. I had used the same temperature sensor in my water heater program.
What he was doing could be bought on ebay for $2.50 shipped. OK, he wanted to do a project.
This could be done in 6 lines of program.  I looked at the code and initially couldn't
figure out what he was doing. It was all very proper and correct. He must have just finished
a programming class and wanted to look like a real programmer. He still lacked any practical
experience as his A/D readings weren't averaged. Random converter noise would drive that LED
crazy. The point is you will see a lot of programming on the internet and it will look like
a whole page of swearing. First thought is I'm dumb as a stump and will never learn to
program. Top notch programming is a beautiful thing to see. A lot like a mathematician who
spends 20 years trying to prove the existence of zero. We know what zero is. There are
shortcuts with characters that seem to defy understanding. You can write programs without
getting into any of that clever stuff ever. Don't let those programs intimidate you. They
probably don't work that well in an application anyway.

"Nobody's so damn well educated that you can't learn ninety percent of what he knows
in six weeks.  The other ten percent is decoration."
Kurt Vonnegut, Player Piano

On a side note, my summer home is only a half mile from where he wrote that.

« Last Edit: December 15, 2016, 07:45:20 AM by OperaHouse »


  • Hero Member
  • *****
  • Posts: 1084
  • Country: us
Re: Automatic Inverter Cycling, Low Voltage Disconnect
« Reply #1 on: December 15, 2016, 06:57:49 AM »
   SWITCH_OFF_BAT_1 program for switching inverter
 1.  Read battery voltage
 2.  Read switch input
 3.  Turn off inverter with low and excessive voltage
 4.  Delay to prevent hot start or rapid changes
 5.  PWM relay to save power
 6.  Wait for battery to reach near full level before restart

Upon posting, this document is considered “uncontrolled”.
Please contact me for the most current version.

 CREATED 12/13/2016
 REVISED 12/15/2016

// Declare variables as integers and set initial values

int AI0            = 0;           // Battery raw A/D conversion
int AI1            = 0;           // spare
int kbd            = 'h';         // start with help screen
int blinktime      = 0;           // blink counter
int enable         = 0;           // enable inverter power ON SWITCH
int Ipower         = 0;           // INVERTER powered
int ENDpwm         = 160;         // END value of pwm for lower power
int battery        = 0;
int LOWvolt        = 12300;       // low voltage dropout
int STARTvolt      = 13200;       // restart voltage
int HIGHvolt       = 15000;       // excessive voltage turn off
int inhibit        = 10;          // seconds, initial startup delay
int hotstart       = 25;          // seconds, hot start delay
int lockout        = 0;           // prevent shut down from momentary dips
int seconds        = 0;
int minutes        = 0;

void setup()
// initialize the digital pins
// Pin 13 has LED on Arduino UNO board

pinMode(13, OUTPUT);                // board LED output enabled
pinMode(2,  INPUT);                 // switch on pin 2 input enabled
digitalWrite (2, HIGH);             // add pullup to input

Serial.begin (9600);                // Set up serial monitor routine

void loop() {                       // This is the start of the program

  // ******************************************************************
  //       Inverter enable code can be placed here such as read a switch
  enable = digitalRead (2);         // read switch for enable, ON if left open
  // enable = 1;                    // force enable on, delete if switch input is read
  // ****************************************************************** 

  // This section reads the analog signals.  Range is 0 to 5V DC or 0 to 1023 counts
  AI0  = analogRead (0);            // Anolog In.  Read the battery voltage PIN #A0
  AI1  = analogRead (1);            // Anolog In.  Spare
  battery = battery - battery/ 17;  // or 18, subtract one average reading
  battery = battery + AI0;          // add in a new reading
  if (battery > LOWvolt && Ipower > 0 && blinktime == 0) lockout = 0;
  if (battery < LOWvolt && Ipower > 0 && blinktime == 0) lockout = lockout + 1;
  if (battery < LOWvolt && Ipower > 0 && lockout > hotstart)
    lockout = 0;              // reset lockout
    Ipower  = 0;              // turn INVERTER RELAY OFF
    inhibit = hotstart;       // institute INHIBIT to prevent rapid transition
  // battery over voltage, inverter power off                     
  if (battery > HIGHvolt && Ipower > 0 && inhibit == 0 )
    Ipower  = 0;                    // turn INVERTER RELAY OFF
    inhibit = hotstart;             // institute INHIBIT to prevent rapid transition
  // inverter enabled, battery normal voltage, inverter power off, no inhibit                     
  if (enable == 1 && battery < HIGHvolt && battery > STARTvolt && Ipower == 0 && inhibit == 0 )
    Ipower   = 255;                  // turn INVERTER RELAY ON
    inhibit  = hotstart;             // institute INHIBIT to prevent rapid transition
  // inverter disabled, battery normal voltage, inverter power on, no inhibit                     
  if (enable == 0 && Ipower > 0 && inhibit == 0 )
    Ipower   = 0;                    // turn INVERTER RELAY OFF
    inhibit  = hotstart;                   // institute INHIBIT to prevent rapid transition
  // This section sends out serial data contained in the program. It has no actual functional
  //use in the program.  It can be viewed by
  // using SERIAL MONITOR in TOOLS when the ARDUINO programmer is running.  The program
 //can run without any serial monitor connected. 
  // Some diagnostic section like this should be included in all programs.  It will save a lot
  //of time in the development of programs.

  if (Serial.available() > 0) kbd =;    // look for and get keyboard character 
  // kbd is the character returned from keyboard

    if (kbd == 'r' || kbd == 'R')  // RESET everything
      Ipower   = 0;          // turn INVERTER RELAY OFF
      seconds  = 0;
      minutes  = 0;
      inhibit  = 10;         // institute inhibit
    kbd == 'z';              // reset keyboard to non used character each loop
    if (kbd == 'H' || kbd == 'h')    // if H send out HELP screen
    Serial.println("  ");
    Serial.println("  ");
    Serial.println(" H  HELP SCREEN ");
    Serial.println(" R  RESET TEST ");
    Serial.println("  ");
    Serial.print (ENDpwm);
    Serial.println (" RELAY END PWM  ");
    Serial.print ((float)LOWvolt/1000);
    Serial.println (" LOW BATTERY VOLTAGE  ");
    Serial.print ((float)STARTvolt/1000);
    Serial.println (" RESTART BATTERY VOLTAGE  ");
    Serial.print ((float)HIGHvolt/1000);
    Serial.println (" EXCESSIVE BATTERY VOLTAGE  ");
    Serial.print (hotstart);
    Serial.println (" SECONDS HOT START INHIBIT  ");
    Serial.println("  ");
    Serial.println("  ");
    delay (2000);      // keep screen for two seconds of viewing
    kbd = 'z';   
  //                   BLINK BOARD LED and COUNT TIME
  // This section blinks the board LED when the micro is working.
  // sequenced using a count routine. 

  blinktime = blinktime + 1;     // increment blink counter
  if (blinktime  == 100)         // 100 ish is about 1 second
    blinktime = 0;               // Reset blink counter
    seconds = seconds +1;        // increment seconds
  if (blinktime  == 0 && seconds >= 60)   // 60 is 1 minute
    minutes = minutes +1;         // add a minute
    seconds = 0;                  // reset seconds
  if (minutes > 10080) minutes = 0; 
  // this could be entered into MAP and output as a PWM voltage
  // included so counter does not overflow. possibilities......
  //                      INHIBIT LOGIC
  if (inhibit > 0 && blinktime == 60) inhibit = inhibit - 1;   // decrement inhibit every second
  if (Ipower > ENDpwm && blinktime == 0) Ipower = Ipower - 1;  // decrement PWM 
  //              SEND OUT RELAY DRIVE
  analogWrite(10, Ipower);                // analogWrite values from 0 to 255
  delay (10);                             // delay creates second interval

  //             BLINK LED     
  if (blinktime == 0) digitalWrite (13,HIGH);   // processor on blink #1
  if (blinktime == 5) digitalWrite (13,LOW);
  if (enable == 1 && blinktime == 10) digitalWrite (13, HIGH);  // enable on ON
  if (blinktime == 20) digitalWrite (13, LOW); 
  if (battery < LOWvolt && blinktime == 30) digitalWrite (13, HIGH);  // LOW BATT
  if (blinktime == 90) digitalWrite (13, LOW);   

  if (battery > HIGHvolt && blinktime == 30) digitalWrite (13, HIGH);  // HIGH BATT
  if (blinktime == 50) digitalWrite (13, LOW);   
  if (battery > HIGHvolt && blinktime == 70) digitalWrite (13, HIGH);  // HIGH BATT
  //              SCREEN PRINT ROUTINE
  if ( blinktime == 0)
    Serial.print (AI0);
    Serial.print (" ");
    Serial.print ((float)LOWvolt/ 1000);
    Serial.print ("  ");
    Serial.print ((float)battery/ 1000);
    Serial.print ("V  ");
    Serial.print ((float)HIGHvolt/ 1000);
    Serial.print ("   ");
    Serial.print (inhibit);
    Serial.print (" INH   ");
    Serial.print (lockout);
    Serial.print (" LOCK  ");
    Serial.print (Ipower);
    Serial.print (" INVERTER  ");
    if (enable == 0) Serial.print (" DISABLE   ");
    if (enable == 1) Serial.print (" ENABLE    ");
    Serial.print (minutes);
    Serial.print (":");
    Serial.print (seconds);
    Serial.println(" ");       // start new line
}     // END of the program loop

« Last Edit: December 15, 2016, 08:19:48 AM by OperaHouse »

Mary B

  • Hero Member
  • *****
  • Posts: 812
Re: Automatic Inverter Cycling, Low Voltage Disconnect
« Reply #2 on: December 15, 2016, 04:33:50 PM »
I took the lazy way out it has programmable voltage levels and I use it to switch a DC/DC solid state relay to turn the inverter off to the fridge. The fridge temp controller(I am using a chest freezer as a fridge) has a built in 3 minute delay on power loss. It is also built into a transfer relay that drops the fridge back on grid after 30 seconds.


  • Sr. Member
  • ****
  • Posts: 495
  • Country: au
Re: Automatic Inverter Cycling, Low Voltage Disconnect
« Reply #3 on: December 15, 2016, 04:53:26 PM »

You sure this wasn't what I was saying I wanted here?

I have the EXACT requirement for this in the setup I have been playing with. When the sun is out the UPS I am using is beeping it's head off all day because the panels are sitting the batteries on 28V where I have the controller set. I can't go below 27.5 anyway.  At night I want the thing to change back to AC power when the batteries get low so the fridge is not warming up on these hot summer nights. If the voltage falls too low the UPS trips and won't boot up again in the morning till I come out and manually re set it.

I'd LOVE to be able to build this as it is exactly what I want so I'll see if my nephew can give me a hand with the Physical side of things and can work out the components  I need and the circuit.  Way too far over my head but like most things you put up here, they are exactly what I'd like to do and be very useful.  I'd certainly be building them if I could work out the parts and circuit!

Thanks again for taking the time to work out another useful Circuit.