profmason.com

December 8, 2008

Battery Monitor

Filed under: Daily — profmason @ 9:30 pm

I had the unfortunate experience of having a robot drain an SLA down to the point of no return.  I need something that will monitor the voltage of a battery and give the following reports:

  • If the voltage drops below a certain threshold, sound an alarm.
  • If the voltage drops below a certain threshold and STAYS there for a length of time, shut off power to the whole system.  (It is important to reject transient drops due to startup of motors etc)

Using a picaxe 08M, a buzzer and a relay, all of the objectives were accomplished.  Right now everything is on a breadboard, but I will transfer it to a pcb soon enough.  I am still debating if a relay or a high power fet is a better solution.

Here is a quick video of the system in action.  I have the battery just barely above 12volts. Once I load the motor, it pulls more current which drops the voltage of the battery below the first minimum sounding the alarm.  Once I stall the motor, the current goes way up and the voltage sags below the second minimum and shuts the system down.

Battery Monitor

UPDATE:

I replaced the Relay with a IRL540 Mosfet.  This actaully has a lower impedance then the relay!  (Suprised the heck out of me!)  It also makes the circuit cheaper and easier to build.  I have run a 2 Amp load through the mosfet with no noticeable heating.  If I were to go a bit cheaper, I could use a transistor to switch the 12V supply to a standard mosfet.  However, the IRL540s are only 0.60 cents each (cheaper then a relay too!)

Here is the Picaxe code for the battery monitor.  You may need to adjust the ADC values for your case.

'Program to read the voltage of a battery and switch the battery off if it drops below a certain value and sound and alarm.
'Set the mosfet on
high 1
'initialize b4 to store the last value of the voltage read
b4 = 0
main:
	'Initialize w1 to store the total ADC value
	w1 = 0
	'Read the ADC 10 times and then average
	for b1 = 1 to 10
		readadc 4,b0
		w1 = w1 + b0
	next b1
	w1 = w1 /10
	'Output the adc value
	sertxd (#w1,13,10)
	'If the ADC value is less then 12V sound the warning
	if b0 > 182 then jump1
		for b1 = 95 to 120
			sound 2,(b1,1)
		next b1
	'If this is the second time the warning has sounded sequentially and the voltage is less then 11.5V then shutdown
		if b4 > 0 and b0< 175 then shutdown
		'if not the second time then set b4
		b4  = 2
		pause 100
	jump1:
	pause 10
	'Decrement b4 to 0.  The idea is that large loads getting switched into the circuit will cause a momentary voltage drop.  We don't want to shutdown on these momentary drops.  The drop has to last at least 100ms in order to trigger the shutdown condition.
	if b4 < 1 then main
	b4 = b4 -1
goto main
'Turn off the mosfet and play a new alarm tone.
shutdown:
	sound 2,(120,20)
	low 1
goto shutdown

Here is a picture of the final version on a perf board.  By connecting the ground wire of a load to the two terminals, that load is switched on by the mosfet as long as the voltage of the battery monitored between the aligator clips is greater then 12 volts.

I still need to figure out how to have the pic turn itself off.

Update 2:

I have an idea on how to have the pic turn itself off. Basically use an SCR to latch the pic on.  Since the SCR has a minimum latch current of 5mA, the picaxe running will keep the SCR latched on.  When I want to turn the picaxe off, set it to sleep mode (low power) where the current will drop to below 5mA and the SCR will shut off.

Here is a link to a description of how to do this.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress