Shop OBEX P1 Docs P2 Docs Learn Events
Pushbuttons Low to High — Parallax Forums

Pushbuttons Low to High

T. PardyT. Pardy Posts: 6
edited 2009-05-08 00:18 in BASIC Stamp
Hi, I am new to the forum. I just recently bought the stampworks kit, I've had a long time interest in electronics and computers. I came across this kit and thought wow, I'm gonna dive right in. Now for my question, I have noticed that the push buttons on the PDB return a logic 0 when pressed instead of a 1. Is this normal? and if so, could someone explain to me why that is and how I can get them to send a high signal instead? Any help would be greatly appreciated..

thanks,

Travis

Comments

  • rixterrixter Posts: 95
    edited 2009-05-04 00:29
    I believe those pushbuttons are pulled up to VDD with 10k resistors. This forces them to read 1 when not pressed and a pressing of the button will return zero. It is common with switches to pull up or pull down with resistors to force a true known logic state so the pin won't read a "floating" value. I am not sure if those are configurable with that board.

    Rick
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-05-04 03:31
    Hi Travis, the PDB is a nice board.

    If you take a look at the PDB schematic on the product page and find the page with the switches on you will see that the buttons are 8 identical circuits. Each button has two resistors associated with it. The 22 Ohm is a standard connection used with most I/O to protect the stamp from high current. The 10 K resistor is low enough to hold the pin in a logic 1 state yet high enough that when the button is pressed it provides a logic 0 while limiting the current between Vdd and Vss to a minimal value.

    As Rick pointed out these switches hard wired and cannot be altered , but you can mount your own switch on the breadboard using the same resistor configuration and by swapping Vdd and Vss you would get a logic 0 in the non pressed state and a logic 1 when pressed.

    Jeff T.
  • T. PardyT. Pardy Posts: 6
    edited 2009-05-05 03:31
    Thanks guys... I was wondering if there was a way I could invert the signal to logic 1 once it is received by the stamp? I have been skimming through the stamp syntax manual for a solution, but yet to find one... Again thanks!

    trav
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-05 04:11
    There's rarely a reason to invert the hardware signal. The Stamp is just as happy testing for an I/O pin going low as it is for an I/O pin going high. The BUTTON statement is designed for either case. You can do "IF IN1 = 0 THEN" just as easily as you can do "IF IN1 = 1 THEN".
  • T. PardyT. Pardy Posts: 6
    edited 2009-05-05 23:14
    Thanks everyone, as I am new to the digital domain of electronics, I'm still learning. Thanks Mike for reminding me that the stamp, regardless if the button returns a high or low, the stamp still detects if the button has been pressed, or released for that matter. I guess my question was a little on the dumb side, lol..
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-05-06 15:38
    Hello,

    To read the inverted state of any I/O pin simply place a tilde (~) in front of it. For example, if you use the following code you will see a 1 until you press the button at which point it will become a 0 (assuming your PDB button is connected to P0).
    DO
      DEBUG HOME, BIN1 IN0
      PAUSE 100
    LOOP
    

    Now, if you make a single change as below, it will now return a 0 until you press the button which will then return a 1.

    DO
      DEBUG HOME, BIN1 ~IN0
      PAUSE 100
    LOOP
    

    You can use this in assignments to, such as:· temp = ~IN0·· or switches = ~INL

    ...and in compares, such as: IF ~IN0 = 1 THEN

    I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • T. PardyT. Pardy Posts: 6
    edited 2009-05-08 00:18
    Thanks Chris that is exactly what I was looking for!
Sign In or Register to comment.