RC nicad/nimh battery gauge

Volhout

New Member
In remote controlled airplanes, a 4.8V (4 cel) battery is used to power electronics. To prevent flying an airplane with an empty battery, this battery condition checker is developed. It is based on a PICAXE 08M2, powered from the NIMH battery, measuring the voltage with the A/D converter. The value is compared to set levels in software (4.2V / 4.8V / 5V / 5.2V) and drives 4 LED's. Since the 08M2 is short on IO pins, the LED's are multiplexed. The software cycles fast enough to detect glitches (if servo's draw much current, and the battery is older (higher internal resistance). Especially these glitches can cause a hard reset of the RC receiver, causing loss of control for up to 2 seconds. (2 seconds is lethal for an RC airplane).

schematics.pngprototype.png
 
Last edited:

Volhout

New Member
And here is the code for the battery gauge

Code:
; PICAXE 08M2 als NICAD meter gauge (4.8V / 4 cell).

;		          +---__---+
;	+5	        --|1           |--	GND
;	Sin	        --|             |--	Sout / OUT0
;ADC4 / OUT4    --|             |--	ADC1 / OUT1
;IrIN / IN3	        --|             |--	ADC2 / OUT2
;		          +--------+

; ADC4 = input (22k to +6V, 10k to GND)
; OUT0 = multiplex driver (remaining LED pins)
; OUT1 = K(red), A(orange)
; OUT2 = K(yellow), A(green)
; Vcc via 1N4148 to +6V, 220nF to GND

fvrsetup FVR2048 			; set FVR as 2.048V
adcconfig %011 			  	; set FVR as ADC Vref+, 0V Vref-

main:
	fvrsetup FVR2048 		; set FVR as 2.048V, FOR EACH READING RE-DO
	readadc C.4,b1 		  	; read value into b1
	if b1 < 180 then flsh 	   	; jump to flsh if voltage < 4.6V
	if b1 < 186 then lowbat		; jump to lobat if 4.8V
	if b1 < 193 then minimal	; jump to flsh if 5.0V
	if b1 < 200 then nominal        ; jump to flsh if > 5.2V
	goto maximal

flsh:
	;debug b1
	high C.0 			; flash RED outputs
	low C.1
	high C.2
	pause 200 		      	; wait 200 mseconds
	low C.0 			; switch on output RED
	low C.1
	low C.2
	pause 200  		      	; wait 200 mseconds
	goto main 		       	; loop back to start
lowbat:
	;debug b1
	high C.0 			; switch on output RED
	low C.1
	high C.2
	pause 10 		       	; wait 10 mseconds
	low C.0 			; switch on output RED
	low C.1
	low C.2
	pause 4  		        ; wait 10 mseconds (incudin ADC)
	goto main 		       	; loop back to start
minimal:
	;debug b1
	high C.0 			; switch on output RED+ORANGE
	low C.1
	high C.2
	pause 10  		      	; wait 10 mseconds
	low C.0 			; switch on output RED
	high C.1
	low C.2
	pause 4  		        ; wait 10 mseconds (incudin ADC)
	goto main 		       	; loop back to start
nominal:
	;debug b1
	high C.0 			; switch on output RED+ORANGE+YELLOW
	low C.1
	low C.2
	pause 10  		      	; wait 10 mseconds
	low C.0 			; switch on output RED
	high C.1
	low C.2
	pause 4  		        ; wait 10 mseconds (incudin ADC)
	goto main 		       	; loop back to start
maximal:
	;debug b1
	high C.0 			; switch on output RED
	low C.1
	low C.2
	pause 10  		      	; wait 10 mseconds
	low C.0 			; switch on output RED
	high C.1
	high C.2
	pause 4  		        ; wait 10 mseconds (incudin ADC)
	goto main 		       	; loop back to start
 
Top