Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Wiegand Interfacing with 89c51

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-8051
View previous topic :: View next topic  
Author Message
AttiqAamir

Bascom Member



Joined: 18 Jun 2008
Posts: 2

pakistan.gif
PostPosted: Wed Apr 15, 2009 11:16 am    Post subject: Wiegand Interfacing with 89c51 Reply with quote

I have to connect an 89c51 with a couple of Wiegand RFID readers. If anyone want to share his experience (Code + Schm). I had done it in bascom51 previously while utilizing both external interrupts (IN0 and IN1), leaving no room for other readers. I am using the readers from Paxton. Any Help will be appreciated. my previous code was


Code:
$regfile = "reg51.DAT"
$crystal = 11059200
$baud = 57600

'==================================================================================================
' Wiegand Kbd InPut
K_d0 Alias P3.2
K_d1 Alias P3.3

'Edge Trigger on both interrupts
Set Tcon.0
Set Tcon.2

On Int0 D0
On Int1 D1

Config Timer0 = Timer , Mode = 1 , Gate = Internal
On Timer0 Tg0

Enable Interrupts
Enable Int0
Enable Int1
Enable Timer0

Dim Wdata As Long
Dim K As Byte

Dim C1 As Byte
Dim C2 As Byte
Dim I As Byte
Dim X As Bit

Dim Gd0 As Byte
Dim Gd1 As Byte
Dim Gt1 As Byte
Dim Gp1 As Byte


Gd0 = 0
Gd1 = 0
Gt1 = 0
Gp1 = 0


Wdata = 0

C1 = 0
C2 = 0


Do

  If Gp1 = 1 Then
     Gp1 = 0
     Gosub Get_card
  End If



Loop


D0:
   If Gd0 = 0 Then
       Shift Wdata , Left , 1
       Incr C1
   End If

   If Gt1 = 0 Then
     mov    TL0,#0x33
     mov    TH0,#0xF5
     Start Timer0
     Gt1 = 1
   End If

Return


D1:
   If Gd1 = 0 Then
       Shift Wdata , Left , 1
       Wdata = Wdata Or 1
       Incr C1
   End If

   If Gt1 = 0 Then
     mov    TL0,#0x33
     mov    TH0,#0xF5
     Start Timer0
     Gt1 = 1
   End If

Return

Tg0:
    Stop Timer0
    Gd0 = 1
    Gd1 = 1
    Gp1 = 1

Return



Get_card:
                 Print Wdata
                 C1 = 0
                 Wdata = 0
                 Gd0 = 0
                 Gd1 = 0
                 Gt1 = 0
Return
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-8051 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum