Shop OBEX P1 Docs P2 Docs Learn Events
Getting parallel data on BS2... newbie — Parallax Forums

Getting parallel data on BS2... newbie

ArchiverArchiver Posts: 46,084
edited 2003-05-14 17:49 in General Discussion
Hi... I have a Clare 8870-01 DTMF decoder that I want to interface
with my BS2 for a application that does stuff based on dial-tones.

The 8870 takes a touch-tone tone in, and outputs a corresponding
binary code on 4 outputs (Q0-Q3). Also, a Valid-Tone pin (ESt) goes
High when a valid DTMF tone is detected. Eg, I press a 7 and I get a
0111 parallel output on Q0-3 and a 1 on ESt until I release the 7
button.

The 8870 part of the circuit is working great and I'm pleased. But
now I want my BS2 to make some use of this. I'm trying to write some
code that watches ESt, and when ESt is HIGH the stamp looks at Q0-Q3
and says, "Ok, I see a 0111... I will set key=7".

Can anyone offer a code sample, or maybe point me to a good resource
(I did RTFM, and I'm sure I can hack my way through it, but I'd like
to hear what the pros think).

Thanks a bunch!

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-05-12 19:10
    Presuming you've got all five data lines you mentioned running to
    the BS2, that shouldn't be too difficult at all.

    '
    key var byte 'define variable "key"
    'Q0-Q3 to pin0-pin3
    'ESt to pin4

    loop:
    if in4=0 then loop 'do nothing until ESt goes high

    key=in3*8+in2*4+in1*2+in0*1 'convert to base 10 (pin3 is MSb)

    if key=0 then...
    if key=1 then...
    if key=2 then... (etc.)
    '

    Hope that helps! - John

    --- In basicstamps@yahoogroups.com, "iamlevis2" <iamlevis2@y...>
    wrote:
    > Hi... I have a Clare 8870-01 DTMF decoder that I want to
    interface
    > with my BS2 for a application that does stuff based on dial-tones.
    >
    > The 8870 takes a touch-tone tone in, and outputs a corresponding
    > binary code on 4 outputs (Q0-Q3). Also, a Valid-Tone pin (ESt)
    goes
    > High when a valid DTMF tone is detected. Eg, I press a 7 and I get
    a
    > 0111 parallel output on Q0-3 and a 1 on ESt until I release the 7
    > button.
    >
    > The 8870 part of the circuit is working great and I'm pleased.
    But
    > now I want my BS2 to make some use of this. I'm trying to write
    some
    > code that watches ESt, and when ESt is HIGH the stamp looks at Q0-
    Q3
    > and says, "Ok, I see a 0111... I will set key=7".
    >
    > Can anyone offer a code sample, or maybe point me to a good
    resource
    > (I did RTFM, and I'm sure I can hack my way through it, but I'd
    like
    > to hear what the pros think).
    >
    > Thanks a bunch!
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-12 20:19
    I'm at work right now, so I can't try it out, but it makes sense. I
    can't wait to get home and give it a try!

    Thanks... I'm sure I'll be back =)


    --- In basicstamps@yahoogroups.com, "max2451234" <jjghost@t...> wrote:
    > Presuming you've got all five data lines you mentioned running to
    > the BS2, that shouldn't be too difficult at all.
    >
    > '
    > key var byte 'define variable "key"
    > 'Q0-Q3 to pin0-pin3
    > 'ESt to pin4
    >
    > loop:
    > if in4=0 then loop 'do nothing until ESt goes high
    >
    > key=in3*8+in2*4+in1*2+in0*1 'convert to base 10 (pin3 is MSb)
    >
    > if key=0 then...
    > if key=1 then...
    > if key=2 then... (etc.)
    > '
    >
    > Hope that helps! - John
    >
    > --- In basicstamps@yahoogroups.com, "iamlevis2" <iamlevis2@y...>
    > wrote:
    > > Hi... I have a Clare 8870-01 DTMF decoder that I want to
    > interface
    > > with my BS2 for a application that does stuff based on dial-tones.
    > >
    > > The 8870 takes a touch-tone tone in, and outputs a corresponding
    > > binary code on 4 outputs (Q0-Q3). Also, a Valid-Tone pin (ESt)
    > goes
    > > High when a valid DTMF tone is detected. Eg, I press a 7 and I
    get
    > a
    > > 0111 parallel output on Q0-3 and a 1 on ESt until I release the 7
    > > button.
    > >
    > > The 8870 part of the circuit is working great and I'm pleased.
    > But
    > > now I want my BS2 to make some use of this. I'm trying to write
    > some
    > > code that watches ESt, and when ESt is HIGH the stamp looks at Q0-
    > Q3
    > > and says, "Ok, I see a 0111... I will set key=7".
    > >
    > > Can anyone offer a code sample, or maybe point me to a good
    > resource
    > > (I did RTFM, and I'm sure I can hack my way through it, but I'd
    > like
    > > to hear what the pros think).
    > >
    > > Thanks a bunch!
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-12 20:36
    If you're using the pins as shown in the code below, you can simplify by
    using some of the Stamp's built-in variables. Like this:

    key = InA

    Ta da.... Done. No math required. InA is a nibble sized variable that is
    affected by the input pins 0 - 3.

    -- Jon Williams
    -- Parallax


    In a message dated 5/12/2003 1:35:07 PM Central Standard Time,
    jjghost@t... writes:

    > key=in3*8+in2*4+in1*2+in0*1 'convert to base 10 (pin3 is MSb)



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-14 17:49
    Yah... that did the trick. Actually, your little piece of code led
    to an epiphany that I'm sure will help me in my stamping.


    --- In basicstamps@yahoogroups.com, "max2451234" <jjghost@t...> wrote:
    > Presuming you've got all five data lines you mentioned running to
    > the BS2, that shouldn't be too difficult at all.
    >
    > '
    > key var byte 'define variable "key"
    > 'Q0-Q3 to pin0-pin3
    > 'ESt to pin4
    >
    > loop:
    > if in4=0 then loop 'do nothing until ESt goes high
    >
    > key=in3*8+in2*4+in1*2+in0*1 'convert to base 10 (pin3 is MSb)
    >
    > if key=0 then...
    > if key=1 then...
    > if key=2 then... (etc.)
    > '
    >
    > Hope that helps! - John
    >
    > --- In basicstamps@yahoogroups.com, "iamlevis2" <iamlevis2@y...>
    > wrote:
    > > Hi... I have a Clare 8870-01 DTMF decoder that I want to
    > interface
    > > with my BS2 for a application that does stuff based on dial-tones.
    > >
    > > The 8870 takes a touch-tone tone in, and outputs a corresponding
    > > binary code on 4 outputs (Q0-Q3). Also, a Valid-Tone pin (ESt)
    > goes
    > > High when a valid DTMF tone is detected. Eg, I press a 7 and I
    get
    > a
    > > 0111 parallel output on Q0-3 and a 1 on ESt until I release the 7
    > > button.
    > >
    > > The 8870 part of the circuit is working great and I'm pleased.
    > But
    > > now I want my BS2 to make some use of this. I'm trying to write
    > some
    > > code that watches ESt, and when ESt is HIGH the stamp looks at Q0-
    > Q3
    > > and says, "Ok, I see a 0111... I will set key=7".
    > >
    > > Can anyone offer a code sample, or maybe point me to a good
    > resource
    > > (I did RTFM, and I'm sure I can hack my way through it, but I'd
    > like
    > > to hear what the pros think).
    > >
    > > Thanks a bunch!
Sign In or Register to comment.