Shop OBEX P1 Docs P2 Docs Learn Events
Buffered trigger — Parallax Forums

Buffered trigger

noobydoobnoobydoob Posts: 14
edited 2014-05-20 10:51 in General Discussion
I want to make a buffered trigger.

Can I use the attached circuit, and test if switch is pressed with:

myvar VAR Byte
LOW 0
Loop:
RCTIME 0, 1, myvar
IF myvar > (somevalue) THEN
DEBUG "Triggered!"
LOW 0
ENDIF
GOTO Loop
605 x 192 - 9K
a.jpg 9.3K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2014-05-20 07:19
    The first time you execute this with the switch closed, you're probably going to burn out the Stamp I/O pin because you would have a short circuit between +5V and ground through the low-side transistor of the I/O pin.

    First of all, include a 220 Ohm (or larger) resistor between the I/O pin and the rest of your circuit

    How you program things depends on how you want things to behave. I assume that you want this circuit to "remember" that the switch had be closed until you reset the circuit.

    To reset the circuit ... either at the start of your program or some time after you've checked the switch setting, do: LOW 0

    To check whether the switch has been pressed, you only have to do: IF IN0 THEN GOTO switchPressed

    The I/O pin input circuitry already uses the voltage on the input pin to decide whether the pin is a logic 0 or logic 1. Usually that threshold is about 1/2 of the supply voltage.
  • noobydoobnoobydoob Posts: 14
    edited 2014-05-20 10:30
    Thank you! You are right about the intended use. I want the circuit to remember that the switch is pressed until i check it. I was thinking of using RCTIME because I thought the capacitor could discharge faster than IN0 could detect a logic high.
  • Mike GreenMike Green Posts: 23,101
    edited 2014-05-20 10:51
    A Stamp I/O pin, when in input mode, has a resistance on the order of megaOhms. A 100uF capacitor will take on the order of minutes to discharge. You might do some experimenting. You'll find that humidity may have a significant effect.
Sign In or Register to comment.