Using an AVR to monitor LIPO minimum voltage

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

I am now using LIPO batteries for my LED designs.
I have a 1 amp PTC fuse with a battery monitor (tiny13).

My initial design used the BOD fuse set at 2.7VDC and I powered the Uc with from the balance plug so I could monitor just 1 cell. This eliminates the resistor voltage divider as I am using a 4cell pack for this design. I used a diode in series with the voltage input of the chip so that brown out at 2.7VDC is actually 3.3VDC of the battery.

Testing, I am running at 128khz and the chip is using just .025mA when the power is above 3.3V and the chip actually uses up too 0.300mA at the point where it hit's the BOD.

Going to scrap that idea and use the ADC instead.

Question, does anyone make a complete shutoff LIPO battery monitor? I did design a micro servo and micro switch combination to physicaly disconnect the battery from the load. A momentary switch is pressed, micro powers up and moves servo to allow micro switch to close, monitors voltage and rotates servo to off position if under voltage. Works fine but a bit bulky.

Is there a latching silicon chip micro switch available to do something like this and will allow high amperage 10,20..50 amps for RC motors? I know the ESC's used for the motors have a shut down but they also can drain the LIPO if not disconnected. A full shutoff would be nice, not sure if a cell phone has a full shutoff or not.

This is the 10 watt drum light I am making for a drum group.

http://www.youtube.com/watch?v=K...

Just tested using ADC after turning off the BOD. I use a second pin to power a resistor divider for a microsecond. Now it runs at 0.005mA Lower then the discharge rate of the battery.

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

metron9 wrote:
... does anyone make a complete shutoff LIPO battery monitor?
Yes.
http://www.batteryspace.com/pcmforli-coli-mn-nibatterypacks.aspx
Some cells or batteries come with a protection and/or charging and/or balancing module attached or built-in.

"Dare to be naïve." - Buckminster Fuller

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

It's called a PCB (Protection Circuit Board) or Protection Circuit Module.

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

If the mcu has the capability, power directly from the battery and measure the 1v1 bandgap using Vcc as a reference. That saves a resistor and pin and draws less current compared to a switched divider.

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

dak664 wrote:
If the mcu has the capability, power directly from the battery and measure the 1v1 bandgap using Vcc as a reference. That saves a resistor and pin and draws less current compared to a switched divider.

Oh, I see now, I remember reading about bandgap but it never sunk in, now I am on Adderall everything seems a lot clearer. I will read up on the bandgap. I am guessing it measures the difference from 1.1v to the VCC but I will read up on it.

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

Like any other ADC measurement it returns the ratio to Vref==Vcc scaled to the ADC resolution. e.g. ADC = 1024*Vbg/Vref implies Vcc=1024*Vbg/ADC.

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

dak664 wrote:
Like any other ADC measurement it returns the ratio to Vref==Vcc scaled to the ADC resolution. e.g. ADC = 1024*Vbg/Vref implies Vcc=1024*Vbg/ADC.

A little confused. I am using the Tiny13
data sheet only talks about the ACBG bit in the ACSR for the Comparator.

It also refers to the ADC

ATtiny13 features an internal bandgap reference. This reference is used for Brown-out
Detection, and it can be used as an input to the Analog Comparator or the ADC.

I tried setting the ACBG bit
waited 70 us for power up
set up ADC like this with the understanding that the ADC compares the 1.1 volt Vbg with the VCC so that a voltage of 4.5VCC would return a left shifted value of 62

1.1 / 4.5 = .244

2.44 * 256 = 62

Where did I lose it?

;============================= ADC Converter ===============================

GETADC: 

	cli ;stop global interrupts

;Reference to VCC
;Left adjusted (255 maximum in ADCH)
	ldi	Temp, (0<<REFS0)|(1<<ADLAR)|(0<<MUX1)|(0<<MUX0)
	out ADMUX, Temp

; Select bandgap
	ldi Temp,(1<<ACIE)
	out ACSR,Temp
; Wait 70 uS (128k clock fo 7us per clock)
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop

;Enable ADC
;Clear ADIF
;Enable ADC Interrupt
; Prescale /2
	ldi	Temp, (1<<ADEN)|(0<<ADSC)|(0<<ADATE)|(1<<ADIF)|(1<<ADIE)|(0<<ADPS2)|(0<<ADPS1)|(0<<ADPS0)
	out ADCSRA, Temp

;ADC noise reduction
;Sleep mode for best ADC resolution
	ldi	Temp, (0<<SM1) | (1<<SM0)  | ( 1<<SE)
	out	MCUCR, Temp
; entering sleep will start ADC conversion, completion will wake the MCU to ADC interrupt

	sei ;enable global interrupts
	sleep ;Adc reads and wakes up after conversion
	cli

;Disable ADC and turn off ADC Interrupt enable flag
	ldi temp, (0<<ADEN) | (0<<ADIE)
	out ADCSRA, temp 

;Turn Off bandgap
	ldi Temp,(0<<ACIE)
	out	ACSR,Temp
	ret

ADC_COMPLETE:     ;ADC COnversion Complete
	in 	adclow, ADCH ;Read Result Low byte
	reti

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

Woops, there I go again. Just pulled up the tiny45 data sheet and I see you can select the Vref as the input channel but the tiny13 only has the 4 ADC pins for input.

Although the Tiny13 data sheet does say bandgap can be used with the ADC but I guess we are talking about two distinct bandgaps, still a bit confused though.

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

Tried using the tiny45 with no results.

I am not understanding the input Vref by setting mux3 and mux2 bits is it 1.1 or is it 2.56 it reads 1.1V/2.56V
I am confused.

This is the ADC code, what did I do wrong.


GETADC: 

	cli ;stop global interrupts

;Reference to VCC
;Left adjusted (255 maximum in ADCH)
; Select input 1.1/2.56 with mux3=1 and mux2=1
	ldi	Temp, (0<<REFS2)|(0<<REFS1)|(0<<REFS0)|(1<<ADLAR)|(1<<MUX3)|(1<<MUX2)|(0<<MUX1)|(0<<MUX0)
	out ADMUX, Temp

;Enable ADC
;Clear ADIF
;Enable ADC Interrupt
; Prescale /2
	ldi	Temp, (1<<ADEN)|(0<<ADSC)|(0<<ADATE)|(1<<ADIF)|(1<<ADIE)|(0<<ADPS2)|(0<<ADPS1)|(0<<ADPS0)
	out ADCSRA, Temp

;ADC noise reduction
;Sleep mode for best ADC resolution
	ldi	Temp, (0<<SM1) | (1<<SM0)  | ( 1<<SE)
	out	MCUCR, Temp
; entering sleep will start ADC conversion, completion will wake the MCU to ADC interrupt

	sei ;enable global interrupts
	sleep ;Adc reads and wakes up after conversion
	cli

;Disable ADC and turn off ADC Interrupt enable flag
	ldi temp, (0<<ADEN) | (0<<ADIE)
	out ADCSRA, temp 

	ret

ADC_COMPLETE:     ;ADC COnversion Complete
	in 	adclow, ADCH ;Read Result Low byte
	reti

Diddled with it till i figured it out. Did not use the sleep to invoke the ADC used loop to test ADSC. sleep was working on the tiny13 so i will have to figure out why it did not on the tiny45.