The text of a manual · part 7 of 7
I/O Interface for TTL Magnetic Stripe Readers Technical Reference Manual, pages 31 to 34
Pages 31 to 34 of 34: APPENDIX C. STANDARDS; APPENDIX D. CARD READER INTERFACE
The original document is the PDF (1.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the MagTek 101mm Swipe Reader
Page 31
APPENDIX C. STANDARDS DIMENSIONS ISO 7810
FINANCIAL TRANSACTION CARDS Physical Characteristics of Credit Card Size Document
7811-1
Embossing
7811-2
Magnetic Stripe - Low Coercivity
7811-3
Location of Embossed Characters
7811-4
Location of Tracks 1 and 2
7811-5
Location of Track 3
7811-6
Magnetic Stripe - High Coercivity
7813
Financial Transaction Cards
MAGNETIC STRIPE 2.125"
EMBOSSED INFORMATION
For Copies of Specifications contact:
3.375" 0.030" Thick
AMERICAN NATIONAL STANDARDS INSTITUTE 25 W. 43rd Street, New York, New York 10036 (212) 642-4900
MAGNETIC STRIPE ENCODING
FINANCIAL TRANSACTION CARDS
0.223"
RECORDING DENSITY (bits per inch)
CHARACTER CONFIGURATION (including parity bit)
INFORMATION CONTENT (including control characters)
0.100" Track 1 IATA
210BPI
7 BITS PER CHARACTER
79 APHANUMERIC CHARACTERS
0.100" Track 2 ABA
75BPI
5 BITS PER CHARACTER
40 NUMERIC CHARACTERS
0.100" Track 3 Thrift
210BPI
5 BITS PER CHARACTER
107NUMERIC CHARACTERS
CARD DATA FORMAT - TRACK 1 76 ALPHANUMERIC DATA CHARACTERS SS FC
PAN Primary Account Number (19 digits max.)
FS
NAME Name (26 alphanumeric characters Max.)
FS
ADDITIONAL DATA
DISCRETIONARY DATA
ES LRC
No. of Characters No. of Characters Expiration Date (YYMM) 4 *PVKI 1 Service Code 3 *PVV 4 *CVV or *CVC 3 Some or all of the above fields may be found within the Discretionary Data.
Control Characters:
SS = Start Sentinel FS = Field Separator ES = End Sentinel
% ^ ?
FC = Format Code LRC = Longitudinal Redundancy Check Character
*(PKIV) = PIN Verification Key Indicator *(PVV) = PIN Verification Value *(CVV) = Card Verification Value *(CVC) = Card Validation Code
27
Page 32
I/O Interface for TTL Magnetic Stripe Readers
CARD DATA FORMAT
TRACK 2 37 NUMERIC DATA CHARACTERS
SS
PAN
FS ADDITIONAL DATA
Primary Account Number (19 digits Max.)
DISCRETIONARY DATA
No. of Characters Expiration Date (YYMM) 4 Service Code 3
SS = Start Sentinel
Hex B
;
ES = End Sentinel
FS = Field Separator
Hex D
=
Longitudinal Redundancy Check Character
CARD DATA FORMAT
Hex F ?
ES LRC
No. of Characters *PVKI 1 *PVV or Offset 4 *CVV or CVC 3 Some of the above fields may be found within the Discretionary Data. *(PKIV) = PIN Verification Key Indicator *(PVV) = PIN Verification Value *(CVV) = Card Verification Value *(CVC) = Card Validation code
TRACK 3 (ISO 4909) 104 NUMERIC DATA CHARACTERS
SS
PAN Primary Account Number (19 digits Max.)
FS
USE AND SECURITY DATA No. of Characters Country Code (opt.) 3 Currency Code 3 Currency Exponent 1 Amount Authorized per Cycle 4 Amount Remaining this Cycle 4 Cycle Begin (Validity Date) 4 Cycle Length 2 Retry Count 1 PIN Control Parameters (opt.) 6 Interchange Control 1 PAN Service Restriction 2 SAN-1 Service Restriction 2 Expiration Date (opt.) 4 Card Sequence Number 1 Card Security Number (opt.) 9
ADDITIONAL DATA No. of Characters First Subsidiary Account Number (opt.) Second Subsidiary Account Number (opt.) Relay Marker
1
Cryptographic Check Digit (opt.)
6
Discretionary Data
A Field Separator (FS) must be encoded if an optional field is not used.
SS = Start Sentinel Hex B FS = FS = Field Separator Hex D ES = End Sentinel Hex F
; = ?
FC = Format Code (2 digits) *(PKIV) = PIN Verification Key LRC = Longitudinal Redundancy Check Character
The track formats used in this
This section is derived from P/N 99800004. Copies may be document are based on ISO Standards, however, other obtained from MagTek.
formats may be used. Contact your card issuer for your exact requirements.
28
ES
LRC
Page 33
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 Bit Rate (bits/sec.) 10,500 Character Rate (char/sec.) 1,500 Table 1 data rates @ 50ips
TK2 3,750 750
TK3 10,500 2,100
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.
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 B0 B1 B2 B3 P. The least significant bit is B0. B3 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 B3 B2 B1 B0) or 0Bh (hex).
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
29
Page 34
I/O Interface for TTL Magnetic Stripe Readers 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.
bits) and disable parity checking; for track 2, the word size should be no more than 5 bits.
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.
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.
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.
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.
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
30
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.
REGISTERED TO ISO 9001:2000 20725 South Annalee, Carson, CA. 90746 Phone: (310) 631-8602, Help Line (651) 415-6800 Fax (310) 631-3956 http://www.magtek.com P/N 99875063-4, 4/03 Copyright 1997-2003, Mag-Tek