Shop OBEX P1 Docs P2 Docs Learn Events
Multiple pot readings — Parallax Forums

Multiple pot readings

hippyhippy Posts: 1,981
edited 2007-10-16 20:03 in Propeller 1
What's the easiest way to read multiple pots using a Propeller without going to external DAC hardware ?

I was thinking of a modified RCTIME circuit like below. A0..AN and Ax set low to discharge C via Rd. Then Ax input and one of A0..AN set high to charge C via Rc.

Any thoughts ? Any simpler ways ?

              VR                     Rc
             __/__                  ____
    A0 >----|_/___|----|>|----.----|____|----.------.
             /                |              |      |
    :                --|>|----{              |    __|__
    :                --|>|----{              |    --.--
             __/__            |              |      |
    AN >----|_/___|----|>|----'              |     _|_ 0V
             /                       Rd      |
                                    ____     |
    Ax <>--------------------------|____|----'


Comments

  • RaymanRayman Posts: 14,162
    edited 2007-10-16 17:41
    I guess if you really wanted to save pins, you could skip Ax and just output high on all A0..AN for a while to charge up the cap, then read as usual...

    I don't know what I was thinking!

    Actually, I think this could work!· You just measure the RC time it takes for the cap voltage to fall from Vdd to Vdd/2 by putting out a 0 on the pin you want to read and putting the others into high-impedance and reading the input there...· And, get rid of RC...

    Post Edited (Rayman) : 10/16/2007 6:26:49 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-16 17:59
    This only works if you have a good knowledge of the value range. It's easy to say "long enough". The conecpt is, that Rd is MUCH smaller than any of the tested loads.

    Simplification: As you can assure that A0 to AN are tristate (or also low) when unloading , you can completely ommit Rd as well as Rc.
  • RaymanRayman Posts: 14,162
    edited 2007-10-16 18:24
    I think you need a resistor in there when charging up C for the case when VR->0...
  • hippyhippy Posts: 1,981
    edited 2007-10-16 18:29
    The -|>|- were to indicate diodes but I guess as A1..AN can be tri-stated then there would be minimal effect even when VR=0 and the diodes could be left out. I'll probably leave Rd in simply as extra protection for the I/O pin.

    I'll wire it up and see how it goes. Thanks for the suggestions.
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-10-16 18:57
    If you can invest in a chip *and* save pins, how about an analog switch like the CD4051?

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-16 19:02
    You are not really interested in the read voltage but in that it drops beyond or rises above a certain level.
    So Nick's suggestion is fine, buit any digital multiplexer with defined input threshold will do as well!

    Edit: e.g. 74HC150 16:1 or 74HC152 8:1
    There seems to be none with Schmitt Trigger inputs...

    Post Edited (deSilva) : 10/16/2007 7:18:24 PM GMT
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-10-16 19:38
    > buit any digital multiplexer with defined input threshold will do as well!

    Ah, well. Not quite.
    Use the 4051 to select the source to pass to the Cs and Rs. Just 4 more pins, one extra IC (the 4051) NOT more Cs and Rs and you get 16 channels. You even save some Rs and all the diodes.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-16 19:46
    Hippy, perhaps you should just rethink, who is loading, and who is unloading and who is listening, before this becomes too complicated...
    Nick is right in his criticism, that when you want to load the cap through one of the Prop lines A0 to AN you will need an encoder with tri state output rather than a multiplexer.

    I was somehow thinking to READ the voltage at A0 to AN which of course is nonsense!

    Edit:
    Hmm... seems such a chip does not exist smile.gif Closest is a I2C port expander

    Post Edited (deSilva) : 10/16/2007 7:53:20 PM GMT
  • hippyhippy Posts: 1,981
    edited 2007-10-16 19:51
    The original idea was to use a shift register (SIPO) and just clock a high along , hence the diodes to block discharge t0 outputs at 0V. That would give unlimited pots for the cost of two pins, Clock and Data In. Some clever trickery with an RC and it should be possible to shift in a 0 or 1 and have just one clock line, one sense line. Every other line of the SIPO not connected to a pot so Ax can be used to force the discharge.

    Having enough I/O lines I'm happy to use them in parallel.

    Post Edited (hippy) : 10/16/2007 7:56:53 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-16 19:54
    So it would be best - and much like to my puristic conceptions - to use nothing but one cap in addiotion to the test loads. There is no real need for any additional "safty resistors" when you keep to the protocol...
  • hippyhippy Posts: 1,981
    edited 2007-10-16 20:03
    I've never been happy charging a cap from 0V straight from an output pin ( ie VR=0 ) nor discharging a cap by dumping it straight to 0V when turning an input to output low. I'm no electronics engineer so I tend to play safe, and on safety, "when the protocol is followed", I've already accidentally downloaded incorrect code by having the wrong tab selected when hitting F10 in the Propeller Tool and I'd hate to cause an accidental catastrophe that way. If it can go wrong I always expect it will.
Sign In or Register to comment.