LIPO alarm

Status
Not open for further replies.

samtheboxer

New Member
okay, so im back to my lipo alarm project. i still dont get it and its been a while since i tried to get it!! I have this code that someone gave me, but i need to make it work for the 12F629. it needs to change flash patterns when the voltage of the lipo drops below 9.8 volts. can someone please help me understand this and what i need to do to make it work for me???? thanks

; PIC18F4620
define OSC 40 ; 40 MHz Oscillator"
TRISA = %00000011 ; portA.0 and A.1 are inputs
TRISD = %00000000 ; Port D all outputs


ADCON1 = %0001101

; Comparator Control
CMCON = %00000110
;CMCON.7 = 0 ; C2OUT Comparator Output 2 (Read Only)
;CMCON.6 = 0 ; C1OUT Comparator Output 1 (Read Only)
;CMCON.5 = 0 ; C2INV Comparator 2 Output Inversion
;CMCON.4 = 0 ; C1INV Comparator 1 Output Inversion
;CMCON.3 = 0 ; Comparator Input Switch
;CMCON.2 = 1 ; )
;CMCON.1 = 1 ; )Mode 110
;CMCON.0 = 0 ; )
; ;
; Comparator Voltage Reference Control
CVRCON = %10101010
;CVRCON.7 = 1 ; CVREN Voltage Reference Enable (1 = on, 0 = OFF)
;CVRCON.6 = 0 ; CVROE VREF Output Enable
;CVRCON.5 = 1 ; CVRR Comparator Range Selection bit
;CVRCON.4 = 0 ; CVRSS Comparator Reference Source
;CVRCON.3 = 1 ; )
;CVRCON.2 = 0 ; ) Set for Reference Voltage
;CVRCON.1 = 1 ; ) 1010 sets 2.083v in Low Range
;CVRCON.0 = 0 ; ) 9.2 Volts from Battery

; Start Main Program Loop
loop:
if CMCON.6 = 1 then
CVRCON = %10101101 ; 2.083V
PortD.7 = 1
else
CVRCON = %10101010 ; 2.708V
PortD.7 = 0
endif

Goto loop ; Do it forever
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…