unexplained problem reading wiegand protocol
stef
Posts: 173
Hi
I used in a few projects now the folowing routine to read the wiegand bus from a standard HID access control reader. I got this with help from other forum members and it has worked perfect until now. In my recent project it is working but sometimes it is reading a differend number. If you then look at the binery format of that number everything is shifted one place to the left and aded a zero on the right side. basicly it has read the same number but schifted. I looked with a scoop and at that point it is the same number as always in pulses on the data 0 and data 1 lines. So why is it sometimes doing that? Does somebody have some hints on resolving this or optimizing this spin so i can resolve this. I'm sertainly not the best in spin but i like to learn.
so eventualy in cardnumber0 and in cardnumber 1 is the complete 42 bit of the wiegand bus.
Any advice is welcom.
stef
I used in a few projects now the folowing routine to read the wiegand bus from a standard HID access control reader. I got this with help from other forum members and it has worked perfect until now. In my recent project it is working but sometimes it is reading a differend number. If you then look at the binery format of that number everything is shifted one place to the left and aded a zero on the right side. basicly it has read the same number but schifted. I looked with a scoop and at that point it is the same number as always in pulses on the data 0 and data 1 lines. So why is it sometimes doing that? Does somebody have some hints on resolving this or optimizing this spin so i can resolve this. I'm sertainly not the best in spin but i like to learn.
state := %11<<4 ' setup mask state for RDR_D0 and RDR_D1 pins Repeat cardnumber[0] := 0 ' Initialise variables cardnumber[1] := 0 Bits := 0 cardnumber_L := 0 Repeat waitpne(state,state,0) ' Wait for D0 or D1 to change Read := INA[WD0..WD1] ' Store the state of D0 and D1 cardnumber[0] <<= 1 ' Shift cardnumber 0 left by 1 bit cardnumber[0] |= ((cardnumber[1] & (%1<<31))>>31) ' copy the MSB of cardumber 1 to LSB or cardnumber 0 cardnumber[1] <<= 1 ' Shift cardnumber 1 left by 1 bit IF Read == %01 ' If the D1 input was low cardnumber[1] |= %1 ' Set the LSB of cardnumber 1 waitpeq(state,state,0) ' Wait for D0 and D1 to go high Bits++ ' Increase the number of bits received Until Bits == 42The code example is not the complete project. Just the part to read the wiegand bus.
so eventualy in cardnumber0 and in cardnumber 1 is the complete 42 bit of the wiegand bus.
Any advice is welcom.
stef
Comments
Without knowing the card structure I would guess that it's additional parity bits.
How many bits are read and how many should you expect to read?
Regards,
Coley
This code may be of use to you, it uses the counters to keep track of the bits received....
wiegand-protocol-format-pr25.pdf
Where can one buy "wiegand wire"?
Just the wire to play with or do experiments.
I have looked for this for at least 15 years and can't find a source.
I don't want the card readers.
Duane J
Wiegand Wires are used in the actual magnetic sensor used in the Wiegand keycards. These have a Wiegand protocol .
I'm looking for the magnetic Wiegand Wires which are the heart of the sensors.
Duane J
I know, not the best explanation, but the best I can give on short notice.
Duane J
not the centre. Presumably the right alloy is needed (otherwise everyone would be doing this with steel wire!).
Nice catch. Yes I started with your code. It was working perfect until now.
Thiks for the help and the new code. I will set it up this evening at home and get back with the result.
I need to modify it to work with 42 Bit because this project is running on that.
I will keep you informed.
Stef
Up to the next project.
stef
Regards,
Coley
No, I did not look at the links in your prior posting before my prior post, but I have now. Thanks for posting those links. I picked up some good information there. Now I am wondering what kind of cards the system is using. The data is sent in the Weigand format over 2 wires + ground, but the cards are not slid through a card reader (like mag stripe cards), they only need to be placed near the surface of the reader. I know the reader uses a magnetic coil energized by a 125KHz signal and assumed it was reading Weigand cards. Perhaps not. This security stuff is relatively new to me so it looks like I still have a bit more to learn about it.