Shop OBEX P1 Docs P2 Docs Learn Events
Reading POT controls (Analog to Digital) — Parallax Forums

Reading POT controls (Analog to Digital)

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2008-10-19 01:30 in Propeller 1
In reviewing the PEkit labs, I stumbled across something I missed...

There is a very nice demonstration of reading data from POT controls, TestRCdecay
that I thought would be nice for adaption to simple game controls since every PPDB has two of these.

I'm sure this is another obvious to everyone else, but here's an adaption of that code
that would lend itself to 20 position game control using it as a controller.

This adaptation trades uses a simple Propeller-->POT-->GND so it's returning single
decimal digits, perfect for this use and stupid simple to wire up.

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS

Comments

  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2008-10-16 05:35
    so are you saying that it would oly have 20 positions for readings?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-10-16 08:02
    Hello OBC,

    I'm not sure if I understand your shematic in the spinfile correctly

    do you mean it is enough to connect the pot like shown to a IO-Pin of the Prop ?

    As there is no capacitor at all where is the element that needs time to "load up" until a threshold-point is reached ?
    (delta-sigma principle of AD-conversion)

    Is the capacitance of the IO-Pin enough ?

    Shouldn't there be a capacitor ? In the name TestRCDelay I think the "C" stands for capacitor

    In the PE-Kit-manual it is shown as in the picture attached

    best regards

    Stefan
    1172 x 358 - 78K
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-10-16 14:00
    Yes, I have it connected exactly as it is listed in the spinfile.
    I did start with the configuration as listed in the original instruction,
    but the "what would happen if i?" in me (see my avatar) discovered
    that it becomes a nice twenty position selector without the cap.

    (I get less smoke with this attitude than you might think. <smirk>)

    Thoughts as to why this works?

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2008-10-16 14:10
    Magic maybe??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • BTXBTX Posts: 674
    edited 2008-10-16 15:11
    Hi OBC.
    A good idea would be to add a series resistor to the propeller "pot" pin.
    If not...maybe you'll get more smoke that you think, or you'll get a fried propeller pin instead. <grin>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2008-10-16 15:31
    Oldbitcollector,

    I can't reproduce your results.· Can you provide a picture of your board and setup?·

    I suspect that in addition to the normal I/O capacitance, you may also be contributing SBB capacitance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-10-16 15:43
    I don't have my camera handy, (it's at the shop) but here's the setup.

    Using the PPDB, I have a 3" wire from P17 to center of POT1.
    Another 3" wire from the right (or left) of POT1 to GND.

    That's it. Both of them work the same way here, and I can
    even stack the POTs together (series) to have dual control
    of the digit returned.

    How interesting that this works here, but not elsewhere?
    No smoke, but I can't imagine why this would stress
    the pin more than pulling it low to ground without the
    resistance.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2008-10-16 16:50
    Oldbitcollector,

    "How interesting that this works here, but not elsewhere?
    No smoke, but I can't imagine why this would stress
    the pin more than pulling it low to ground without the
    resistance."

    If your pot is in an extreme position, and the I/O pin is HIGH, then you could potentially sink more current than the I/O can handle.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • KeithEKeithE Posts: 957
    edited 2008-10-17 04:48
    Beau said...
    If your pot is in an extreme position, and the I/O pin is HIGH, then you could potentially sink more current than the I/O can handle.

    When I was reading through the PE-Kit-Counters lab I thought the same thing when I saw this explanation:

    "Where is the current-limiting series resistor?

    The Propeller chip’s I/O pin driver circuits do not need to be protected from the sudden initial current spike that
    results when the I/O pin is taken from either output-low or input to output-high. The I/O pins’ output capacity
    and current-limiting characteristics prevent any damage from occurring.

    If you try to use this circuit with a different microcontroller, you will probably need to include a current-
    limiting resistor between the I/O pin and the RC circuit. Make sure that it is large enough to prevent the I/O pin
    from getting damaged. The decay time won’t be linear because the voltage divider created by the second
    resistor causes the RC decay measurement’s starting voltage to vary. Choosing an R in the RC circuit that is
    very large compared to the series resistor will help the decay time more closely resemble a linear behavior. "

    It doesn't really discuss the case that an output could be driving "1" right into the ground plane. It could even
    be for an extended period of time depending on what software is being run, and any bugs/crashes that may
    occur. You might want to discuss this internally, and update the labs if appropriate.

    Post Edited (KeithE) : 10/17/2008 5:01:58 AM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-10-17 14:36
    A contradiction here... [noparse]:)[/noparse]

    What I don't understand is why a resistor would be used between
    the I/O and the POT when the POT itself is simply a variable resistor?
    If pulling a high I/O low is an issue, then it would only be a problem
    at the lowest side of the POT where there is least resistance?

    I'm willing to do some extended testing on this with my PPDB and
    see what happens. (After all it is a socketed chip)

    Was this reduplicated successfully by anyone else?

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • rjo_rjo_ Posts: 1,825
    edited 2008-10-17 14:40
    your fingers might have more capacitance than mine... then what?
  • BTXBTX Posts: 674
    edited 2008-10-17 15:34
    OBC
    OBC said...
    What I don't understand is why a resistor would be used between
    the I/O and the POT when the POT itself is simply a variable resistor?
    If pulling a high I/O low is an issue, then it would only be a problem
    at the lowest side of the POT where there is least resistance?
    Beau answered you doubt before.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-10-19 01:30
    It's very simple. Insert a 150 ohm resistor in series with your potentiometer. Then your minimum value on the pot will never load your pin more than spec (< 40 mA) 150 ohms is insignificant relative to the 10K value of the potentiometer, so your readings won't be out of whack as a result.

    If you're worried about too much current when charging / discharging the cap, just use a smaller cap. The Propeller is a tough little beast.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
Sign In or Register to comment.