To sense the 220V often a small transformer is used. There are optocouplers for 220V, but a transformer is simple.
Do you want to use the Arduino to charge the battery ? That is dangerous, if something is wrong the battery could be overcharged.
The 3 parts are already made, the power supply is using a trasnforfer, so it is isolated.
The way I see it, Power supply provides 12 volt to charge the battery while the block of leds is off
Once the power is off , the Battery provide the power for the LEDS. Through using relays and some simple logic I can control the switching.
Krupski:
You are absolutly right A relay will do the switching, but I thought if I use the Arduino I will be able to monitor the charging of the battery, so I do not over charge.
Will wait for the "AutoSwitcher", in the mean time, I want to monitor the 12V, if off I use a relay to switch the battery to the LED circuit. At the same time I will monitor the battey charge if above a certail voltage I disconnect temprary the 12v supply.
I will use Voltage divider to get less that 5V to a digital pin. If LOW I will activate the realy to connect the bttery to the LED block.
I will use an analog pin to measure the Battery voltage ( I will use a voltage divider for that too)
My concern is using voltage dividers takes power, and I need to conserve it especially when power is OFF.
Let us leave the practical side for a while and consider this as a learning exercise. How can I use this approach to program say Arduino tiny to this simple circuit Manouvering??...
The 3 parts are already made, the power supply is using a trasnforfer, so it is isolated.
The way I see it, Power supply provides 12 volt to charge the battery while the block of leds is off
Once the power is off , the Battery provide the power for the LEDS. Through using relays and some simple logic I can control the switching.
Krupski:
You are absolutly right A relay will do the switching, but I thought if I use the Arduino I will be able to monitor the charging of the battery, so I do not over charge.
I assume you are using lead-acid cells? Regardless, different battery technologies require different charging methods. Look up HOW to properly charge the battery type you are using and design a charger to match.
Fortunately, lead-acid batteries are simple to charge and tolerant of overcharging. You charge lead-acid at 2.35 volts per cell. For a 6 volt battery, that's 7.05 volts.
Just make a 7.05 volt DC power supply and send it to the battery through the relay. Power the relay coil from the unregulated side of the power supply (which will probably be around 12 volts).
When the power goes off, the power supply goes away, the relay switches and disconnects the power supply from the battery (and connects the battery to the LED array).
Remember a quote from a famous man:
[b]"Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto."[/b] --- Mikhail T. Kalashnikov
The modern version is "KISS" (Keep It Simple, Stupid).
(not calling you stupid... that's just what "kiss" stands for!)
I love your post....I am an Engineer and I used to say the most DIFFICULT design is the SIMPLE one.
So, I am happy to join your "club" !! I mean your motto.....
Very informative info on the charging bit...I will design the circuit accordingly. I will also try to avoid the resistive Voltage divider..If I can.
Sorry, having problems with internet connection,
Spent from Friday to this morning trying to download IDE 1.0.5,1.0.6, 1.6.0 NO LUCK.
With a 6v. battery you can only light ONE LED.
With a 12v., you can have 3 LED strings with less current comsumption.
Tested with one string and a 450A vehicle battery.
Adjust Vcap2 to 13.8v.
While AC, Q1 ON and holds Q2 OFF.
As Vbat rises, charging current lowers due to voltage difference across R5, 1 to 2Ohm/ 2w.
When charged, trickling starts avoiding over charge.
If AC loss, Q2 turns ON and LEDs light.
Q2 should handle total LEDs current.
Works for me, might have to tweak for your use.