Using ADCIN or POT/RCTIME?


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2006
    Posts
    92

    Default Using ADCIN or POT/RCTIME?

    Hi,

    I just started using the pics and pbp 2.46. I programmed a pic12f683 using adcin to read the value of a couple of pots. I noticed that there is a time lag from the moment when I turn the pot and the response of the pic, which in this case is oscillating the pic with the SOUND command.

    I'll turn the pot to adjust the frequency of the note, a new note will sound but only after a time lag. Is this just the nature of using adcin? I thought it was supposed to be very fast and accurate when compared to using the POT or RCTIME commands. Would these other commands be better for reading the value of a pot?

    Also, I was wondering if you could use adcin with a different circuit other than a voltage divider circuit.

    Thanks in adavance.
    Tony

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Tony,

    ADCIN & the PIC's internal ADC are actually pretty fast, but the sound
    command, depending on the note/duration time, can be relatively slow.

    RCTIME just measures the time a pin stays in a particular state. POT would
    work, but it's really a pain to calibrate.

    The time lag you're seeing is most likely due to the time it takes to generate
    sound.

    You can adjust the sample time for A/D readings by using the PBP
    DEFINE ADC_SAMPLEUS option as long as it stays within the parameters
    shown in the PIC data sheet for A/D acquisition time.

    The default is 50uS unless otherwise specified with DEFINE ADC_SAMPLEUS.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    I see, so it's the SOUND command that's taking the time.

    What about using the ADCIN with a pot using a different circuit than the voltage divider that's shown in the books. Is it possible to use other circuits with a pot and ADCIN?

    Thanks again,
    Tony

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    PIC A/D inputs can be connected directly to the analog source. You don't
    need any voltage dividers unless the analog input is greater than Vcc.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    So I can just connect one part of the pot to the pic pin and the other to ground?

    Or if using a photocell, one lead to pin the other to ground?

    I was laboring under the notion that there had to be that voltage divider that I've seen in some books where one pot pin goes to +5, the other to ground and the middle pin to the pic ADCIN pin.

    Tony

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you have an analog signal from some external device, say, a temperature
    sensor or something else, that outputs an analog voltage, then you can
    connect this analog source directly to the PIC A/D input.

    If you're using a potentiometer to simulate the external analog signal, then of
    course you'll want one end to Vcc, the other to ground, and the wiper to the
    PIC A/D input.

    Without one leg of the potentiometer to Vcc you wouldn't have anything but
    ground on the PIC A/D input.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    AND be sure you POT or ELSE analog source meet the maximum A/D input impedance.

    If you plan to use a PhotoResistor, you will need to pass the PhotoCell trhough an OPAmp or else method.

    look the PIC datasheet (once again) to know the maximum PIC A/D impedance
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default Rctime

    Ok, thanks for the info.

    So RCTIME is just measuring the time for a cap to discharge, but the voltage source is coming from the pic pin itself, when it goes from low to high. In this case you would just hook the pot up like what's described for using the POT command? (None of the pots pins to Vcc)

    Thanks again,
    Tony

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    RCTIME and POT command are just 'usefull' when your PIC don't have any AD converter. While it's just a pain and real waste of time to do some intelligent calibration, forget them. Choose a PIC with internal AD or use an external one. If you use an external one you'll discover really fast that it just don't worth the investement while a PIC with internal AD are not really much expensive than others without.

    Your POT is connect between VCC and GND, the wiper can go directly or through a low value resistor to your PIC AD input.

    If your software don't provide any noise cancelation, i suggest to add a ~0.1uF between PIC input and GND to filter the signal a little bit.

    If you use the above method, your POT impedance must meet the maximum PIC AD impedance too. Look into your PIC datasheet under the AD section, you'll fiond it there.

    BUT if you don't have any POT that meet it, you can even place a buffer between your POT and the PIC. almost any decent op-amp will do the job.

    ADCIN is easy to use and work really fine even if you can do it simply by writing/reading directly to the internal registers. That will also provide tighter code.
    Last edited by mister_e; - 16th April 2006 at 09:37.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    I see. So the POT and RCTIME are useful if your pic doesn't have an a/d convertor.

    Thanks for the info on the circuit, using a resistor before the pin and the cap for filtering. I appreciate it.

    I'm looking in one of the books for A/D conversion. They show a 50K pot, the wiper going directly into the pic pin, but there is a 15K "pull-up" resistor connected from the +5V to the pot. Is this recommended?
    Last edited by TonyA; - 16th April 2006 at 15:54.

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Could be a soultion but i feel the POT will lost his linearity response. well i think

    Let's do some math

    1/5 pot maximum position:

    in theory, we should have 1/5 Vcc on the wiper = 1 Volt
    voltage divider resistor are 10 and 40K
    Voltage divider ratio is 10/50K

    Using the 15K pull up....
    (10//15)/40K
    voltage divider ration is 6/46
    Voltage on the wiper = 6/46 * 5 = 0.65 Volts


    1/2 pot maximum position:

    in theory, we should have 1/2 Vcc on the wiper = 2.5 Volt
    voltage divider resistor are 25 AND 25k
    Voltage divider ratio is 25/50K

    Using the 15K pull up....
    (25//15)/25K
    voltage divider ration is 9.3/34.3
    Voltage on the wiper = 9.3/34.3 * 5 = 1.36 volt

    and so on. Unless your application can deal with that kind of un-linear curve, yes you can use it. I'm not a fan of it
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thanks for that. I see what you're saying. Thanks again

    Tony

Similar Threads

  1. ADCIN and PIC18F4331 Arghhhhh !
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th December 2010, 20:27
  2. How to make adcin stable?
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th January 2009, 07:41
  3. ADCIN problems with PIC16F73
    By passion1 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 26th July 2007, 11:38
  4. Adcin or Pot
    By lerameur in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 11th January 2007, 16:46
  5. help using adcin
    By harryweb in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st January 2006, 07:46

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