Shop OBEX P1 Docs P2 Docs Learn Events
Reading a self clocking synchronous IO Device — Parallax Forums

Reading a self clocking synchronous IO Device

ArchiverArchiver Posts: 46,084
edited 2003-03-20 03:23 in General Discussion
What would be the best way to read data from a 3 wire synchronous serial
device? Preferably I would like to watch 16 devices with a 32 port BS2p
40. ShiftIn unfortunately has the basic stamp doing the clocking. I
need the basic stamp to listen to the clock and read the data wire when
it receives a clock. Any help would be great!!

Josh



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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-03-19 21:15
    You could use 2 74HCT595 chips.
    You would write a '1' bit into the first chip, to use
    as a 'divide by 8' signal. You would use the second
    595 as a shift register on the 3-wire synch line.
    Shift both 595's with the same clock.

    When the '1' bit comes out of the first 595, use
    that signal to latch the second chip's data.
    Monitor that pin with the Stamp, and when it goes
    low, read the 8-bits in parallel from the second
    595.

    This will only monitor a single data line -- a second
    data line requires another '595. This is a mostly
    hardware solution -- because I don't think the
    Stamp has anything built in to do this.

    --- In basicstamps@yahoogroups.com, "Joshua Perry" <jperry@1...>
    wrote:
    > What would be the best way to read data from a 3 wire synchronous
    serial
    > device? Preferably I would like to watch 16 devices with a 32 port
    BS2p
    > 40. ShiftIn unfortunately has the basic stamp doing the clocking.
    I
    > need the basic stamp to listen to the clock and read the data wire
    when
    > it receives a clock. Any help would be great!!
    >
    > Josh
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-19 22:19
    OK, after more reading, the 2P DOES have a
    'POLLWAIT' feature set:

    PollClockPin CON 0
    PollDataPin CON 1
    PollVar VAR BYTE
    NumBits VAR BYTE

    POLLIN PollClockPin, 1 ' Look for a high
    POLLMODE 2 ' Mode 2 means use a PollWait
    MAIN:
    PollVar = 0: NumBits = 0
    Loop:
    PollVar = PollVar << 1
    POLLWAIT 8 ' Wait for clock high (mid-bit)
    ' Response time < 160 uS (Page 235)
    PollVar.Bit1 = PollDataPin
    NumBits = NumBits + 1
    IF NumBits < 8 THEN Loop
    ' ELSE
    ' Save data in PollVar, or do whatever...
    GOTO MAIN ' Get the next byte...

    I don't know how fast this will work -- the
    circuit I described earlier will give you
    more time to get the data.

    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > You could use 2 74HCT595 chips.
    > You would write a '1' bit into the first chip, to use
    > as a 'divide by 8' signal. You would use the second
    > 595 as a shift register on the 3-wire synch line.
    > Shift both 595's with the same clock.
    >
    > When the '1' bit comes out of the first 595, use
    > that signal to latch the second chip's data.
    > Monitor that pin with the Stamp, and when it goes
    > low, read the 8-bits in parallel from the second
    > 595.
    >
    > This will only monitor a single data line -- a second
    > data line requires another '595. This is a mostly
    > hardware solution -- because I don't think the
    > Stamp has anything built in to do this.
    >
    > --- In basicstamps@yahoogroups.com, "Joshua Perry" <jperry@1...>
    > wrote:
    > > What would be the best way to read data from a 3 wire synchronous
    > serial
    > > device? Preferably I would like to watch 16 devices with a 32
    port
    > BS2p
    > > 40. ShiftIn unfortunately has the basic stamp doing the
    clocking.
    > I
    > > need the basic stamp to listen to the clock and read the data
    wire
    > when
    > > it receives a clock. Any help would be great!!
    > >
    > > Josh
    > >
    > >
    > >
    > > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-20 03:23
    Ok, well I ended up getting a CD4031 64 bit shift register, and the stamp worked
    great with it. Well it turns out that the hardware I am using isn't clock/data,
    its Weigand. Weigand uses 2 data lines that sit high. One line is the 1 line
    and the other is the 0 line. When data is sent the 1 or 0 line will pulse low
    for 50 us. There is at least a 2 ms pause between each pulse. If the 1 line
    pulses it is a high bit in the data string, if the 0 line pulses it is a low bit
    in the data string. Obviously the stamp is too slow to pick up a 50us pulse.
    So I thought I could change this to a clock/data system.

    DATA0
    |
    |
    ORGATE
    >CLOCK ANDGATE
    >DATA
    DATA1
    |--NOTGATE
    |


    Then I can use the CD4031 to stor the data and clock it out with the basic
    stamp. Could anyone experienced in hardware design give some input on whether
    this would work? If a picture with a waveform would help, just let me know. I
    wasn't sure if picture attachments are allowed on the list.

    Thanks a ton!

    Josh

    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=tUiuktcBo044q6WaL2qdfwzVvPWhqkqVkjJ8eJtTIqQCUjkSNagjCqQDSnaPPnTHF2TvmwyHdwWfShqkeRKxZy2A0bMDsCA]allan.lane@h...[/url
    Sent: Wed 3/19/2003 3:19 PM
    To: basicstamps@yahoogroups.com
    Cc:
    Subject: [noparse][[/noparse]basicstamps] Re: Reading a self clocking synchronous IO Device



    OK, after more reading, the 2P DOES have a
    'POLLWAIT' feature set:

    PollClockPin CON 0
    PollDataPin CON 1
    PollVar VAR BYTE
    NumBits VAR BYTE

    POLLIN PollClockPin, 1 ' Look for a high
    POLLMODE 2 ' Mode 2 means use a PollWait
    MAIN:
    PollVar = 0: NumBits = 0
    Loop:
    PollVar = PollVar << 1
    POLLWAIT 8 ' Wait for clock high (mid-bit)
    ' Response time < 160 uS (Page 235)
    PollVar.Bit1 = PollDataPin
    NumBits = NumBits + 1
    IF NumBits < 8 THEN Loop
    ' ELSE
    ' Save data in PollVar, or do whatever...
    GOTO MAIN ' Get the next byte...

    I don't know how fast this will work -- the
    circuit I described earlier will give you
    more time to get the data.

    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > You could use 2 74HCT595 chips.
    > You would write a '1' bit into the first chip, to use
    > as a 'divide by 8' signal. You would use the second
    > 595 as a shift register on the 3-wire synch line.
    > Shift both 595's with the same clock.
    >
    > When the '1' bit comes out of the first 595, use
    > that signal to latch the second chip's data.
    > Monitor that pin with the Stamp, and when it goes
    > low, read the 8-bits in parallel from the second
    > 595.
    >
    > This will only monitor a single data line -- a second
    > data line requires another '595. This is a mostly
    > hardware solution -- because I don't think the
    > Stamp has anything built in to do this.
    >
    > --- In basicstamps@yahoogroups.com, "Joshua Perry" <jperry@1...>
    > wrote:
    > > What would be the best way to read data from a 3 wire synchronous
    > serial
    > > device? Preferably I would like to watch 16 devices with a 32
    port
    > BS2p
    > > 40. ShiftIn unfortunately has the basic stamp doing the
    clocking.
    > I
    > > need the basic stamp to listen to the clock and read the data
    wire
    > when
    > > it receives a clock. Any help would be great!!
    > >
    > > Josh
    > >
    > >
    > >
    > > [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/




    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.