I have a project based on a pic16f913 to open (unlock) a box of cigarettes after a certain period of time.
parts used:
-LM2936 (LDO Voltage Regulator 5V)
-dumb LCD for countdown
-BD6222 (H-Bridge to control the latching solenoid)
The consumtion on SLEEP of the circuit is somewhere close by 42uA
When i add the ADC to check the battery the consumtion increase to 390uA (with the ADC off.....ADCON0.0=0).
Code:
'CHECK THE BATTERY VOLTAGE
TRISA.0 = 1 'set PORTA.0 to input
ANSEL.0 = 1 'set PORTA.0 to analog
ADCON0.7 = 1 'A/D result have to be right justified for 10 bits (2^10=1024)resolution (ADFM bit)
ADCON0.6 = 0 'set voltage_reference=Vss (VCFG1 bit)
ADCON0.5 = 0 'set voltage_reference=Vdd (VCFG0 bit)
ADCON0.4 = 0 'set analog_channel=AN0=PORTA.0 (CHS bits)
ADCON0.3 = 0
ADCON0.2 = 0
ADCON1.5 = 1 'set A/D conversion clock source to F_rc=dedicated internal osc (ADCS bits)
ADCON1.4 = 1
ADCON0.0 = 1 'enable A/D module
PAUSE 4 'wait 0.5sec (...acquisition time) (32768*500/4000000)
'start_adc_conversion:
FOR readADCloop=8 TO 1 step -1
ADCON0.1=1 'start A/D conversion (GO/DONE bit)
WHILE ADCON0.1=1 'wait for it to complete
WEND
VbatTEMP.HighByte = ADRESH 'read high-byte of result
VbatTEMP.LowByte = ADRESL 'read low-byte of result
Vbat=Vbat+VbatTEMP
PAUSEUS 13 'wait 10msec (10000*32768/4000000)
NEXT readADCloop
SELECT CASE Vbat
CASE IS < 500
END 'battery is too low to drive the solenoid=END THE PROGRAM
CASE IS < 900 'attention: battery low
LCDDATA10.5 = 1 'write to lcd "b" (as in Battery low)
LCDDATA4.5 = 1
LCDDATA7.5 = 1
LCDDATA4.6 = 1
LCDDATA1.5 = 1
END SELECT
ADCON0 = 0 'disable A/D module
It is normal just one ADC to increase the consumtion so much ???
Im sure is something wrong with my setup / code
Please just take a look... Thank You
Bookmarks