PDA

View Full Version : Proximity Card Reader



Sphere
- 5th November 2005, 14:02
Im trying to display the information stored on a proximity card using a clock an data HID proximity reader. I used the sense pin on the reader to start the programe off. The problem is the lcd displays the same information all the time even if the data line is disconnected from the reader. Im using a pic18f252 at 4mhz ,ive also tried changing the mode on the shift in command and still the same problem. Ive included my code below.

Can anybody help on this one Sphere.


'--------------------------------P18F252----------------------------------------
@CONFIG_REQ
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
@ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
@ __CONFIG _CONFIG3H, _CCP2MX_OFF_3H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG2L, _BOR_OFF_2L & _BORV_42_2L & _PWRT_ON_2L
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
'--------------------------------PROXIMITY READER TEST--------------------------
DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTC 'LCD register select port
DEFINE LCD_RSBIT 4 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 3 'LCD enable bit
DEFINE LCD_RWBIT 2 'LCD read/write bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD

B0 var BYTE

lcdout $FE,$80,"READER "
lcdout $FE,$C0,"TEST "
PAUSE 2000

START:
IF PORTC.7 = 0 THEN GOSUB GETDATA 'TO SENSE OUTPUT ON READER
GOTO START

GETDATA:
Shiftin PORTC.6,PORTC.5,0,[B0\10] 'CLOCK & DATA PINS ON READER
PAUSE 1
lcdout $FE,$80,#B0
LOW PORTB.2 'READER LED
PAUSE 3000
HIGH PORTB.2'READER LED
lcdout $FE,$80," "
RETURN

mugwamp
- 5th November 2005, 15:50
Sphere, Is your card reader communicating in RS232 or Wiegand? HID readers come in both flavors and some will do both. The other thing that stood out in your post was that you're running your PIC at 4 Mhz. A lot of card readers default to 9600 baud. Using the rule of clock rate divided by 400, that would seem to be a bit too "hairy edge" for my tastes. I'd go up to 8Mhz or even 20Mhz. Let us know how it works out.

Sphere
- 5th November 2005, 17:17
Just to let you know its not a weigand reader. With reguards to the crystal ive only got 4Mhz but ill try 20Mhz.

Thanks for the reply Sphere.

Ioannis
- 5th November 2005, 20:54
Could you post the type of the reader? Or link for datasheet?

Ioannis

Sphere
- 5th November 2005, 22:45
Sorry dont no the model number of the reader the make is hid it has a clock, data, sense, red led, green led, buzzer, 5v ,0v. Its of an old site which was being demolished. The system was working before removal from the site.

Sphere.

mugwamp
- 6th November 2005, 05:01
You might want to go to http://www.hidcorp.com/products/readers.php and see if you can match your reader up with on of their models.

Sphere
- 6th November 2005, 14:43
Does my code look ok or im I missing something out. No joy on identifing the model but I tried it on a door controler an it works fine. The door controler is compatable with clock and data readers only acording to the spec sheet. Would I need pullup resistors on the clock and data lines.

Thanks for the help Sphere