beautypg.com

Section 1. decoding reader output – MagTek TTL User Manual

Page 5

background image

1

SECTION 1. DECODING READER OUTPUT

The usual way to gather card data from a TTL (Transistor Transistor Logic) swipe magnetic card
reader is as follows:

1.

Connect the strobe line to an interrupt port on the CPU that is programmed to interrupt on
the falling edge of the strobe.


2.

Connect the data line to an ordinary CPU port pin.


3.

Connect the card present line to another ordinary CPU port pin.


All three of the above signals are quiescently high (V

cc

). When a card is swiped, the first signal to

go low (active) is Card Present. It will go low after 14 to 15 head flux reversals have been read.
These initial strobes are not output on the strobe line. After Card Present goes low, the strobes are
output on the strobe line. Normally, storing data is not begun until the data line goes low (indicating
a one) and the strobe line falls. When this occurs, the CPU starts to store the data in RAM (Random
Access Memory) until the strobes stop because the card has cleared the head. Approximately
150ms later, Card Present returns to V

cc.

When this occurs, the CPU analyzes the data in RAM and

checks for parity errors and LRC (Longitudinal Redundancy Check or check sum) error. If no
errors are detected, the CPU outputs the data in some useful form, such as ASCII (American
Standard Code for Information Interchange) or Keyboard Scan Code.

There are two methods of storing data, one way is to put each character into its own byte in RAM.
The advantage of this method is that it is easy to debug the software. The disadvantages are that
some bits are not used (wasted) and the card can only be read in the forward direction. The second
method is to store all bits from the card into RAM (no unused bits). The only disadvantage to this
method is that it is difficult to debug your software code. The reason being, in the case of Track 2
(5 bits per character), the first byte of RAM has the first character (5 bits) and 3 bits of the second
character. The second byte of ram has 2 bits of the second character, 5 bits of the third character,
and 1 bit from the fourth character, etc. When using In-Circuit Emulation (ICE) to decode the data
in RAM, it is difficult to figure out what you have. Also, with both methods the data is read in
backwards (Least Significant Bit First).

If you run out of interrupts, one way to create another interrupt is to set a counter to all one's. When
the strobe falls, the counter increments causing a counter interrupt which can be used to collect the
data bit and reset the counter to all one's again.