Appendix d. card reader interface, Interfacing the card reader to a microprocessor, Single - bit input programming – MagTek TTL User Manual

Page 33: Usart

Advertising
background image

29

APPENDIX D. CARD READER INTERFACE


INTERFACING THE CARD READER TO A
MICROPROCESSOR

The Mag-Tek Card Reader may be interfaced to a
microprocessor unit (MPU) in a number of ways.
Selection of the most suitable method will depend on the
system requirements and the MPU capabilities. The two
most common methods are:
1. Single-bit input programming.
2. USART (Universal Synchronous/Asynchronous

Receiver - Transmitter such as NEC 82C51).

SINGLE - BIT INPUT PROGRAMMING

This method of interface does not require any external
chip to implement serial data communication between
the Card Reader and an MPU. This function is done
through a software program that allows the MPU to
transmit and receive data. This process requires some
very time-critical programming. A disadvantage of this
approach is that, while the processor is receiving data
serially, it must totally dedicate itself to the task.
Accurate timing can only be maintained if the program
remains in a tight wait loop without being diverted to
other functions. When programming the MPU, the timing
loops required for receiving data cannot exceed the time
period of the incoming data bits. Table 1 shows the data
rates at card speed of 50 inches per second (ips).

TK1 TK2 TK3

Bit Rate (bits/sec.)

10,500

3,750

10,500

Character Rate (char/sec.) 1,500

750

2,100

Table 1 data rates @ 50ips

USART

The primary advantage of the USART method is that the
MPU is relieved of the critical time-dependent
programming.

The CARD PRESENT signal can be connected to an
input pin on the USART. The DSR input of the USART is
suggested as an input of the CARD PRESENT signal to
the MPU. The serial data input (RXD) of the USART
receives data from the Card Reader. The clock input
(RXC) of the USART is connected to the read STROBE
output of the Card Reader. The USART must be set up
to operate in the synchronous mode with a single sync
character. This sync character must be equivalent to the
Start Sentinel character of the track that is being read.

When reading Track 1, the user may set the parity on
the USART to ON or OFF. If parity is set to Enabled,
then the word size must be set to 6 bits. In this case the
USART checks the character for parity error. If the user
prefers the parity to be checked by the MPU and not the
USART then parity must be set to Disabled and word
size must be set to 7 bits. When reading Track 2 or
Track 3, parity must be set to OFF. This is because data
characters encoded on these two tracks are in 5 bit

words, including parity. The USART is limited to a
minimum word size of 5 bits only when parity is OFF. In
this case, the USART treats the parity bit just like any
other data bit, and the MPU should check for correct
parity on each character.

In operation, the USART remains inactive until it
recognizes the Start Sentinel character. Then it becomes
active and collects the data characters, frames the data,
and presents it to the MPU. (In some applications, this
may not be suitable for reliable Start Sentinel detection;
see the Detecting Start Sentinel discussion below.)

When using either method, after the CARD PRESENT
signal indicates that the card is gone, the MPU should
perform error detection by checking both the parity of
each character and of the Longitudinal Redundancy
Check (LRC) character. To perform the LRC calculation,
each bit of each character excluding the parity bit should
be exclusive ORed with the respective bit of all
characters, including Start Sentinel and End Sentinel.
Exclusive ORing the parity bit of all characters does not
generate the parity bit for the LRC character; it is the
parity bit for the LRC character.

The Start Sentinel and the End Sentinel characters
frame data. The first bits encountered by the Card
Reader are the leading zeros. They indicate to the
Reader the presence of an encoded magnetic stripe
card, and allow the Reader to synchronize itself with the
incoming data bits. The leading zeros are followed by
the Start Sentinel character, which indicates the
beginning of data on a track. The characters following
the Start Sentinel represent the data. The End Sentinel
Character indicates the end of data. After the End
Sentinel is the Longitudinal Redundancy Check (LRC)
character. Trailing zeros follow the LRC and fill the
remainder of the track.

NOTE: Characters are encoded on the magnetic stripe
with the least significant bit recorded first. The Start
Sentinel character on Track 2 is recorded as 11010. The
bit pattern is B

0

B

1

B

2

B

3

P. The least significant bit is B

0

.

B

3

is the most significant bit. P is the parity bit. As

defined in the ANSI x4.16 1983, ODD parity is required.
The conventional representation of the Start Sentinel
would be 01011 (P B

3

B

2

B

1

B

0

) or 0Bh (hex).


Advertising