The text of a manual · part 2 of 7
I/O Interface for TTL Magnetic Stripe Readers Technical Reference Manual: SECTION 1. DECODING READER OUTPUT
Pages 5 to 10 of 34, from I/O Interface for TTL Magnetic Stripe Readers Technical Reference Manual
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 5
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 (Vcc). 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 Vcc. 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.
1
Page 6
I/O Interface for TTL Magnetic Stripe Readers
REFERENCE DOCUMENTS 43-millimeter Compatible, Swipe Reader, Technical Reference Manual, P/N 99875148 90-millimeter Compatible, Swipe Reader, Technical Reference Manual, P/N 99831083 100-millimeter Compatible, Swipe Reader, Technical Reference Manual, P/N 99831012 101-millimeter Compatible, Swipe Reader, Technical Reference Manual, P/N 99821101 Slim Profile Card Guide, Swipe Reader, Technical Reference Manual, P/N 99875147 MT-215, TTL, Half Card Insertion Reader, Technical Reference Manual, P/N 99875009 Model MT-215, TTL, Insertion Reader, Technical Reference Manual, P/N 99875042 IntelliStripe 50 Manual Insertion Reader Tech Reference Manual, P/N 99875079 Model MT-215 TTL, Single or Dual Head, Insertion Reader Technical Reference Manual, P/N 99875113 IntelliStripe 60, TTL Insertion Reader, Technical Reference Manual, P/N 99875135 Petrol (P-Series), TTL, Insertion Readers, Technical Reference Manual, P/N 99875139 Model MT-215, TTL, Single Head, 3-Track, Insertion Reader Technical Reference Manual, P/N 99875157 MAGTEK DOCUMENTS INCLUDED IN THIS MANUAL The following MagTek documents are included as appendices in this manual: Appendix A. Character Conversion, P/N 99875065 Appendix B. Read IC 21006516 Spec Sheet, P/N 99821066 Appendix C. Magnetic Stripe Card Standards, P/N 99800004 Appendix D. Card Reader Interface, P/N 99875063
2
Page 7
Section 1. Decoding Reader Output
TRACK 1 DATA FORMAT The following is typical for Track 1 data. The Track 1 data format includes the following items: 1. 2. 3. 4. 5. 6.
Approximately 62 leading clocking zeros The Start Sentinel "%" Up to 76 alphanumeric characters selected by the user The end sentinel "?" The LRC (longitudinal redundancy check character) Trailing clocking zeros (minimum of 62) to the end of the card
Each data character is in a 7-bit (6 plus parity) alphanumeric format. The data is in the format "parity, 32, 16, 8, 4, 2, 1". Parity is odd (an odd number of "one's" in each character). The character is written "backwards" on the card starting with the least significant digit and ending with the parity bit. The card data format is "1, 2, 4, 8, 16, 32, parity". See Appendix C for ATM and credit card formats. Example: The data message "AT3" is encoded on the card as follows: 1. 2. 3. 4. 5. 6. 7. 8.
"000..00" "1010001" "1000011" "0010110" "1100100" "1111100" "0011100" "000..00" leading clocking zeros the Start Sentinel "%" the character "A"* the character "T"* the character "3" the End Sentinel "?" the character "<"** trailing clocking zeros
(approximately 62) (1000101) (1100001) (0110100) (0010011) (0011111) (0011100) the LRC (check digit) (minimum of 62) to end of the card
*Use capital letters only. **The character "<" is not defined by credit card standards but is a legitimate LRC character. The binary values of all card data can be found in the MagTek publication, Application Note Character Conversion, Part Number 99875065, see Appendix A. See Appendix C for ATM and Credit Card Formats.
3
Page 8
I/O Interface for TTL Magnetic Stripe Readers
Calculating odd parity and LRC, for the message AT3: P
32 16 8 4 2 1
Hex Value, Less Parity
Decimal Value Less Parity
Start sentinel % A T 3 End sentinel: ?
1 1 0 0 0
LRC
0
0 0 0 1 0 1 1 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 1 1 ___________ 0 1 1 1 0 0
05 hex 21 hex 34 hex 13 hex 1F hex ___ 1C hex
05 (4+1) 33 (32+1) 52 (32+16+4) 19 (16+2+1) 31 (16+8+4+2+1) __ 28 (16+8+4)
<
Calculating odd parity: scan each horizontal row and enter a zero or one In the P column so that each row has an odd number of one's. To find the LRC: disregard the parity bits, scan up each vertical column, and make sure that each column has an even number of one's in it. Enter a zero or one in the LRC position, so that it does. If you are using a computer to calculate the LRC, use the "Exclusive OR" function. Next, calculate odd parity for the LRC character, in the horizontal direction. TRACKS 2 AND 3 DATA FORMAT The following is typical for Track 2 and Track 3 data. The Track 2 and 3 data formats include the following items: 1. Leading clocking zeros: Approximately 22 (Track 2) or 62 (Track 3) 2. The start sentinel (hexadecimal "B") 3. Up to 37 (track 2) or 104 (track 3) hexadecimal numeric characters selected by the user 4. The end sentinel (hexadecimal "F") 5. The LRC (longitudinal redundancy check character) 6. Trailing clocking zeros: A minimum of 22 (track 2) or 62 (track 3) to the end of the card Each data character is in a 5-bit (4 plus parity) numeric format. The data is in the format "parity, 8, 4, 2, 1". Parity is odd (an odd number of one's in each character). The character is written "backwards" on the card starting with the least significant bit and ending with the parity bit. The card data format Is "1, 2, 4, 8, parity". Example: The data message "123" is encoded on the card as follows: 4
Page 9
Section 1. Decoding Reader Output
1. "00.00" 2. "11010" 3. "10000" 4. "01000" 5. "11001" 6. "11111" 7. "00100" 8. "00.00" leading clocking zeros the character "hex B" the character "1" the character "2" the character "3" the character "hex F" the character "4" trailing clocking zeros
Approximately 22 (tk2) or 62 (tk3) (01011) the Start Sentinel (00001) (00010) (10011) (11111) the End Sentinel (00100) the LRC (check digit) A minimum of 22 (Tk2) or 62 (tk3) to the end of the card
Calculating odd parity and LRC for the message 123: P
8 4 2 1
Start Sentinel: B 1 2 3 End Sentinel: F
0 0 0 1 1
LRC
0
1 0 1 1 B 0 0 0 1 1 0 0 1 0 2 0 0 1 1 3 1 1 1 1 F ___________ 0 1 0 0 4
4
Hex Value Decimal Value Less Parity Less Parity 11 (8+2+1) 1 2 3 (2+1) 15 (8+4+2+1) __ 4
Calculating odd parity: scan each horizontal row and enter a zero or one In the P column so that each row has an odd number of one's. To find the LCR: disregard the parity bits, scan up each vertical column, and make sure that each column has a even number of one's in it. Enter a zero or one in the LCR position, so that it does. If you are using a computer to calculate the LCR, use the "exclusive or" function. Next, calculate odd parity for the LCR character, in the horizontal direction. The Hex characters are usually displayed in their ASCII equivalent: Hex B as a ";" semicolon, Hex D as an "=" equal sign, and Hex F as a "?" question mark.
5
Page 10
I/O Interface for TTL Magnetic Stripe Readers
6