Shop OBEX P1 Docs P2 Docs Learn Events
>>>>>noob questions here<<<<< — Parallax Forums

>>>>>noob questions here<<<<<

QUARKSPINQUARKSPIN Posts: 36
edited 2010-01-25 01:46 in General Discussion
My (Dumb) question is....

Here it comes...

How do you make the prop see when you press a button?
More specificly, why does my setup toggle between on and off extremely fast? I have one side of the button connected to a resistor, and then to ground, and the other side connected to I\O pin 5. I'm guessing it has something to do with 0 volts not being counter as a zero in my input register, (Because it stops turning on and off when I press the button)

I know there is a very easy way to fix this, could someone give me a schematic or something?

Oh, And rather than kill the forum with thousands of new threads, I'm going to put all my other questions here.

Comments

  • P!-RoP!-Ro Posts: 1,189
    edited 2010-01-24 00:25
    Resistor values aren't so important as long as the pin remains an input. Just to be safe though, 1k and 10k resistors will work fine. With a 10k resistor connecting to ground and the input pin, and 1k connecting to 3.3v and the button it will work fine. What happens is when the button isn't pressed the 10k resistor drags the pin low and it is detected. When it is pressed, positive 3.3v floods in and since it only has 1k resistance instead of 10k it is detected and drags the pin high. Simple enough?

    --also, reading your post a second time it sounds like you put the power for both 3.3v and ground on one side, so when it isn't connected to the pin you are allowing to float, causing random changes in signals.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG

    Post Edited (Pi Guy) : 1/24/2010 12:31:00 AM GMT
  • QUARKSPINQUARKSPIN Posts: 36
    edited 2010-01-24 01:31
    What resistor value should I be using if the 1k resistor is reduced to 220 ohms? (I'm using the PDB and the 220 is hardwired)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm smart, cause' I say smart stuff like this:
    "Hardware is what you have if you want to make that little light on the front turn on."
    --QUARKSPIN
    And...
    "Sometimes some stuff does stuff like... um..."
    --QUARKSPIN
  • P!-RoP!-Ro Posts: 1,189
    edited 2010-01-24 01:41
    PDB and the propeller? I'm assuming you mean ppdb? Yeah it doesn't matter too much, but 1k is just safe if the output is set low it doesn't fry the prop. When you push the button the 1k and 10k short together, but it's too little power to worry about.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • QUARKSPINQUARKSPIN Posts: 36
    edited 2010-01-24 23:53
    I tried every resistor in my box, and they all ether do nothing or permanantly drive it low. Time to go shopping?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm smart, cause' I say smart stuff like this:
    "Hardware is what you have if you want to make that little light on the front turn on."
    --QUARKSPIN
    And...
    "Sometimes some stuff does stuff like... um..."
    --QUARKSPIN
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-25 00:06
    First of all "NOOB QUESTIONS HERE" is not a useful subject for your message thread (for readers of the thread list) unless you want to drive people off. Please change it to something meaningful. Use the pencil icon in the upper right-hand corner of the first message box.

    Do you understand Ohm's Law? If not, please read the Wikipedia article on it. It's basic to this question and probably a lot of others you might have.

    Look at the examples in the "What's a Microcontroller?" tutorial from Parallax. It's written for the Stamps and for 5V logic, but the same ideas apply to the Propeller and 3.3V logic. You may have to change resistors and the code is a bit different, but not a lot. The resistors are generally proportional to the supply voltage (there's that Ohm's Law again!).
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-25 00:13
    I recommend that you use a pullup or pulldown resistor on the order of 10K as Pi Guy suggested. When you press the pushbutton, you don't want the pushbutton and resistor to conduct too much current to cause heating or just waste power or too little current for reliability of the switch contacts. You can figure this out with Ohm's Law, but something in the range from a few hundred microAmps to a few milliAmps would be ok. There's also the protective resistor in series with the I/O pin. You'd like that to be less than perhaps 10% of the pullup or pulldown resistor. This series resistor forms a voltage divider with the pullup or pulldown resistor and you'd like the input voltage to the I/O pin to be closer to the supply voltage or ground than about 10% to be sure to be sensed properly by the I/O pin circuitry.

    Do you know how to read the resistor color codes? If not, look for a Wikipedia article on the subject. It's another piece of really basic information you need.
  • P!-RoP!-Ro Posts: 1,189
    edited 2010-01-25 00:34
    www.parallax.com/Portals/0/Downloads/docs/prod/prop/PELabsFunBook-v1.1.pdf
    go to page 33/34

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-01-25 01:46
    The series input resistor is really only used to protect the Prop's I/O pin in case of a programming error. Imagine if you made this pin an output and that it was set low, what would happen when you press the button? That's right, the I/O pin would be shorted to the supply and a large current would flow. Although the I/O pins are hardy the resistor is there as insurance to limit the current. In normal operation as an input the series resistor has negligible effect as the I/O pins input "resistance" is so high it is effectively floating, so there is no real divider effect, whether it is 100R or 100K.

    The series resistor value is normally low enough to be able to use this pin as an output with sufficient current to drive an led for example. Using a value of around 220R allows an led to be connected directly. The lowest value that would be advisable would be around 100R. Using current limit resistors on general-purpose boards is good practice as it is common to have software errors or side-effects that would otherwise possibly damage the Prop.

    For push-button inputs a pullup/down resistor value of around 1K to 10K is normally used as this provides sufficiently low input impedance so that the pin would not be overly affected by stray EM fields inducing false readings. If your button was connected via a long length of cable then you would use a lower value of pullup/down resistor and po isssibly even a capacitor across the button as well for low AC impedance and debouncing. There is also the issue of providing enough "wetting" current so that the switch contacts remain clean (google this up if you want).

    On the subject of pushbutton inputs IMO I prefer to ground the pushbutton and use a pullup resistor rather than the PE kit example, although for the example there isn't a problem in doing it that way. The reason I have is that a clean and stable supply is essential to operation of the processor so I would avoid running it around to things that don't need it and through which noise could be injected on the supply or the supply shorted against a "ground". Imagine running a button a foot or two away, if you tie the button to the 3.3V supply then that cable becomes an antenna, both transmitting noise and receiving it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
Sign In or Register to comment.