How to sense mains power failure on a battery backed up M32

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guyzz

I have a M32 board that will get power from a 12v Accu connected to a charger , but i would like to signal when main power is down.

I have been looking at the Atmel App note for Zero crossing , and was wondering if that would be an easy way of detecting the 220v Mains.

I was thinking about running the 12v AC from the charger transformer through 2 resistors 47K , just as Atmel uses 2 resistors of 1M (220v).

Then i would detect on external int if there is 50hz , but id there a smarter way (i mean as cheap as 2 resistors , or just about as cheap).

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Presuming that the charger is connected all the time on trickle - connect the charger via a diode to the accu. Then 2 high value resistors (with another diode to stop overvoltage on the input) can switch a port - One connects to the charger side of the diode and the port and the other from the port to ground. The other diode goes from the port to Vcc. That diode should have a Vf < 0.5v .
You'd have to check that the 1st diode doesn't interfere with the way the charger operates e.g. if it determines charge state by the voltage it sees on the accu.

Ralph Hilton

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds a bit tricky for an electronics noob like me :oops:

Maybe i should stik to the 50hz interrupt , i could use it for a RTC :D :D

But thanx for the suggestion

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using the zero crossing detector to feed an external interrupt will generate interrupts as long as the AC power is there but it won't tell you when it stops unless you also implement some sort of timeout timer. Another approach would be to use the zero crossing detector to drive a NE555 in a missing pulse detector configuration - one of the more common uses for this timer chip. Here, the zero crossing detector would be used to continuously reset the 555. If the input stops the timer completes the timing cycle and the output changes. This way you would never get an interrupt until the AC was missing. Check any application note for the NE555 and you will see sample circuits that do this.

Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suggest you to use TL7705.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanx guyzz

I allready have a 10ms timer for scheduling , and i will prob. just detect if i am counting the 50hz pulses up , in the 10ms irq handler

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well i'll check the 50 hz counter once a second i guess.
I have a one second "tick" flag that is handled in the main()

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes you can use zero cross detector to sense a mains fail. You have variable as counter, on every zero crossing clear the variable. You use the timer to increment the variable every 5-10ms.
condition 1 : when mains fail, no zero crossing interrupt so the variable counter keeps on increment when it reaches a value say 100 you sense the power fail.

condition 2 : when mains is present your variable counter is clear every 5-10ms

that is it !

Fascinating Mega AVR series

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@kumax

Yepp :D

Thats it :lol: :lol:

Thanx

/Bingo