Shop OBEX P1 Docs P2 Docs Learn Events
RCTime — Parallax Forums

RCTime

ArchiverArchiver Posts: 46,084
edited 2003-10-11 00:21 in General Discussion
Hi,

I saw some instructions on a way to setup multiple push switches onto
one pin in the 1.9 manual and i'm trying to figure out basically how
to do it with a basic stamp and RCTime instead of Pot, but i'm
completely stumped.

Anyone able to just show me how i should be wiring this up and how i
should be coding it?

Thanks

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-01-25 17:47
    >I saw some instructions on a way to setup multiple push switches onto
    >one pin in the 1.9 manual and i'm trying to figure out basically how
    >to do it with a basic stamp and RCTime instead of Pot, but i'm
    >completely stumped.

    You can use a very similar circuit (referring to stamp I app note 18
    "one pin, many switches"), modified as follows (6 switches shown):

    <TT>
    10k 10k 10k 10k 10k
    +5 Vdd --o-/\/\-o-/\/\-o-/\/\-o-/\/\-o-/\/\-;
    | | | | | |
    N.O. switches % 0 % 1 % 2 % 3 % 4 % 5
    | | | | | |
    stamp P0 -/\/\-o
    o
    o
    o
    o
    o
    1k |
    === 0.01uF mylar film
    |
    Vss
    </TT>

    With one switch at a time down, the time required to charge the
    capacitor from zero volts up to the BS2 switching threshold at 1.3
    volts is about:
    tm = 30E-6 * k second, where k is the switch index.
    That is, switch 0 takes zero time, switch 1 takes 30 microseconds,
    switch 2 60 microseconds ... switch 5 takes 150 microseconds.
    (This comes from solving, 1.3=5*(1 - exp(tm/k*RC))
    The value returned by RCtime will be in units of 2 microseconds, or
    about 15 units per switch.

    ' example program for BS2 "one pin, many switches"
    tm var word
    low 0
    loop:
    RCtime 0,0,tm ' get time
    low 0
    debug dec tm,tab,dec tm+7/15 ' show time and key number
    pause 200
    goto loop

    The constants "7" and "15" may need to be adjusted too match the
    spacing of tm values you see in your circuit, which will depend on
    component tolerances.

    Is that what you are looking for?

    Be aware that this circuit will not allow you to sort out two or more
    switches pressed at the same time. It would be possible to do that,
    a different circuit.

    Have fun,

    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2001-01-26 04:38
    Just out of curiosity, what is the difference between a regular
    capactior and mylar film?

    Also, the main reason i'm trying to get this working completely is i
    need to run a keypad (about 8 buttons) off 1 or 2 pins, as i'm going
    to be using all the rest, is there a simpler method to doing all of
    this? (An IC or something i can hook up that will handle the
    keypresses?)

    Thanks for the help.

    --- In basicstamps@egroups.com, Tracy Allen <tracy@e...> wrote:
    > >I saw some instructions on a way to setup multiple push switches
    onto
    > >one pin in the 1.9 manual and i'm trying to figure out basically
    how
    > >to do it with a basic stamp and RCTime instead of Pot, but i'm
    > >completely stumped.
    >
    > You can use a very similar circuit (referring to stamp I app note
    18
    > "one pin, many switches"), modified as follows (6 switches shown):
    >
    > <TT>
    > 10k 10k 10k 10k 10k
    > +5 Vdd --o-/\/\-o-/\/\-o-/\/\-o-/\/\-o-/\/\-;
    > | | | | | |
    > N.O. switches % 0 % 1 % 2 % 3 % 4 % 5
    > | | | | | |
    > stamp P0 -/\/\-o
    o
    o
    o
    o
    o
    > 1k |
    > === 0.01uF mylar film
    > |
    > Vss
    > </TT>
    >
    > With one switch at a time down, the time required to charge the
    > capacitor from zero volts up to the BS2 switching threshold at 1.3
    > volts is about:
    > tm = 30E-6 * k second, where k is the switch index.
    > That is, switch 0 takes zero time, switch 1 takes 30 microseconds,
    > switch 2 60 microseconds ... switch 5 takes 150 microseconds.
    > (This comes from solving, 1.3=5*(1 - exp(tm/k*RC))
    > The value returned by RCtime will be in units of 2 microseconds,
    or
    > about 15 units per switch.
    >
    > ' example program for BS2 "one pin, many switches"
    > tm var word
    > low 0
    > loop:
    > RCtime 0,0,tm ' get time
    > low 0
    > debug dec tm,tab,dec tm+7/15 ' show time and key number
    > pause 200
    > goto loop
    >
    > The constants "7" and "15" may need to be adjusted too match the
    > spacing of tm values you see in your circuit, which will depend on
    > component tolerances.
    >
    > Is that what you are looking for?
    >
    > Be aware that this circuit will not allow you to sort out two or
    more
    > switches pressed at the same time. It would be possible to do
    that,
    > a different circuit.
    >
    > Have fun,
    >
    > -- Tracy Allen
    > electronically monitored ecosystems
    > http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2001-01-26 06:35
    >Just out of curiosity, what is the difference between a regular
    >capactior and mylar film?

    Accuracy and stability. A plastic film capacitor (mylar is just one
    type) will be within 5% or 2% of the 0.01uF value. And the value
    won't change too much with the temperature outside. The ceramic
    capacitors are worse (except COG/NPO, which are uncommon in the 0.01
    uF value).


    >Also, the main reason i'm trying to get this working completely is i
    >need to run a keypad (about 8 buttons) off 1 or 2 pins, as i'm going
    >to be using all the rest, is there a simpler method to doing all of
    >this? (An IC or something i can hook up that will handle the
    >keypresses?)

    Follow this link:
    http://www.rentron.com/Ser-Key.htm
    Bruce has a nice keypad chip that handles up to 10 keys. You will
    still need extra parts. The chip requires a crystal, a capacitor,
    and a handful of resistors.

    When a circuit calls for several resistors of one value, you can
    often get them all in one SIP or DIP package. That would go for
    either the series 10k resistors called for by the RCtime circuit, or
    the pullup resistors called for by the Ser-Key circuit. That saves
    on your parts count and hassle. An RCtime circuit with 5 switches
    would require one 10kx5 resistor network, one 0.01uf capacitor, and
    one 1kohm resistor, plus the 5 switches.

    Revisiting the RCtime program, I put in a couple of minor changes, and,
    ---If no key is pressed, then the RCtime value will be exactly zero,
    whereas if any key is pressed, then the RCtime value will be greater
    than 0. . The program below loops until a key is actually pressed.


    ' example program for BS2 "one pin, many switches"
    tm var word
    k1 con 15 ' RCtime difference, switch to switch
    k2 con k1/2 ' half the above for offset
    low 0
    loop:
    RCtime 0,0,tm ' get time
    low 0
    if tm=0 then loop ' tm is exactly zero if no key pressed
    debug dec tm,tab,dec tm+k2/k1,cr ' show time and key number
    pause 200
    goto loop

    ---It is possible that the user might press the key exactly in the
    middle of the RCtime command, and that would give a bogus result. If
    it matters, it would be best to read the RCtime value twice in a row,
    and only accept a key if the two values agree.



    >Thanks for the help.

    You're welcome!
    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com



    >
    >--- In basicstamps@egroups.com, Tracy Allen <tracy@e...> wrote:
    > > >I saw some instructions on a way to setup multiple push switches
    >onto
    > > >one pin in the 1.9 manual and i'm trying to figure out basically
    >how
    > > >to do it with a basic stamp and RCTime instead of Pot, but i'm
    > > >completely stumped.
    > >
    > > You can use a very similar circuit (referring to stamp I app note
    >18
    > > "one pin, many switches"), modified as follows (6 switches shown):
    > >
    > > <TT>
    > > 10k 10k 10k 10k 10k
    > > +5 Vdd --o-/\/\-o-/\/\-o-/\/\-o-/\/\-o-/\/\-;
    > > | | | | | |
    > > N.O. switches % 0 % 1 % 2 % 3 % 4 % 5
    > > | | | | | |
    > > stamp P0 -/\/\-o
    o
    o
    o
    o
    o
    > > 1k |
    > > === 0.01uF mylar film
    > > |
    > > Vss
    > > </TT>
    > >
    > > With one switch at a time down, the time required to charge the
    > > capacitor from zero volts up to the BS2 switching threshold at 1.3
    > > volts is about:
    > > tm = 30E-6 * k second, where k is the switch index.
    > > That is, switch 0 takes zero time, switch 1 takes 30 microseconds,
    > > switch 2 60 microseconds ... switch 5 takes 150 microseconds.
    > > (This comes from solving, 1.3=5*(1 - exp(tm/k*RC))
    > > The value returned by RCtime will be in units of 2 microseconds,
    >or
    > > about 15 units per switch.
    > >
    > > ' example program for BS2 "one pin, many switches"
    > > tm var word
    > > low 0
    > > loop:
    > > RCtime 0,0,tm ' get time
    > > low 0
    > > debug dec tm,tab,dec tm+7/15 ' show time and key number
    > > pause 200
    > > goto loop
    > >
    > > The constants "7" and "15" may need to be adjusted too match the
    > > spacing of tm values you see in your circuit, which will depend on
    > > component tolerances.
    > >
    > > Is that what you are looking for?
    > >
    > > Be aware that this circuit will not allow you to sort out two or
    >more
    > > switches pressed at the same time. It would be possible to do
    >that,
    > > a different circuit.
    > >
    > > Have fun,
    > >
    > > -- Tracy Allen
    > > electronically monitored ecosystems
    > > http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-11 00:16
    Has anyone tried the RCTIME example in the manual? Where's the useful
    information, like how much time it takes for the cap to discharge. All the
    program
    gives me is result = 1.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-11 00:21
    Which version of the manual do you have? The current manual goes into
    considerable detail on the mechanics and mathematics of RCTIME,
    specifically pages 257 and 258.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: MP1428@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=PeZ4bgfJhzqV8o__4q_VCeKe3UbRRqzjlcjM6-JiMmH7TXPI466mlbP_v4gPyFe9w51sPZQI]MP1428@a...[/url
    Sent: Friday, October 10, 2003 6:16 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] RCTIME


    Has anyone tried the RCTIME example in the manual? Where's the useful
    information, like how much time it takes for the cap to discharge. All
    the program
    gives me is result = 1.


    [noparse][[/noparse]Non-text portions of this message have been removed]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.