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

Weigand

VBVB Posts: 1
edited 2005-04-15 18:42 in BASIC Stamp
Has anyone tried to use the basic stamp alongwith a Weigand protocol based proximity reader ?

Quoting from an earlier message in this forum


"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."

Would it work if I use the COUNT command to wait for and decode 50us transitions ?

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-15 18:42
    The problem you run into is you can only 'COUNT' (or even PULSIN) a single pin at a time. The protocol you describe uses two pins -- so you could wait for a "1", or wait for a "0", but not both.

    You could sample both lines at the same time with:

    INPUT 0 ' "0" pin
    INPUT 1 ' "1" pin

    ' Note InA will read 4 pins at one time

    ReadPins:
    BRANCH InA, [noparse][[/noparse]BothPins, RecordZero, RecordOne, ReadPins]
    GOTO ReadPins

    RecordZero:
    ' Do stuff until line goes high again
    ' Record a zero value
    GOTO ReadPins

    RecordOne:
    ' Do stuff until line goes high again
    ' Record a one value
    GOTO ReadPins

    BothPins:
    ' Shouldn't happen
    GOTO ReadPins

    The only problem with this approach is it may miss a 50 uSec pulse -- that's awfully small compared to the BS2 instruction cycle time (33 uSec / instruction).
    ·
Sign In or Register to comment.