reading wiegand data
Hi
I'm trieing to read wiegand protocol to interface an acces controle reader to my sx and send the data then out true a serial line to a computer. I have struggeld so far now that it is working but I always get diffrend data when presenting the same badge. Thier is something wrong in the program but I can't find what it is. Is somebody willing to take a look and point me to the bug or give me a clue what i'm doing wrong.
I listed the program below.
Thanks
Stef
I'm trieing to read wiegand protocol to interface an acces controle reader to my sx and send the data then out true a serial line to a computer. I have struggeld so far now that it is working but I always get diffrend data when presenting the same badge. Thier is something wrong in the program but I can't find what it is. Is somebody willing to take a look and point me to the bug or give me a clue what i'm doing wrong.
I listed the program below.
Thanks
Stef
DEVICE SX28,TURBO,STACKX_OPTIONX '-------------------------------------------------------------------------------- ' wiegand reader interface '-------------------------------------------------------------------------------- '-------------------------------------------------------------------------------- ' Pins '-------------------------------------------------------------------------------- DIMBIT pulseled=RA.3 DIMBIT data0=RA.0 DIMBIT data1=RA.1 DIMBIT greenled=RC.7 DIMBIT TX=RB.0 '-------------------------------------------------------------------------------- ' Variables '-------------------------------------------------------------------------------- DIM N DIM databit DIM bitcnt DIM bytecnt DIM rfid(3) DIM siteid DIM cardid(2) outdir greenled indir data0,data1,pulseled watch siteid,cardid,data0,data1 level RA=$ff pullup RA=$00 LEVEL RB=$00 SCHMITT RB=$FF '-------------------------------------------------------------------------------- 'Programma '-------------------------------------------------------------------------------- start: bitcnt=0 bytecnt=0 databit=0 main: ' controle if both lines are high IF data0 = TRUE then if data1 = TRUE then greenled = false GOTO main ENDIF ENDIF greenled = true ' controle if one line is low IF data1 = FALSE THEN SHIFTINL databit,data0 'wait untile data1 line is back high WHILE DATA1=FALSE WEND ELSE SHIFTINL databit,data0 'wait untile data0 line is back high WHILE data0=FALSE WEND ENDIF ' add bit count INCR bitcnt IF bitcnt = 8 THEN bitcnt = 0 rfid(bytecnt) = databit INCR bytecnt ENDIF 'controle 3 bytes if bytecnt < 3 THEN GOTO main ' send data to serial port out SEROUTA TX,rfid(0),3 'seroutA tx,rfid(1),3 'seroutA tx,rfid(2),3 goto start END
Comments
I'm realy not getting out this problem. I got some nice help on earlyer post but now nobody is reakting. Did I do something wrong? So yes, I appolagise.
I don't know if it is hardware (pull up or down resisters perhaps) or a mistake in the program. I know i'm a beginner but I realy don't know why I always get diffreand readouts.
Stef
it would appear that you are uncertain of a few items.· Suggest that you google wiegand, I cannot recall exact timing, but it is slow.· You need to use pullups, suggest 5 to 10 k, to 5 volts.· The reader will pull down on a data bit, and this is what needs to be read.
There is considerable difference in output from all the different weigand devices in the market.· The only real simularity is the fact that one of the data lines pulled low =· 0, and the other, 1.
This is due to the original need to read wiegand cards.· The continued use of the system (as a data transmission medium) long after the demise of the wiegand card is a sad reflection on the (access control) industry.
If it was me, the first thing I would do is examine the reader output on a duel channel scope to get the timing and bit sequences.· If no scope, write a program for the SX to log and record a read.· Debug is great for this type of fast and dirty bit v time examination.· Set an interrupt (2 t's) for 100uS, and increment a register every interrupt until a bit pulls a data line low.· As wiegand is so slow, you will need a multi byte setup.
Hope this helps,· bongo
Thanks for the help. I recheked all and took some of your advice in considuration.
I changed the hardware and added 2 pull up resistors of 10 K to the wiegand lines.(why I dont know)
Afther some test (The value's where now always the same but not what I wood expect) I saw that I made a mistake in the program. The 26bit wiegand format has a leeding parity bit for the first 12 bits. The program I run in the sx was taking also that bit als value. That was the reason I saw diffrent values than expected.
I changed the program to discard the first bit and now I see realy the value's I expect.
Thanks for the help.
The wiegand has al leeding even paritybit for the first 12 bits and a tailing odd paritybit for the last 12 bits. I think i can use them like a sort off error check if my values are read ok. Is somebody knowing how to calculate in basic the odd and even parity checksum??
I now can see the value's true the serial connection on my pc. I like to difine 2 pins and send the value also out again in wiegand format. Is sombody knowing what command I need to use to do this?? I think it is more difficult because you need to look also in considuration the timing you create to match wiegand standard.
stef