Beginner in need of help !!


Closed Thread
Results 1 to 40 of 72

Hybrid View

  1. #1
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Back again already, Comparators are mind boggling !!

    Firstly I have no idea how to even set the mode of the comparator, let alone working out & setting the VRC. I have been researching all day, the only info that looks helpful is in C so it is all gobbledygook to me as I have only just started learning basic.

    I am not looking for someone to spoon feed me a code, I just want to be able to understand it for myself. What does this mean from the data sheet CM<2:0> = 011? How do you get CMCON0 = 2 from that? If I could understand the data sheet enough to put it into basic then it would help me a lot.

    Just being able to turn on an LED when the voltage goes under 1.00v using a pot would be a massive accomplishment for me at the moment, as I could understand how it all works.

    Any help on this would be great.

    Thanks,
    Rob

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    What does this mean from the data sheet CM<2:0> = 011?
    It means bits 2 , 1, 0 are set 011
    very common nomenclature to use the colon to be inclusive of all the bits in between 2:0
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Rob,

    Yes Comparators can be confusing the 1st time using them on the PIC MCU.

    First, have a read through this link.
    http://www.cuteminds.com/index.php/e...23-comparators

    It explains simply how the comparator
    on the PIC12F683 can be used. Ignore the C language stuff, but pay attention
    to the setup of the Comparator, especially the Second Case.
    This case describes what you will probably implement.

    This will give you the info on how the Comparator will work by polling the
    Comparator output, NOT USING INTERRUPTS.

    Once you have this digested, then you can move on to the Interrupt portion.

    Use the equation for VRR=1 (Low Range): (VR3:VR0/24) x Vdd to set the "Threshold Voltage"

    E.g.
    Vdd = +5Vdc
    VR3:VR0 = 5 (%1001)

    Putting this into the equation above gives this CVref "Threshold voltage"

    (5/24) x 5 = 1.042 Vdc

    This will be the reference voltage that will be used to compare the input voltage to.

    General Rules when using the Comparator:
    1. Set the appropriate pins to analog for the Comparator with ANSEL
    2. Set the direction of the pins appropriately with TRISIO
    3. Configure the Compare Module using CMCON0
    4. Configure the reference voltage using VRCON
    To use the comparator, poll the value of the status bit in CMCON0.

    See if this gets you started.

    Regards,
    Last edited by Tabsoft; - 23rd January 2015 at 19:10. Reason: Forget a general rule
    Regards,
    TABSoft

Similar Threads

  1. Beginner help!
    By Recognize in forum General
    Replies: 14
    Last Post: - 26th April 2012, 14:55
  2. pic24 beginner
    By robertpeach in forum General
    Replies: 23
    Last Post: - 13th August 2009, 11:57
  3. need help! to beginner
    By emilhs in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 6th May 2009, 18:44
  4. Beginner at PB
    By alphahr in forum Off Topic
    Replies: 1
    Last Post: - 21st April 2008, 17:43
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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