voltage monitor


Closed Thread
Results 1 to 16 of 16

Thread: voltage monitor

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by w7ami View Post
    The simplest and fastest would be to use a PIC with comparator. You would only need two resistors used as a voltage divider to bring your battery voltage down to something the PIC can handle. You can set the comparator reference voltage in code. You also can program the comparator to trip an interupt when the divided battery voltage drops below the reference voltage. You will need to look at the reference manual for the PIC you have to find out how to set the comparator and turn on the correct interupts.

    Terry
    Sorry to interrupt here, but im trying to build the same circuit to monitor a lipo battery on my RC heli. do you have a schematic for the voltage divider or what this circuit might look like using a 12v lipo batter? i am really lost on this project and cant quite get a handle on it!

    from what i gather, the chip will compare the input voltage from the battery to the internal voltage and detect the difference? am i close?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by samtheboxer View Post
    Sorry to interrupt here, but im trying to build the same circuit to monitor a lipo battery on my RC heli. do you have a schematic for the voltage divider or what this circuit might look like using a 12v lipo batter? i am really lost on this project and cant quite get a handle on it!

    from what i gather, the chip will compare the input voltage from the battery to the internal voltage and detect the difference? am i close?
    This link will explain voltage dividers.
    http://www.omega.com/techref/das/divider.html
    The divided voltage will the go to an ADC pin of the PIC. The voltage will then either be compared to the voltage that the PIC is running on or a reference from another source(voltage divider).
    Dave
    Always wear safety glasses while programming.

  3. #3
    w7ami's Avatar
    w7ami Guest


    Did you find this post helpful? Yes | No

    Cool voltage monitor

    Samtheboxer,

    Dave has already sent you a link that explains what a voltage divider is and how to figure the correct values of resistors to use so I won't repeat his info.

    Whether you use an ADC or comparator you will need to use a voltage divider to divide down the battery voltage into a range that is safe for the PIC.

    I suggested using a comparator and interupt because it doesn't require clock cycles from the PIC unless the battery voltage has dropped below the pre set threshold. I was thinking that he just wanted some sort of failsafe that would shut things down if the battery voltage dropped to low but do other things in the mean time. I am using just such a feature on a project that I am working on now. After re reading the original post I see that what was really wanted was to circuit that just monitored the battery voltage and for that the ADC approach is better.

    Which circuit and code you use depends upon what it is you are wishing to accomplish.

    Terry

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by w7ami View Post
    Samtheboxer,

    Dave has already sent you a link that explains what a voltage divider is and how to figure the correct values of resistors to use so I won't repeat his info.

    Whether you use an ADC or comparator you will need to use a voltage divider to divide down the battery voltage into a range that is safe for the PIC.

    I suggested using a comparator and interupt because it doesn't require clock cycles from the PIC unless the battery voltage has dropped below the pre set threshold. I was thinking that he just wanted some sort of failsafe that would shut things down if the battery voltage dropped to low but do other things in the mean time. I am using just such a feature on a project that I am working on now. After re reading the original post I see that what was really wanted was to circuit that just monitored the battery voltage and for that the ADC approach is better.

    Which circuit and code you use depends upon what it is you are wishing to accomplish.

    Terry
    Terry - I have attached a schematic of my circuit using the voltage divider. I drew it up really quick using paint, so it doesnt look pretty. Also, the battery input should be +12 and -12, not +12 and -11. I also figure out were to put that voltage divider ground, im just running it into the chip ground. (i will post a proper schematic here shortly, i am working on it now.)

    So, i think ive got the circuit down but now i need to work on the program. All i want to do is run a program flashing some LEDS as a strobe light on my helicopter. When the LIPO reaches 9.5v (or so, just not below 9V) i want the chip to change the pattern of the LEDS to warn me that my battery is getting low and its time to land. So far, i understand i need to use the comparator on the 12f629 and compare the battery voltage from the divider to the internal voltage in the chip (supplied by a constant 5v).

    Here is my frustration, I am new to all this and might be in over my head, but im not giving up. I understand how to blink a light and different flash patterns, but thats about as far as ive gotten. No matter how hard i look i cant seem to find a program to dissect or an example of what i want to accomplish and how to accomplish it code wise.

    I hate to ask, but would it be possible for someone to write the picbasic pro code for me, a working program, so that i can run it and figure out how it works? I feel like if i just has a working program, a lot of it would make sense to me........
    Attached Images Attached Images  

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Samtheboxer,
    Have you seen this? http://www.picbasic.co.uk/forum/show...ght=comparator
    Lots of info and good links to even more.
    Dave
    Always wear safety glasses while programming.

  6. #6
    w7ami's Avatar
    w7ami Guest


    Did you find this post helpful? Yes | No

    Default voltage monitor

    Sam,

    Here is some code that have working on a 18F4620. You might have to change things abit to make it work on your PIC.

    Not familiar with the battery packs you are using. Are they really +/- 12V or are they 24 volts? Either way I suspect that your PIC would be very unhappy connected across 10 volts ( +/- 5 V ).

    I hope this gets you started. Good luck.

    Terry

    ; 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

  7. #7
    w7ami's Avatar
    w7ami Guest


    Did you find this post helpful? Yes | No

    Cool voltage monitor

    Sam,

    Here is some code that have working on a 18F4620. You might have to change things abit to make it work on your PIC.

    Not familiar with the battery packs you are using. Are they really +/- 12V or are they 24 volts? Either way I suspect that your PIC would be very unhappy connected across 10 volts ( +/- 5 V ).

    I hope this gets you started. Good luck.

    Terry

    Quote Originally Posted by w7ami View Post
    ; 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

Similar Threads

  1. Voltage monitor and PWM control
    By StoneColdFuzzy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th May 2009, 16:11
  2. Voltage monitor for car battery
    By passion1 in forum mel PIC BASIC Pro
    Replies: 50
    Last Post: - 23rd April 2008, 21:47
  3. Expanded Scale Voltmeter
    By Pic_User in forum Schematics
    Replies: 6
    Last Post: - 8th February 2008, 20:32
  4. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35
  5. Help with DS2436 Voltage monitor
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th October 2006, 16:39

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts