Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > BASIC Stamp > Wiegand Input  Forum Quick Jump
 
New Topic Post Reply Printable Version
33 posts in this thread.
Viewing Page :
 1  2 
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/10/2006 8:10 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Is anyone familiar with designing some software to read the Wiegand protocol? I have purchased a Basic Stamp Discovery Kit (USB) with a BS2 microcontroller.
 
I have tried the following:
 
I have DATA0 in input0, DATA1 in input1.
 
serialData VAR Byte
SHIFTIN IN0, IN1&IN0, MSBPRE, [serialData]
 
I get different bytes when an actual card is read, but the bytes are never consistent with something that I would consider being a valid Facility Code and Card Number.
 
Can someone please help?
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/10/2006 8:41 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
I not a BS2 expert, but I don't think it can read wiegand data.

The problem is that the weigand device provides that clock and the BS2 SHIFTIN command the BS2 provides the clock.
Using some kind of external "helper" chip you could probably do it.

I have read wiegand the the SX chip using SX/B.

Wiegand format:

Both DATA0 and DATA1 are normally high.
IF DATA0 goes low for about 40uSec then a 0 is clocked in.
IF DATA1 goes low for about 40uSec then a 1 is clocked in.
There is about 2mSec between pulses.

With one of the faster stamps you might be able to pull it off, but putting a diode and cap on each of the lines to act as a "pulse stretcher" so the stamp has a chance to see the low pulse.

Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Post Edited (Bean (Hitt Consulting)) : 2/10/2006 4:46:37 PM GMT

Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/10/2006 8:45 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
I am looking to get some SX-28 chips soon. Do you happen to have your Wiegand SX/B code available?
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/10/2006 8:47 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
You'll need the SX-Key or SX-blitz to program the SX-28 chips.
I'll try to find the code for you.
 
[edit]
This is probably not the place to be posting SX/B code. Maybe one of the moderators will move the thread if they feel so inclined.
 
  ' Edited Feb 10, 2006 12:38PM EST
 
  Data0 VAR RA.0
  DATA1 VAR RA.1
 
  gotID VAR Bit
  bitcnt VAR Byte
  byteCnt VAR Byte
  rfid VAR Byte (3)
 
  gotID = 0
  bitCnt = 255 ' Skip first parity bit
  byteCnt = 0
 
Reader_Wait:
  IF Data0 = 1 THEN
    IF  Data1 = 1 THEN Reader_Wait
  ENDIF
  IF Data1 = 0 THEN 
    dataBit = 1
    DO
    LOOP UNTIL Data1 = 1
  ELSE
    dataBit = 0
    DO
    LOOP UNTIL Data0 = 1
  ENDIF
  IF bitCnt <> 255 THEN
    rfid(byteCnt) = rfid(byteCnt) << 1
    rfid(byteCnt).0 = dataBit
  ENDIF
  INC bitCnt
  IF bitCnt = 8 THEN
    bitCnt = 0
    INC byteCnt
  ENDIF
  IF byteCnt < 3 THEN Reader_Wait
  gotID = 1
This is NOT a complete program, just a snippet to show reading wiegand data.
Sorry about all the comments too ;)
 
Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Post Edited (Bean (Hitt Consulting)) : 2/10/2006 5:39:38 PM GMT

Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/10/2006 8:52 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
That would be much appreciated.
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/14/2006 3:43 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Using the code you supplied I am unable to get any consistent data. I have an LED hooked up to blink when 3 bytes are received, but without anything being read by the reader, the LED still blinks. I have the following code:

' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------

DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000


' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------

DATA0 VAR RA.0
DATA1 VAR RA.1
GREENLED VAR RC.7


' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------

dataBit VAR Bit
bitcnt VAR Byte
byteCnt VAR Byte
rfid VAR Byte (3)

bitCnt = 255 ' Skip first parity bit
byteCnt = 0


' =========================================================================
PROGRAM Start
' =========================================================================

' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------

Start:
GOTO Main

Main:
'Check Low On Data0
IF Data1 = 0 THEN
'Wait For High On Data1
dataBit = 1
DO
LOOP UNTIL Data1 = 1
ELSE
'Wait For High On Data0
dataBit = 0
DO
LOOP UNTIL Data0 = 1
ENDIF

'Check For Parity Bit
IF bitCnt <> 255 THEN
rfid(byteCnt) = rfid(byteCnt) << 1
rfid(byteCnt).0 = dataBit
ENDIF

'Increase Bit Count
INC bitCnt

'8 Bits = 1 Byte
IF bitCnt = 8 THEN
bitCnt = 0
INC byteCnt
ENDIF

'Check For Required 3 Bytes
IF byteCnt < 3 THEN
LOW GREENLED
ELSE
HIGH GREENLED
byteCnt = 0
ENDIF

GOTO Main
Back to Top
 

stamptrol
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2004
Total Posts : 1059
 
   Posted 2/14/2006 4:31 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Jumpkick,

I did some work with Wiegand code from a proximity card reader with a BS2 or BS2sx . Its not a pretty thing to work with, but in the end it did the trick. I wrote it down for safe keeping, now just have to find it.

Seems to me, the card reader would let you select whether the output was sent in async serial ( RS-232) or synchronous where you supplied a clock pulse. The serial version is what I used, 2400 baud, I think.

Will get back to you.

Tom
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/14/2006 4:47 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Jumpkick,
Is seems you missed the first 3 lines of code right after "ReaderWait:"
  IF Data0 = 1 THEN
    IF  Data1 = 1 THEN Reader_Wait
  ENDIF
This keeps the program from continuing unless one of data lines is low.
Your code is shifting in a "0" on every loop through the code.

Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Back to Top
 

stamptrol
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2004
Total Posts : 1059
 
   Posted 2/14/2006 5:20 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Jumpkick,

OK, found my notes from 2002.

1. It was an HID RF proximity card reader.

2. The Wiegand code output could be set to either serial or sync. I used serial.

3. I tested it at 4800 on a BS2 and 9600 on a BS2sx. Just used SERIN to watch for CR or LF. Then, the next burst is grabbed as STR in an 18 byte array. I think the leading zeros were constant so they could also be used as a WAIT parameter inthe SERIN.

4. As an example, card number 31926 sends a string that looks like this:

00 00 04 D6 F9 6C 3F CR LF

step 1: throw away CR and LF ( carriage return and line feed)
step 2: the next pair ( 3F ) is the checksum and can also be disregarded , unless you really want the gymnastics to crunch it on the fly.
step 3: the next two pairs are the card number ( F9 6C ), sort of. F9 6C = 63852
step 4: take the value of those two pairs and divide by 2
step 5: card number is 31926
the 04 and D6 are facility numbers, which I didn't need to decode.

Hope this helps.

Tom
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 8:18 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Bean I added:

IF Data0 = 1 THEN
IF Data1 = 1 THEN
GOTO Main
ENDIF
ENDIF

But even with that the LED blinks green rather spontaneously. I was able to hook my reader to another manufacturers panel and it worked just fine so I don't know what is going on.

Stamptrol:
I am unable to use a serial interface per a requirement for the product. It has to be able to read Wiegand inputs. :(
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/15/2006 9:06 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Jumpkick,
Can you attach your complete program. I'll look at it.
Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 9:16 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Reader.sxb attached.

File Attachment :
Reader.SXB   2KB (text/plain)
This file has been downloaded 71 time(s).
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 10:08 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
What is your layout for connecting a wiegand reader to the board itself?
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/15/2006 10:17 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Jumpkick,
  Try this code.
  Make sure you have the ground wire connected between the reader and the SX.
 
  If the reader is operating from the same power source as the SX then it should be okay.
  If the reader is operating from a seperate supply then you need to connect the ground wires together.
  Other than that just connect the DATA0 and DATA1 wires to the SX pins. You might want to use a 1K resistor just to protect the pin.

Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Post Edited (Bean (Hitt Consulting)) : 2/15/2006 6:20:33 PM GMT



File Attachment :
Reader.SXB   2KB (application/octet-stream)
This file has been downloaded 62 time(s).
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 10:21 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
That may be the problem. Currently I have the wiegand powered outside the board and Data0 and Data1 plugged into RC.0 and RC.1 respectively. Where can I connec the reader to the board to use the same power source?
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/15/2006 10:26 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Just connect the ground of the supply for the SX to the ground of the reader's power supply.
You'll need three wires between the SX and reader: DATA0, DATA1, and GROUND.
Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 10:58 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
That looks to work GREAT! When I put a 1k resistor in between it never reads. However if I go directly into the input itself, everything appears okay. Thank you very much for all your help on this project. I really appreciate it.
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 11:04 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Next I am thinking on how I can output the numbers via serial to a PC for evaluation.
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/15/2006 11:26 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Use this code and from the IDE choose "DEBUG" then choose "POLL".
When you swipe a tag the WATCH window should show the siteID and the cardID for that tag.
 
Bean.
 


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 



File Attachment :
Reader.SXB   2KB (application/octet-stream)
This file has been downloaded 58 time(s).
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 11:32 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Not sure why, but nothing is enabled on the debug screen.
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/15/2006 11:40 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Try changing OSC4MHZ to OSCXT2 on the DEVICE line.
Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 11:57 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
It just says running and you are unable to press any of the buttons.
Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 12:06 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
This is the card I have:

005-56164

Yields:

225 1 118

??
Back to Top
 

Bean (Hitt Consulting)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 5761
 
   Posted 2/15/2006 12:26 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Hmmm,
You should get 5 for siteID and 56164 for cardID. Not sure what's going on there.

Do you get the same values everytime ?

Do you have another card ? What values to you get for it ?

Bean.


"SX-Video Module" Now available from Parallax for only $28.95
 
"SX-Video OSD module" Now available from Parallax for only $49.95
Product web site: www.sxvm.com
 
"Ability may get you to the top, but it takes character to keep you there."
 

Back to Top
 

Jumpkick
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2006
Total Posts : 19
 
   Posted 2/15/2006 1:29 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Even more weird. I get the same values for every card.

005-56166
005-56164
005-56170
Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
33 posts in this thread.
Viewing Page :
 1  2 
 
Forum Information
Currently it is Saturday, November 21, 2009 11:26 AM (GMT -8)
There are a total of 393,853 posts in 55,536 threads.
In the last 3 days there were 84 new threads and 704 reply posts. View Active Threads
Who's Online
This forum has 17692 registered members. Please welcome our newest member, old guy.
54 Guest(s), 18 Registered Member(s) are currently online.  Details
heater, Siri, MichelB, Kenny Gardner, Peter Jakacki, keith_kw, Jay Kickliter, Mike Green, Shawn Lowe, Luis Digital, dMajo, Harley, Rick Brooks, Beau Schwabe (Parallax), SRLM, Tubular, ERM, Toby Seckshund