Magnetic Card Reader and BS2p40
skinnydude
Posts: 20
I'm trying to read track 1 from a TTL magnetic card reader using the BS2p40 I/O pins.· I think I'm missing data from the read.· Is this PIC fast enough to read the data directly or should I use a FIFO to buffer the data?· As of right now, I'm trying to see if I get a start sentinel before I go any further with the code.
' {$STAMP BS2p}
' {$PBASIC 2.5}
'This will poll the /RCP pin and when it goes low, it will read the /RDP pin
'Constants
'Variables
timeoutcount· VAR·· Word···· 'counter for timeout
data1········ VAR·· Byte···· 'test data
readnum······ VAR·· Word
'I/O Pins used for card reading
nRCP··· PIN 15·· '/RCP input clock
nRDP··· PIN 14·· '/RDP input data
'Initialize I/O pins
INPUT·· nRCP
INPUT·· nRDP
Main:
··· timeoutcount = timeoutcount + 1
··· IF (timeoutcount = 200) THEN
····· DEBUG "timeout, data1 = "
····· DEBUG DEC data1, CR
····· DEBUG "number of bits read = "
····· DEBUG DEC readnum, CR
····· data1 = 0
····· readnum = 0
··· ENDIF
··· IF (nRCP = 0) THEN
····· timeoutcount = 0
····· readnum = readnum + 1
····· data1 = data1 >> 1
····· data1.BIT6 = nRDP^1
····· IF (data1 = %01010001) THEN
······· DEBUG "start sentinel"
····· ENDIF
··· ENDIF
··· DO
··· LOOP UNTIL (nRCP = 1)
··· GOTO Main
· END
' {$STAMP BS2p}
' {$PBASIC 2.5}
'This will poll the /RCP pin and when it goes low, it will read the /RDP pin
'Constants
'Variables
timeoutcount· VAR·· Word···· 'counter for timeout
data1········ VAR·· Byte···· 'test data
readnum······ VAR·· Word
'I/O Pins used for card reading
nRCP··· PIN 15·· '/RCP input clock
nRDP··· PIN 14·· '/RDP input data
'Initialize I/O pins
INPUT·· nRCP
INPUT·· nRDP
Main:
··· timeoutcount = timeoutcount + 1
··· IF (timeoutcount = 200) THEN
····· DEBUG "timeout, data1 = "
····· DEBUG DEC data1, CR
····· DEBUG "number of bits read = "
····· DEBUG DEC readnum, CR
····· data1 = 0
····· readnum = 0
··· ENDIF
··· IF (nRCP = 0) THEN
····· timeoutcount = 0
····· readnum = readnum + 1
····· data1 = data1 >> 1
····· data1.BIT6 = nRDP^1
····· IF (data1 = %01010001) THEN
······· DEBUG "start sentinel"
····· ENDIF
··· ENDIF
··· DO
··· LOOP UNTIL (nRCP = 1)
··· GOTO Main
· END
Comments
···Please provide more information on the card reader so we may attempt to help you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 7/5/2005 3:05:38 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I think it is the same as the Magtek version which has a pretty goof PDF at
http://www.magtek.com/documentation/public/99875148-6.pdf
If the pulse width for the clock is too narrow, should I use a FIFO to buffer the data first and then manually clock the data in?· If so, do you have any suggestions on a FIFO to use?· Thanks.
·· This doesn't look too complicated.· It looks like when your swipe a card the Card Present line goes low.· At this point you need to start monitoring the Strobe line for transitions (This is the clock line), and for each HIGH to LOW cycle you need to read the state of the DATA line.· A HIGH on the DATA line will be a logic 0, and a LOW will be a logic 1.·
· It would be helpful to know the bit rate (I didn't look it up), as that would tell you if this could be done with a BASIC Stamp.· If it couldn't, an SX chip would most definately work, and could even be done via an ISR and the data buffered.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Also, the sx chip is runs at 50 MHz, but only does 10k instructions/sec, but the p40 is at 20 MHz Turbo (what does the turbo mean?) and runs 12k instructions/sec.· So the SX would still be faster?
Post Edited (skinnydude) : 7/5/2005 4:10:44 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
··· I don't know if you have a loop monitoring the states of those lines if the BS2P40 will be fast enough or not.· I guess you'd need to try it to find out.· I was recently told a BS2 was too slow to read a rotary encoder, but I have the thing working great, and that's considering it has to update the display as I spin the knob.· I had to try it to find out though.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
How do you set the SX chip up as a co-processor with serial interface?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 7/7/2005 6:18:17 PM GMT
http://www.parallax.com/detail.asp?product_id=45181
and getting this just in case I need it
http://www.parallax.com/detail.asp?product_id=45300
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax