Hi there
I have arduino uno controlling the on/off of a battery charger (UPS) what arduino does is sensing the battery voltage and when batteries are low it closes the relay and the the charger start to charge the batteries when batteries are at 29V it opens the relay and the charger power off...
This is the main function but for adding some information arduino has the following connections:
pin 8 - Relay in
Pin A3 - Acs714 (reading amps charged /discharged) <- reading it at DC side of the charger...
pin A5/a4 a RTC ds1307
All the above are connected to 5v arduino and gnd
Pin a0 - voltage divider to read batt voltages
i'm using this relay board
It have all the diode protections to the pin8 you can see it here
A few days i changed the charger/ups for a new model, but arduino don't have any connection to the charger beside the on/off of the relay that connect the charger to the mains plug...
But the arduino start to behave strange some times it hang other time it only come back after poweron/off..
And i start to see that this behaviour was when i closed the charger circuit (charger connected to the mains)...
now last day it died and never wakeup...
My afraid is that being the batt charger a inductive load some kind of current peak on the relay....
But i have a 10amp 250vac relay and my charger is at maximum 4 amp....
How can i protect arduino even more , put a diode on the 5v power that give power to the relay board???
only a coincidence and arduino died ??
Please comments and suggestions so i wont fry my last arduino......
pin 8 - Relay in
Pin14 - Acs714 (reading amps charged /discharged) <<<-----how it wired, pin14?
pin A5/a4 a RTC ds1307
All the above are connected to 5v arduino and gnd
Pin a0 - voltage divider to read batt voltages <<<-----have you ever measure by DMM?
pin 8 - Relay in
Pin14 - Acs714 (reading amps charged /discharged) <<<-----how it wired, pin14?
pin A5/a4 a RTC ds1307
All the above are connected to 5v arduino and gnd
Pin a0 - voltage divider to read batt voltages <<<-----have you ever measure by DMM?
Current sensor looks nice to me, slightly overrated, but not much.
The only entry point that disturb me, is your voltage divider at A0, what are resistors?
Next, where arduino getting power from?
And could you post a link for a new charger, where a can get a specification?
Difficult to say, but if there is a list of potential causes, I'd put analog input from voltage divider on top of the list. There are many possibilities, when it could be dangerous:
lost contact with ground;
"turn over" divider by mistake;
negative voltage coming when error with battery polarity;
etc.
To prevent problem with another arduino, some protection circuitry has to be implemented, resistors + schottky diodes or resistor + zener for input. Best of all would be complete galvanic insulation voltage reading by OPA + optocoupler: http://ruggedcircuits.com/html/circuit__24.html
There is one more things I still couldn't get:
if arduino getting power from computer, which consequently getting power from UPS, so where power coming when battery charged and UPS is off?
Are the moments when arduino is powered off but still connected to voltage divider?
If so, there is a problem, incoming current = 30 V / 10 kOhm = 3 mA.
Hi ..
Ups is never off...
Ups is ruining as inverter for my solar panels... so i need it work in reverse of what a normal ups does, normal ups behaviour:
1- company power exist ?
yes-- charge batteries and bypass all other power to load...
no-- - run from batteries
I' doing the in reverse, by default i'm running on batteries and if the batt voltage drops to 40% (~23v on my 24v system) then connect ups to company power ...
Beside this when the morning comes and sun start to shine ... i start to charge the batteries with solar panels and the power is cutted from ups...
and who is doing all this ?? my friend arduino
It was working fine withe an apc 1000Va ups i changed to this new 1500 and problems started...
Now i replaced the arduino board and the problems of lost conection arduino crashes when cutting power (relay nc) where the same....
afterrrrrrrrrrrrrrrrr hours of troubleshoot on the solution what solved was replacing the usb cable........(amazing).........
now even if the usb cable was the problem why did the other arduino died ? why ??
IMHO, could be SCR latch-up of microcontroler, but as they say, only autopsy can answer the question. Meantime, I'd be cautious of situation when external signals present at the input/output of the arduino during power up/down transition process. It would make sense to disconnect voltage divider from input by relay, if arduino loosing a power for some reason.
i would always use optocoupler for your setup with mains ac then it completely separated from your ardunio, i just purchased 50 i could post you some if you want
My guess is that it's an earthing problem. If you are powering the Arduino from USB then Arduino ground is connected to mains ground via the PC. Unless the battery in the UPS is floating, one side of it is also likely to be grounded. Assuming you have Arduino ground connected to the same side of the battery, this gives you an earth loop and you are likely to get big transients flowing around it.
The solution is not to connect the Arduino to the PC and the battery at the same time. You can power the Arduino from a battery, or indirectly from the battery whose charge you are monitoring.
The other thing to make sure of is that the Arduino pins that sense the battery voltage and current are protected by series resistance. This will prevent them from damage and SCR latch-up. For the voltage sense pin, just use large enough value resistors, e.g. 10K to ground and ~90k to battery. For the current sense pin, use a series resistor of 10K or more. You could use higher values to be safer (e.g. 10x higher), but then you need to take account of the issues when you switch between reading different analog inputs that are fed from high resistance sources.
dc42:
My guess is that it's an earthing problem. If you are powering the Arduino from USB then Arduino ground is connected to mains ground via the PC. Unless the battery in the UPS is floating, one side of it is also likely to be grounded. Assuming you have Arduino ground connected to the same side of the battery, this gives you an earth loop and you are likely to get big transients flowing around it.
Yes arduino is connected to batteries ground and to the usb port of the pc that is receiving the ac power from the ups so i have gnd from the batts and gnd from the ac part of the ups..
dc42:
The solution is not to connect the Arduino to the PC and the battery at the same time. You can power the Arduino from a battery, or indirectly from the battery whose charge you are monitoring.
I can (and will) power arduino from the batteries just waiting for my lm2596 to arrive to sted down the 24v to 9v so i can power arduino from it...
But i will need to keep the usb cable connected because i'm controlling and receiving information from arduino on the pc side...
dc42:
The other thing to make sure of is that the Arduino pins that sense the battery voltage and current are protected by series resistance. This will prevent them from damage and SCR latch-up. For the voltage sense pin, just use large enough value resistors, e.g. 10K to ground and ~90k to battery. For the current sense pin, use a series resistor of 10K or more. You could use higher values to be safer (e.g. 10x higher), but then you need to take account of the issues when you switch between reading different analog inputs that are fed from high resistance sources.
the voltage sensor is done by a 10k&1k voltage divider, can you explain me how do i connect that resistor protection ?
fca:
the voltage sensor is done by a 10k&1k voltage divider, can you explain me how do i connect that resistor protection ?
Just increase the resistors to 100K and 10K, or to 100K and 1M, so as to increase the effective series resistance. You could also connect a 100nF capacitor between the Arduino pin and Arduino ground to reduce noise and help suppress any transients.
ok, i'm still after this, because i'm starting to have the same problem ...
when i disconect /connect the ups to the mains by closeing or opening th relay sometimes the arduino stop responding...
now i see that its not the arduino that crashes/reset as all only the "serial part" i mean the arduino keep runing and doing what it should be..
Only the seria/usb part get broken the tx led stays on and i lost comunication the pcside to arduino...
i can only have connection back after taking the usb cable out and in again .... (strange)...
another strange issue, when i measure voltage divider when the bat is at ~26v gives 2,364v, and this happens when arduino have power...
When i disconnect arduino from power i read on the voltage divider output something like 1.3v....
why ? something to do with analog pin ??
fca:
when i disconect /connect the ups to the mains by closeing or opening th relay sometimes the arduino stop responding...
now i see that its not the arduino that crashes/reset as all only the "serial part" i mean the arduino keep runing and doing what it should be..
Only the seria/usb part get broken the tx led stays on and i lost comunication the pcside to arduino...
i can only have connection back after taking the usb cable out and in again .... (strange)...
Looks like either the USB port on the Arduino or the USB port on the PC is locking up because of a transient.
fca:
another strange issue, when i measure voltage divider when the bat is at ~26v gives 2,364v, and this happens when arduino have power...
When i disconnect arduino from power i read on the voltage divider output something like 1.3v....
why ? something to do with analog pin ??
There is a protection diode in the mcu between the analog pin and Vcc. This diode will clamp the analog input at about Vcc + 0.65. You'll probably find that Vcc measures about 0.65v in this condition (power removed). The current flowing into the analog pin won't do any harm as long as this current is small - another reason for using higher value resistors in your voltage divider.
Sounds like a snubber network is needed across the relay contacts - large inductive spikes could be causing the problem at switching times. Perhaps you run low-voltage wiring alongside the mains wiring?
No the mains is on 2 iec13 sockets and the live is passing by the relay.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Small correction the ac cable from the ups to the pc run on the same pipe as the usb cable (4m) long from the ups to the pc.
but both cables usb and power have their own pvc isolation and the usb cable is shielded..
can this be a problem ?
i will try with another computer (laptop) near the ups.
Regards