View previous topic :: View next topic |
Author |
Message |
plouf
Joined: 19 Jan 2012 Posts: 78 Location: Athens,Greece
|
Posted: Sat Nov 04, 2017 6:14 pm Post subject: Does exist's any Wiegand reader routines/lib? |
|
|
Hello
i am interest in interfacing wiegand reader to MCU do you know any routines and or library and or IC that does part/all the job ?
thanx
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Mon Nov 06, 2017 12:20 am Post subject: |
|
|
I have to make a Lib de Wiegand, When I have it working I will upload it to the forum |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Thu Apr 19, 2018 11:36 pm Post subject: |
|
|
As a comment a while ago I had to do a routine for reading Wiegand protocol, well here it is, I hope that someone is useful.
Best regards.
The timer1 is set for 20mS
Code: | '----- Timer Wiegand
If Estado = 2 Then
If Tim_out_wg > 0 Then
Decr Tim_out_wg
Else
Fl_wg = 0
End If
If Tim_wg > 0 Then
Decr Tim_wg
Else
If Fl_wg = 1 Then
Fl_wg = 2
End If
End If
End If |
The reading of the pins WD0 and WD1 I do them by means of pins of interruption by level
Code: | '---Read Wiegand
If Estado = 2 Then
Z = Pink
Z = Z And &B00001100
If Z = 12 Then Goto Sigue1
If Fl_wg = 0 Then
Fl_wg = 1
Cont_wg = 1
Tim_out_wg = 12
End If
If Wd0 = 0 Then
Buf_wg(cont_wg) = 0
Incr Cont_wg
Tim_wg = 3
End If
If Wd1 = 0 Then
Buf_wg(cont_wg) = 1
Incr Cont_wg
Tim_wg = 3
End If
End If
Sigue: |
And this is the sub that gets the data from the card. This Sub allows to read 26, 32 and 56 bits, Classic and Ultralight cards with ID of 4 and 7 bytes.
Code: | Sub Send_wg()
Local Frame As String * 30 , Aux As String * 4 , Z As Byte , I As Byte , Aux_byte As Byte
Fl_wg = 0
Decr Cont_wg
Frame = ""
Select Case Cont_wg
Case 26
Z = 7
Facility_code = 0
For N = 2 To 9
If Buf_wg(n) = 1 Then
Set Facility_code.z
End If
Decr Z
Next N
Z = 15
Card_code = 0
For N = 10 To 25
If Buf_wg(n) = 1 Then
Set Card_code.z
End If
Decr Z
Next N
Print Hex(facility_code) ; Hex(card_code)
Case 56
Z = 7
Q = 1
Aux_byte = 0
For N = 1 To 56
If Buf_wg(n) = 1 Then
Set Aux_byte.z
End If
If Z = 0 Then
Aux = "0" + Hex(aux_byte)
Ultralight_c(q) = Right(aux , 2)
Z = 7
Aux_byte = 0
Incr Q
Else
Decr Z
End If
Next N
If Ultralight_c(6) = "00" And Ultralight_c(7) = "00" Then '32 Bits
For N = 1 To 4
Frame = Frame + Ultralight_c(n)
Next N
Else
For N = 1 To 7
Frame = Frame + Ultralight_c(n)
Next N
End If
Case Else
Exit Sub
End Select
print Frame
End Sub |
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Apr 21, 2018 8:13 pm Post subject: |
|
|
I moved this to the shared code section.
Thank you for sharing your code and work _________________ Mark |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Sat Apr 21, 2018 8:26 pm Post subject: |
|
|
You're welcome Mark. Sorry for my ignorance but how to access the shared code. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Apr 22, 2018 12:44 pm Post subject: |
|
|
i only changed the forum of this topic. so you access it as before. _________________ Mark |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Sun Apr 22, 2018 2:22 pm Post subject: |
|
|
Ok. Brst Regards. |
|
Back to top |
|
|
|