I need help on the compare module


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2012
    Posts
    24

    Default I need help on the compare module

    I read compare module and i understand how it works that is it compare the two voltages on the input terminals.
    comparator has two terminals, positive(Vref) and negative(input voltage on AN1 0r AN0)
    Depending on which input has a higher voltage (analog value),
    a logic zero (0) or logic one (1) (digital values) will appear on its output.

    On my project i dont want to know whether the output is low or high but
    i want to know exactly magnitude of output voltage, to know the magnitude of output voltage after comparison
    I need someone to help me, anyone who is able to provide a sample code to overcome this problem

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: I need help on the compare module

    Hi,
    For that you need to use the Analog to Digital converter available in most PICs (but not all). It CAN be done with the comparators too by generating the VRef voltage with for example PWM and then sweeping the voltage from zero upwards while watching the comparator output. When the comparator output toggles you know the voltage. But the ADC is easier though....

    Which PIC are you using?

  3. #3
    Join Date
    Jan 2012
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: I need help on the compare module

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    For that you need to use the Analog to Digital converter available in most PICs (but not all). It CAN be done with the comparators too by generating the VRef voltage with for example PWM and then sweeping the voltage from zero upwards while watching the comparator output. When the comparator output toggles you know the voltage. But the ADC is easier though....

    Which PIC are you using?
    thanks HenrikOsson for your suggestion i hope it will help me, truely i have no anywhere to get the information on that issue, can you give me the reference book so that i can read to get enough concept on how to use ADC on comparators or can you give me sample code so that to be easy for me to understand.
    I suggest to use PIC16F877, is it possible to work as i want, please Henrikosson help me

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: I need help on the compare module

    Hi,
    I'd suggest that you forget about the comparators for now, they COULD be used for what you want but the ADC will be easier for you.

    To use the Analog to Digital Converter you use the ADCIN command. That command and all the others are decribed in the manual you shouldn've received when you bought PBP. If you have PBP3 then the manual even got installed as a.pdf on your system when you installed the compiler. If you have MicroCodeStudio a lot of information is available in the Help, the datasheet for your PIC is available from Microchips website and I'm sure that if you search the forum you'll find a LOT of info and examples showing how to use the ADC.

    /Henrik.

  5. #5
    Join Date
    Jan 2012
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: I need help on the compare module

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    I'd suggest that you forget about the comparators for now, they COULD be used for what you want but the ADC will be easier for you.

    To use the Analog to Digital Converter you use the ADCIN command. That command and all the others are decribed in the manual you shouldn've received when you bought PBP. If you have PBP3 then the manual even got installed as a.pdf on your system when you installed the compiler. If you have MicroCodeStudio a lot of information is available in the Help, the datasheet for your PIC is available from Microchips website and I'm sure that if you search the forum you'll find a LOT of info and examples showing how to use the ADC.

    /Henrik.
    i have read the ADCIN command but i i do no how to link this command with the comparator, my aim is to design dc dc conveter with constant current by varying output voltage after comparison, So it's better for u HenrikOlsson to help me by giving sample code on that issue

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: I need help on the compare module

    You can not use the ADCIN with the comparators. ADCIN is for the ADC.
    On my project i dont want to know whether the output is low or high but i want to know exactly magnitude of output voltage
    Again, you can not use the comparators for what you want without doing some tricks which I told you about in my first reply. The peripheral to use for measuring the actual voltage is the Analog to Digital converter (ADC) for which the ADCIN command works.

    Why have you are you obsessing on the comparators? What am I missing?

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Smile Re: I need help on the compare module

    Quote Originally Posted by chitalula View Post
    On my project i dont want to know whether the output is low or high but
    i want to know exactly magnitude of output voltage, to know the magnitude of output voltage after comparison
    I need someone to help me, anyone who is able to provide a sample code to overcome this problem
    Comparator OUTPUT voltage is either LOW ( ~ VSS ) or HIGH ( ~ VDD ) ...

    That's all !!!

    as stated before ... if you need the difference between the two INPUTS , the A/D converter has to be used and difference CALCULATED ...

    no problem here ... except your goal is " not so clear " ...

    Alain
    Last edited by Acetronics2; - 2nd March 2012 at 12:09.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Jan 2012
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: I need help on the compare module

    thanx HenrikOlsson and Ailan, am taking a deep studies on that if i will meet with difficulties i will come back to you again

Members who have read this thread : 1

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