Shop OBEX P1 Docs P2 Docs Learn Events
Propeller input pullups ? — Parallax Forums

Propeller input pullups ?

Don PomplunDon Pomplun Posts: 116
edited 2013-01-18 10:43 in Propeller 1
I just got a couple QuickStart boards. These have 8 pseudo-buttons which you ground through your conductive finger, each through a 100K resistor. I didn't think the Prop chip had any input-pullup option (like many PICs do). Parallax referred me to the Touch Button demo program. This uses a separate object running in its own cog. Reproduced herein:
<code>
CON

BUTTON_PINS = $FF ' The QuickStart's touch buttons are on the eight LSBs
SAMPLES = 32 ' Require 32 high redings to return true


VAR

long Results


PUB Start(Rate)

Results := Rate
cognew(@Entry, @Results) ' Launch a new cog to read samples


PUB State | Accumulator

Accumulator := Results ' Sample multiple times and return true
repeat constant(SAMPLES - 1) ' if every sample was highw
Accumulator &= Results
return Accumulator


DAT

org
Entry
rdlong WaitTime, par
mov outa, #BUTTON_PINS ' set TestPins high, but keep as inputs

mov Wait, cnt ' preset the counter
add Wait, WaitTime
Loop
or dira, #BUTTON_PINS ' set TestPins as outputs (high)
andn dira, #BUTTON_PINS ' set TestPins as inputs (floating)
mov Reading, #BUTTON_PINS ' create a mask of applicable pins
waitcnt Wait, WaitTime ' wait for the voltage to decay
andn Reading, ina ' clear decayed pins from the mask
wrlong Reading, par ' write the result to RAM
jmp #Loop

Reading res 1
WaitTime res 1
Wait res 1
</code>

The Repeat loop in the spin code just looks like debounce. It's what's going on in the assembly that I don't quite get.
1. Initially it sets the pins High, even though they are still defined as inputs. What does this do? Charge up something to make a non-grounded pad look like it's pulled up, I'd guess.
2. Then the loop repeatedly makes the pins into outputs, then immediately back into inputs. Since each cog defines I/O pin directions, this must somehow make the pin look pulled up to the primary cog?
3. This doesn't look complex enough to not be done *easily* in Spin. But not so far for me. Must not be getting how this works. Having it work would save installing a bunch of pullup resistors!
TIA,
Don

Comments

  • SapiehaSapieha Posts: 2,964
    edited 2013-01-16 16:43
    Hi Don.

    Edit Yours code tags with [ ] instead of < >
  • Don PomplunDon Pomplun Posts: 116
    edited 2013-01-16 16:55
    Sorry, I was *close*
  • cavelambcavelamb Posts: 720
    edited 2013-01-16 16:57
    Hi Don,

    Gotta use code tags to post spin code.


    The Quickstart is a good choice for getting to know the Propeller.

    I just posted my QuickStart pad driver in the push-on/push-off thread.
    http://forums.parallax.com/showthread.php/144841-button-that-has-push-on-off

    It's written in spin and I use it instead of the better ones,
    You might read through it to get the overall idea.
    Use it if you like it.


    Touchpads work by charging the capacitance of the output cell
    and then seeing if that will discharge in a certain time period.
    No pull-up resistors required.

    Making the pins outputs causes the precharged cell to dump into the external circuit.
    In this case the Touch Pads, through that 100k R (and the C of the circuitry?)
    So that charge will naturally decay over a certain time period.
    Shorting the touchpad to ground with a finger bleeds the charge off a lot faster.
    The rest is all timing- when to take the sample(s).
  • Don PomplunDon Pomplun Posts: 116
    edited 2013-01-16 18:45
    Sorry about the angle brackets vs squares. I've noted it in the *hard copy* journal (assuming I remember it's there next time). Thanx for the replies to the software pull-up solution. Been playing with it, with *interesting* results. For pullups, the hardware solution may be best ;=) And that's not even counting my time!
  • cavelambcavelamb Posts: 720
    edited 2013-01-17 15:40
    Sorry about the angle brackets vs squares. I've noted it in the *hard copy* journal (assuming I remember it's there next time). Thanx for the replies to the software pull-up solution. Been playing with it, with *interesting* results. For pullups, the hardware solution may be best ;=) And that's not even counting my time!

    It's even worse that you suspected, Don.
    With modern chips there is no advantage to pulling up over pulling down.
    With a pull down resistor, the input bit sees positive logic instead of inverted.
  • Don PomplunDon Pomplun Posts: 116
    edited 2013-01-17 17:33
    It's not the polarity of the logic that's a problem, just the ambiguity of the state. Maybe Propeller-2 will consider programmable pull up/downs for inputs.
    Now getting out my drawer of 8.2K resistors. At least the QS board has a handy set of holes for the I/O for them - actually pretty handy!
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-01-17 21:40
    Don,

    just for future reference:


    attachment.php?attachmentid=78421&d=1297987572
  • cavelambcavelamb Posts: 720
    edited 2013-01-17 22:21
    It's not the polarity of the logic that's a problem, just the ambiguity of the state. Maybe Propeller-2 will consider programmable pull up/downs for inputs.
    Now getting out my drawer of 8.2K resistors. At least the QS board has a handy set of holes for the I/O for them - actually pretty handy!


    It's not an ambiguous state when sampled at the right time...

    But good luck with it.
  • AribaAriba Posts: 2,690
    edited 2013-01-18 10:21
    It's not the polarity of the logic that's a problem, just the ambiguity of the state. Maybe Propeller-2 will consider programmable pull up/downs for inputs.
    Now getting out my drawer of 8.2K resistors. At least the QS board has a handy set of holes for the I/O for them - actually pretty handy!

    If you add 8.2k pullups your skin resistance must be lower than about 7 kOhm to see a Low at the input. I don't think this is the case otherwise the existing Touchbutton drivers and example codes should have worked fine for you. Normal skin resistance is in the MegaOhms so you would need pullups with 10..20MOhms. And then this will be as "ambiguous" as the existing solutions.
    The problem is that these are resistive touchbuttons instead of capacitive ones. They just not work with all persons and environments.

    Andy
  • Don PomplunDon Pomplun Posts: 116
    edited 2013-01-18 10:43
    There were two problems with 8.2K's. First, they are such strong pullups that, even if your skin resistance is zero (or you use a jumper on the touch pad), its series 100K doesn't pull down hardly at all, so the input pin stays high. And if you pull a pin low, the 8.2K is low enough to cause a serious drop in the 3.3v supply. I changed to 100K this morning (and I'm not using the touch pads, just Real hardware).
    Don
Sign In or Register to comment.