Detecting start sentinel, Bidirectional reading, Converting card data to ascii data – MagTek TTL User Manual
Page 34: Track 1, Track 2 & 3, Registered to iso 9001:2000
I/O Interface for TTL Magnetic Stripe Readers
30
Notes:
1. Card Present, Data, and Strobe are negative true
logic.
2. Card Present goes low after 14-15 head flux
reversals.
3. Card Present returns to high level approximately
150mS after the last flux transition.
4. Data is valid 1.0µS (min.) before the leading
negative edge of strobe and remains valid until
approximately 1.0µS before the next STROBE.
DETECTING START SENTINEL
In some cases, random noise on a blank track
(especially High Coercivity media) may be detected as a
Start Sentinel. If a Start Sentinel is erroneously detected
then parity and/or LRC checking would undoubtedly
indicate that the track, although blank, actually has an
error on it. For this reason, it is suggested that some
number of the leading zeros be included in the detection
of Start Sentinel. The location of the Start Sentinel and
the number of zeros required to synchronize the read
circuitry determine the number of detectable zeros prior
to the Start Sentinel. In the worst case, there may be no
more than four leading zeros on track 2 and no more
than nine on tracks 1 and 3. In other words, the Start
Sentinel on track 2 should be considered as a 9-bit
value: 4 bits of zero and 5 bits of Start Sentinel.
BIDIRECTIONAL READING
In many of today’s magnetic stripe card applications,
reading the card in both directions is necessary.
Programming for bidirectional reading has its own
special requirements. First, the data acquired from the
reader must be treated in memory as a collection of bits
(see note below). Since the direction is not known, the
program must search the bits looking for the Start
Sentinel. If the first character is not the Start Sentinel,
then you must move to the other end of the memory and
begin searching the bits in reverse order for the Start
Sentinel. However, if a Start Sentinel is found, it is
possible that the character is LRC. You may check for
this by determining if the next character is the End
Sentinel. If the next character is the End Sentinel, then
you must move to the other end of memory and begin
searching the bits in the reverse order as discussed
above. The important point is to realize that the LRC
could appear to be a false Start Sentinel.
If the message does not meet the requirements for a
correct recording (the sentinels, party & LRC) then try to
interpret the message in the other direction. The card is
unreadable only after the software has tried both
directions.
Note: For bidirectional reading, a USART cannot be
used to identify the Start Sentinel. The USART must be
programmed to begin capturing data based on the first
binary 1 that is found. Set the word length to one byte (8
bits) and disable parity checking; for track 2, the word
size should be no more than 5 bits.
CONVERTING CARD DATA TO ASCII DATA
The data transmitted or received by the user’s device is
in ASCII. The data encoded on the cards, however, is in
a different format called Card Data. All RS-232 Mag-Tek
equipment automatically converts transmitted and
received data from ASCII to Card Data. The procedure
for converting ASCII to Card Data is described bellow.
TRACK 1
Card data on Track 1 consists of six binary bits and an
odd parity bit for each character. A method for
converting ASCII characters to six-bit Card Data (the
parity bit is not included in the calculation) is to subtract
20h (hex) from the equivalent 0 parity ASCII character
(see Character Conversion Chart). For example, the
ASCII character that represents the percent sign (%) is
25h. Subtract 20h from 25h and the result is 05h, which
represents the six-bit portion of the card data code for
the percent sign. An odd parity bit must be added to the
six-bit portion of the character to complete the Card Data
code. A method for converting card data to ASCII
characters is to remove the parity bit from the Card Data
code, then add 20h to the remaining six-bit portion of the
character. The result will be the 0 parity ASCII character.
TRACK 2 & 3
Card data on Track 2 & 3 consists of four binary bits and
an odd parity bit for each character. A method for
converting ASCII characters to four-bit Card Data (again
the parity bit is not included in the calculation) is to
subtract 30h from the equivalent ASCII character. For
example, the ASCII character that represents the
number 7 is 37h. Subtract 30h from 37h and the result is
07h, which represents the four-bit portion of the card
data code for the number 7. An odd parity bit must be
added to the four-bit portion of the character to complete
the Card Data code. A method for converting card data
to ASCII characters is to remove the parity bit from the
Card Data code, then add 30h to the remaining four-bit
portion of the character. The result will be the 0 parity
ASCII character.
REGISTERED TO ISO 9001:2000
1710 Apollo Court, Seal Beach, CA 90740
Phone: (562) 546-6400, Help Line (651) 415-6800
Fax (562) 546-6301
http://www.magtek.com
P/N 99875063-4, 4/03 Copyright 1997-2003, Mag-Tek