Shop OBEX P1 Docs P2 Docs Learn Events
Reading Pot. values. any suggestions — Parallax Forums

Reading Pot. values. any suggestions

DgswanerDgswaner Posts: 795
edited 2008-01-26 10:29 in Propeller 1
I'm familiar with reading an input for a pin, but what I want to do is read the resistance value from a Pot. the value doesn't need to the actual resistance but just some linear value range.

I want to be able to adjust the speed of my bot, and the distance threshold for the PING sensor, i.e. how close it will get to an object before it turns. I want to be able to do this with out having to reprogram the propeller. so if distance < Pot. value + threshold turn. this will allow me to compensate for different locations and conditions.

could someone recommend a method or circuit for doing this. I'm just learning about A/D converts, but I have no idea how to choose which one to use or if it's even the best solution.

Thanks in advance.

p.s. this of course will be done on a propeller chip.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

DGSwaner

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2008-01-25 00:35
    Have a look here http://forums.parallax.com/showthread.php?p=617192 All you need and even more...
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-01-25 01:00
    The easiest method is to create an RC circuit where your potentiometer is the resistor and is connected to ground on the other terminal. You charge the capacitor by setting the pin to output and high, switch the pin to input and measure how long it takes to go low, this number is correlated to the resistance of the potentiometer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • DgswanerDgswaner Posts: 795
    edited 2008-01-25 04:43
    Thanks Paul, I'll do some experimenting with that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-01-25 06:00
    If your potentiometer goes to zero ohms, you should include another resistor in series so that R > 0. Otherwise low time values will occur and make it more difficult to measure than it needs to be, a value around half the potentiometer's max value should be good.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • RaymanRayman Posts: 14,162
    edited 2008-01-26 00:04
    On a slight tangent: I think the absolute best way is to generate a 1kHz sine wave using 1 pin, a resistor and cap, and then measure the voltage at the connected pot using counter ADC with 2 pins, 2 resistors and 2 caps. Then, you have a basic RLC meter...

    I'm toying with the idea of implementing this...
  • Mike CookMike Cook Posts: 829
    edited 2008-01-26 00:59
    Dgswaner,

    If your trying to read a POT value then this article may be of use:

    http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol7/col/NV134.pdf

    Code for the article can be found here:

    http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol7/code/NV134.zip

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • Alex MackinnonAlex Mackinnon Posts: 25
    edited 2008-01-26 08:26
    Hi,

    You could think out of the box and use a quadrature encoder (such as the Bourne EC1J series)... this looks and feels like a pot and there are plenty of samples of the code required to use it in this forum - only two·pins and 2 pullups required [noparse]:)[/noparse].

    A.
    243 x 200 - 6K
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-26 10:29
    Invremental encoders are a good idea and very underestimated. I think the reason is, that encoders had been quite expensive in the past, being used for very exact readings and work under tough conditions as on a motor axis..

    But for some years now inexpensive devices are available (around 2 Euro). I like their robustness and long term stability. That they have no stop position can be considered a good thing or a bad thing. In fact they are as "incremental" as the mouse ist.

    But reading a pot with one Propeller line is the basic experiment you have to do anyhow, well described in many Parallax documentations (see my links or Mike Cook's links). Charging a cap and reading its voltage threashold ist also a good pre-requisite to understand delta-sigma modulation...
Sign In or Register to comment.