TECHNICAL REFERENCE MANUAL
Manual Part Number 99875148 Rev-6
DECEMBER 2003
REGISTERED TO ISO 9001:2000 20725 South Annalee Avenue
Carson, CA 90746 Phone: (310) 631-8602 FAX: (310) 631-3956
Technical Support: (651) 415-6800
www.magtek.com
Copyright©1999-2003
MagTek®,Inc.
Printed in the United States of America
Information in this document is subject to change without notice. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of MagTek, Inc.
MagTek is a registered trademark of MagTek, Inc.
REVISIONS
Rev Number
12
3
Date 22 Oct 99 12 Jun 00 24 Jun 02
Notes
Initial Release
Table of Contents corrected; Appendix A, Applications Note, Character Conversion 99875065-2 replaced -1 as update. Sec 1: Updated MagTek Documents.
Sec 4: Corrected Error Checking, Track 2; added Insertion Reader.
Appendix A: Replaced 99875065-2 with –3. Appendix B: Replaced 99821066-8 with –10. Appendix C: Editorial corrections.
Front Matter: Title change; Sec 1, MagTek
Documents, deleted Rev numbers and updated P/N 210065015/16 to /16 only, added 8 manuals to Reference Documents; Sec 2: corrected Error Checking, Track 2, added Insertion Readers; Sec 4: added Insertion Readers subsection; Appendix A:corrected character ]ND and bumped rev; Appendix B: removed DIP IC 15, bumped rev; Appendix C: changed ANSI address, and dimensions on Trks 1, 2, 3.
Editorial and format corrections throughout. Front Matter: added ISO line to logo, changed Tech Support phone number. Sec 2: added note to Figure 2-2.
Appendix C, Standards, Card Data Format – Track 1: extended Data Character line to include Format Code (FC).
406 Aug 02
507 Aug 03
617 Dec 03
ii
TABLE OF CONTENTS
SECTION 1. DECODING READER OUTPUT.............................................................................................1 REFERENCE DOCUMENTS...................................................................................................................2 MAGTEK DOCUMENTS INCLUDED IN THIS MANUAL.........................................................................2 TRACK 1 DATA FORMAT........................................................................................................................3 TRACKS 2 AND 3 DATA FORMAT..........................................................................................................4 SECTION 2. ENCODING.............................................................................................................................7 TIMING...................................................................................................................................................10 DATA......................................................................................................................................................10 STROBE.................................................................................................................................................10 CARD PRESENT....................................................................................................................................10 SECTION 3. LRC CALCULATION............................................................................................................13 SECTION 4. ERROR CHECKING.............................................................................................................15 ERROR CHECKS BY A TYPICAL READER.........................................................................................15 ERROR CHECKING, TRACK 2, WITH AN INTEL 8751........................................................................16 INSERTION READERS..........................................................................................................................18 SECTION 5. BIDIRECTIONAL READING AND AMPLITUDE VARIATIONS..........................................19 READING IN ONE DIRECTION VERSES BOTH DIRECTIONS...........................................................19 CARD READBACK AMPLITUDE VARIATIONS....................................................................................20 APPENDIX A. CHARACTER CONVERSION...........................................................................................21 TRACK 1 CHARACTER SET.................................................................................................................21 TRACK 2 AND 3 CHARACTER SET.....................................................................................................21 APPENDIX B. READ IC 21006516 SPEC SHEET...................................................................................23 APPENDIX C. STANDARDS.....................................................................................................................27 APPENDIX D. CARD READER INTERFACE...........................................................................................29 INTERFACING THE CARD READER TO A MICROPROCESSOR......................................................29 SINGLE - BIT INPUT PROGRAMMING.................................................................................................29 USART....................................................................................................................................................29 DETECTING START SENTINEL............................................................................................................30 BIDIRECTIONAL READING...................................................................................................................30 CONVERTING CARD DATA TO ASCII DATA.......................................................................................30 TRACK 1.................................................................................................................................................30 TRACK 2 & 3..........................................................................................................................................30
FIGURES
Figure 2-1. Bit Cell - Flux Transition-----------------------------------------------------------------------------------------8 Figure 2-2. Card Coding--------------------------------------------------------------------------------------------------------9 Figure 2-3. Timing--------------------------------------------------------------------------------------------------------------10
iii
iv
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 aone) 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
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
Section 1. Decoding Reader OutputTRACK 1 DATA FORMAT
The following is typical for Track 1 data.
The Track 1 data format includes the following items: 1. Approximately 62 leading clocking zeros 2. The Start Sentinel \"%\" 3. Up to 76 alphanumeric characters selected by the user 4. The end sentinel \"?\" 5. The LRC (longitudinal redundancy check character) 6. 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. \"000..00\" leading clocking zeros (approximately 62) 2. \"1010001\" the Start Sentinel \"%\" (1000101) 3. \"1000011\" the character \"A\"* (1100001) 4. \"0010110\" the character \"T\"* (0110100) 5. \"1100100\" the character \"3\" (0010011) 6. \"1111100\" the End Sentinel \"?\" (0011111) 7. \"0011100\" the character \"<\"** (0011100) the LRC (check digit) 8. \"000..00\" trailing clocking zeros (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
I/O Interface for TTL Magnetic Stripe Readers Calculating odd parity and LRC, for the message AT3:
P32168421Hex Value, Decimal Value
Less Parity Less Parity
Start sentinel % 1 0 0 0 1 0 1 05 hex 05 (4+1) A110000121hex 33 (32+1) T011010034hex 52 (32+16+4) 3001001113hex 19 (16+2+1) End sentinel: ? 0 0 1 1 1 1 1 1F hex 31 (16+8+4+2+1) ________________LRC < 0 0 1 1 1 0 0 1C hex 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
Section 1. Decoding Reader Output1. \"00.00\" leading clocking zeros Approximately 22 (tk2) or 62 (tk3) 2. \"11010\" the character \"hex B\" (01011) the Start Sentinel 3. \"10000\" the character \"1\" (00001) 4. \"01000\" the character \"2\" (00010) 5. \"11001\" the character \"3\" (10011) 6. \"11111\" the character \"hex F\" (11111) the End Sentinel 7. \"00100\" the character \"4\" (00100) the LRC (check digit) 8. \"00.00\" trailing clocking zeros A minimum of 22 (Tk2) or 62 (tk3) to the end of the card
Calculating odd parity and LRC for the message 123:
P8421Hex Value Decimal Value
Less Parity Less Parity
Start Sentinel: B 0 1 0 1 1 B 11 (8+2+1) 10000111
2000102231001133(2+1)
End Sentinel: F 1 1 1 1 1 F 15 (8+4+2+1) _____________LRC 4 0 0 1 0 0 4 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
I/O Interface for TTL Magnetic Stripe Readers 6
SECTION 2. ENCODING
There are several schemes used to record or encode ones and zeros in the computer industry. (We use the term record and encode synonymously.) In the card industry the International Organization for Standardization (ISO) has defined F2F as the encoding scheme for cards. F2F stands for frequency - double frequency, or for the purist - two frequency coherent phase recording. F2F encoding provides for self-clocking data. That is, the serial data stream
consisting of one and zero bits provides the timing information for the reader to determine which bit is which.
The key feature of self-clocking data is that the data bits can be extracted from the serial data stream without the need to control the speed of the magnetic media past the encoding head.
Thus, card swipe readers, where a human hand is passing the card through the read slot can work regardless of how fast or slow the card is passing through the slot. Serial data merely means that the one and zero bits, that form the desired characters, are stored on the same track, one bit after the next bit.
F2F is an encoding technique which places flux transitions on the magnetic stripe separated by a defined distance for zero bits and one half that distance for one bits.
The defined distance for Track 1 and Track 3 is 0.0047619 inches for zero bits. This value is the reciprocal of the bit density of Track 1 - 210 bits per inch. For one bits - 0.0023809 (1/2 the zero bit distance.)
The defined distance for Track 2 is 0.013333 inches for zero bits. This value is the reciprocal of the bit density of Track 2 - 75 bits per inch. for one bits - 0.0066665 inches (1/2 the zero bit density.)
Figure 2-1 illustrates this concept.
7
I/O Interface for TTL Magnetic Stripe Readers Figure 2-1. Bit Cell - Flux Transition The encoding device has the responsibility to separate the flux transitions at the proper distance. Variations in the proper distance between flux transitions is what is commonly referred to as jitter. Before the desired information can be stored (encoded) on the card, many things must happen. The information itself (the alphanumeric characters for Track 1 and the numeric characters for Tracks 2 and 3) needs to be coded. That is, the information must be converted to one and zero bits. The one and zero bit code for each character can be found in the Coded Character Set tables in ISO/IEC 7811-2, see Appendix A. These tables define the pattern of the one and zero bits for each character. There is a special bit that is added to each character code for the purpose of error detection. This special bit is called a parity bit. The parity bit is either a zero bit or a one bit depending on whether the number of one bits in the character is an even number or and odd number. The ISO standard has defined that for all tracks odd parity is maintained on each character. This means that if the character has an odd number of one bits in the character code for that character, the parity bit is then a zero bit. On the other hand, if the character has an even number of one bits in the character code for that character, the parity bit is a one bit causing the total number of one bits to be odd. Thus the term odd parity. 8
Section 2. EncodingBefore the first character (or more specifically, the first series of bits that define the desired first character) can be encoded, a Start Sentinel character needs to be encoded. The Start Sentinel is a defined series of bits, which signal the start of the data bits. Track 1 Start Sentinel consists of seven bits (as all characters on Track 1). Track 2 and 3 Start Sentinel consists of five bits (as all characters on Track 2). As an example, the Track 2 Start Sentinel code is: 11010.
After the last data character is encoded, an End Sentinel must be encoded. The End Sentinel is a defined series of bits, which signal the end of the data bits. Immediately after the End Sentinel, a special error checking character is also encoded. This error checking character is called the LRC -Longitudinal Redundancy Check character. For further details see Section 3.
Before the Start Sentinel character and after the LRC character, “clocking bits” are encoded. These clocking bits provide card readers with timing to start their synchronization process before encountering the start sentinel (or end sentinel for reverse reading). Figure 2-2 illustrates the relative location of all the characters previously discussed.
This means that if the character has an odd number of one bits in the character code for that
character, the parity bit is then a zero bit. On the other hand, if the character has an even number of one bits in the character code for that character, the parity bit is a one bit causing the total number of one bits to be odd. Thus the term odd parity.
Figure 2-2. Card Coding Note: In this example, Start Sentinel is Hex B, End Sentinel is Hex F, and LRC is Hex F. Note that as you look at the diagram, while not to scale, the encoded information does travel from right to left along the length of the magnetic stripe. See Appendix A. 9
I/O Interface for TTL Magnetic Stripe Readers TIMING
The timing for Card Present, Strobe, and Data is as shown in Figure 2-3.
CARD PRESENT
DATA 000011100000110 STROBE Bit Time STROBE WIDTH APPROXIMATELY 25-50% OF BIT TIME Notes:
1. Time out of the CARD PRESENT signal occurs approximately 150 ms after the last strobe transition. 2. DATA is valid 1.0µsec before the negative edge of STROBE.
Figure 2-3. Timing
DATA
The Data signal is valid while the strobe is low. If the Data signal is high, the bit is a zero. If the Data signal is low, the bit is a one.
STROBE
The Strobe signal indicates when Data is valid. It is recommended that Data be loaded by the user with the leading edge (negative) of the Strobe.
CARD PRESENT
Card Present will go low after 14/15 flux reversals from the head. Card Present will return high 150 milliseconds after the last flux reversal. 10
Section 2. EncodingWhen no card is being moved through the unit, the Data, Strobe, and Card Present signals are high. The signal timing diagram shown above represents the data along with other signals that are generated during the reading process.
11
I/O Interface for TTL Magnetic Stripe Readers
12
SECTION 3. LRC CALCULATION
The formula for calculating LRC below uses Track 2 as an example. Perform the following: 1. Write the value for each character (see examples below and Appendix A). 2. Do not use the odd parity bit (P) in the formula for calculating LRC calculation. 3. Count the number of one bits in each of the 4 vertical columns. 4. Enter a zero or one in the LRC position so that each vertical column has a even number
of ones (not the parity column {P}). 5. After all 4 vertical columns have their LRC bit affixed, affix odd parity to the LRC
character itself.
Examples: P8421P8421P842101011B
100000111111_______ F
400100Where: 5 \"B\" is the start sentinel \"F\" is the end sentinel The LRC is under the line
B0F
0101110000000011 1 1 1 1 _______1 0 1 0 1
B
012 3F 4
0101110000000010 0 0 1 0 100111 1 1 1 1 _______ 0 0 1 0 0
13
I/O Interface for TTL Magnetic Stripe Readers Calculation of LRC for an encoder, using a Micro Processor (Intel 8751), is as follows:
START:
MOV R2,#0 ;ZERO REGISTER 2 (LRC ACCUMULATOR)
MOV R0,#START_SEN ;POINT AT FIRST CARD CHARACTER (START SENTINEL)
LOOP1:
MOVX A,@R0 ;PUT A CARD CHARACTER INTO THE ACCUMULATOR ANL A,#0FH ;MASK OFF THE PARITY BIT
XCH A,R2 ;EXCHANGE THE ACCUMULATOR & REG 2 XRL A,R2 ;\"EXCLUSIVE OR\" ACC WITH R2
XCH A,R2 ;RUNNING TOTAL OF LRC IS NOW IN REG 2, CARD CHARACTER IN ACC. INC R0 ;POINT AT THE NEXT CHARACTER
CJNE A,0FH,LOOP1 ;COMPARE, JUMP TO LOOP1 IF NOT EQUAL TO A END SENTINEL. ;WHEN THE PROGRAM FALLS THROUGH THE ABOVE INSTRUCTION THE FINAL LRC IS ;IN REGISTER 2, WE CALL THE ODD PARITY ROUTINE TO AFFIX ODD PARITY TO THE ;LRC AND WE ARE READY TO WRITE THE LRC ON A CARD.
14
SECTION 4. ERROR CHECKING
This section describes error checking by a typical single track reader and with and Intel 8751 CPU on a typical Track 2 reader.
ERROR CHECKS BY A TYPICAL READER
The following error checking is performed by a typical card reader: 1. While the card is being swiped no error checking is done. All of the micro processor unit
(MPU) time is being devoted to storing the data being read off the card into memory (RAM). Normally the strobe output from the card reader is connected to an interrupt input on the MPU. The MPU is set so that the interrupt is triggered on the falling edge of the strobe. The data output line from the card reader goes to a normal MPU port input pin. On each Falling edge of the strobe, one bit of data is collected from the data input line and the interrupt routine is exited. The 'Card Present' output from the card reader goes to a normal MPU port Input pin. All outputs from the card reader are quiescently high (Vcc). 2. When 'card present' returns to high again the MPU knows that the card has cleared the
read head and error checking can begin. The MPU now checks each character that it collected in step 1 for the following:
A. Checks to ensure the first character is a 'Start Sentinel'. This will be a hex B (01011)
for Track 2 or Track 3. For Track 1 it will be a percent sign (1000101).
B. Checks each character for odd parity (an odd number of one bits).
C. Updates the LRC total as each character is checked.
D. Checks to see if the current character is an 'End Sentinel' (11111, 0011111). If no
'End Sentinel' is found, this is an error. When the 'end sentinel' is found, the MPU inputs the next character (LRC), checks its parity, and updates the LRC total. It then checks that the LRC total is zero. If it is not zero it is an error.
3. Some readers keep count of the number of characters checked, and if this number
exceeds the maximum allowed, will give an error. The maximum allowed is: track 1 = 79; track 2 = 40; track 3 = 107. 4. If for some reason you do not have enough interrupts available to use the preceding
method, MagTek can provide an application note on how to do it without using
interrupts. This is done by using a \"USART\" for each track along with an MPU. See Appendix D.
15
I/O Interface for TTL Magnetic Stripe Readers ERROR CHECKING, TRACK 2, WITH AN INTEL 8751
Example of error checking in a Track 2 reader, using an Intel 8751 CPU:
;INITAILIZE REGISTERS AND FLAG BITS.
CHECK: MOV R2,#0 ;ZERO REGISTER 2 (LRC ACCUMULATOR) CLR PARITY_FLAG ;CLEAR THE PARITY ERROR FLAG MOV R0,#START_SEN ;POINT AT FIRST CARD CHARACTER IN RAM (START SENTINEL)
;START PARITY AND LRC CHECK (LONGITUDINAL REDUNDANCY CHECK CHARACTER).
CK0: CALL CK1 ;GO TEST A CHARACTER CJNZ A,0FH,CK0 ;COMPARE ACCUMULATOR TO END SENTINEL, GO TO CK0 IF NOT ES ;IF IT'S A END SENTINEL THE PROGRAM DROPS THROUGH CALL CK1 ;GO UPDATE THE LRC CHARACTER MOV A,R2 ;MOVE REGISTER 2 TO THE ACCUMULATOR, GET THE LRC SUM JNZ ERROR ;IF LRC SUM IS NOT ZERO, THIS EQUALS AN ERROR JB PARITY_FLAG,ERROR ;SKIP TO ERROR IF PARITY FLAG IS SET NOP ;IF THIS POINT IS REACHED THE CARD WAS READ CORRECTLY ;END OF TEST
;CK1--LRC SUBROUTINE
;THIS ROUTINE KEEPS THE RUNNING SUM OF THE LRC IN REGISTER 2
CK1: MOVX A,@R0 ;PUT A CARD CHARACTER FROM RAM INTO THE ACCUMULATOR CALL PARITY_CK ;CHECK FOR ODD PARITY MOVX A,@R0 ;GET THE SAME CHARACTER AGAIN ANL A,#0FH ;ZERO THE FIRST 4 BITS, INCLUDING THE PARITY BIT XCH A,R2 ;EXCHANGE ACCUMULATOR AND REGISTER 2 XRL A,R2 ;\"EXCLUSIVE OR\" THE ACCUMULATOR WITH REGISTER 2 XCH A,R2 ;EXCHANGE ACCUMULATOR AND REGISTER 2 INC R0 ;POINT AT THE NEXT CHARACTER RET ;RETURN, AT THIS TIME THE RUNNING LRC IS IN REGISTER 2
16
Section 4. Error Checking;PARITY--PARITY SUBROUTINE
;COUNTS THE NUMBER OF 'ONES' IN THE ACCUMULATOR.
;SETS THE 'PARITY ERROR FLAG' IF IT FINDS A CHARACTER WITH AN EVEN NUMBER OF ONE BITS.
PARITY_CK: MOV R4,#0 ;INITIALIZE THE 'ONES' BIT COUNTER TO ZERO PARITY1: CLR C ;CLEAR THE CARRY
PARITY2: JZ PARITY3 ;SKIP TO PARITY3 IF ACCUMULATOR ZERO, DONE, GO TO PARITY3 RRC A ;ROTATE THE ACCUMULATOR RIGHT, THROUGH THE CARRY JNC PARITY2 ;IF THE CARRY IS 'ZERO', GO TO PARITY2 INC R4 ;OTHERWISE INCREMENT THE '1' COUNTER & GO TO PARITY1 JMP PARITY1 ;GO TO PARITY1 AND CONTINUE
PARITY3: MOV A,R4 ;PUT THE 'ONES' COUNT INTO THE ACCUMULATOR JB ACC.0 PARITY4 ;IF BIT 0 IS A 1 (ODD), CHARACTER IS OK, RETURN SETB PARITY_FLAG ;PARITY IS EVEN, SO SET ERROR FLAG PARITY4: RET ;RETURN
ERROR: ;THE READ ERROR ROUTINE IS ENTERED AT THIS POINT.
17
I/O Interface for TTL Magnetic Stripe Readers INSERTION READERS
While it is possible for the card reader to read data on either the insertion or withdrawal stroke, it should be noted that card reading is most reliable during the card withdrawal stroke. For this reason MagTek recommends that customer’s software be designed to emphasize data capture during the card withdrawal stroke.
For the most reliable operation: 1. Read the card upon insertion. When the card hits the backstop (Card Present will go
high), check the data for errors. 2. If the data contains no errors, output that data, start sentinel first, after the card has been
withdrawn. 3. If an error was detected, clear that data and get ready to read the card again upon
withdrawal. 4. After the card is removed (Card Present will go high), check the data for errors. 5. If no errors are found, output that data, start sentinel first. 6. If an error is detected, indicate to the host that an error was detected, indicate to the
customer to insert the card again.
18
SECTION 5. BIDIRECTIONAL READING AND AMPLITUDE
VARIATIONS
READING IN ONE DIRECTION VERSES BOTH DIRECTIONS 1. The simplest way to read a card is in one direction only, with the Start Sentinel read first.
If this method is chosen, normally each character is stored in one byte of memory. During the debug operation this Is a simple and clear method to see what is happening using 'In Circuit Emulation' (ICE). 2. If reading in both directions is desired, the normal method is to scan the data in the
forward direction and if no errors are found, then the data is sent. If an error is found, then the scan is done in the reverse direction. And if no error is found the data is sent in the forward direction (Start Sentinel first). If an error is found in both directions, then an error is Reported. 3. To be able to process the data in both directions, it is necessary to pack the data into
RAM without any unused bits between characters. In the case of 5 bit data, the first byte will have the first character plus 3 bits of the Second character. The second byte will have 2 bits of the second character, 5 bits of the third character and one bit of the fourth character, etc. With the data not being on byte boundaries, it can be difficult to decode it and especially difficult when looking at the data using ICE. 4. When a card is read in the forward direction, the Start Sentinel is first, and the Start
Sentinel was chosen so that the first bit would be a one. This makes it simple to tell when you have reached the end of leading clocking zeros and the first data bit. It also allows for the first bit to be on a Byte boundary.
When a card is read in the reverse direction, there is no way to tell the boundary between the trailing zeros (which are now acting as the leading zeros) and the LRC character. For example, if the LRC is 1 (00001), then the first one bit will be encountered as the fifth bit of the message, and there is no easy way to tell when the trailing zeros stop and the LRC starts:
B5F1
000000000,11010,10101,11111,10000,00000000
which really looks like this:
0000000001101010101111111000000000000
As you can see if you are scanning right to left, it is not easy to tell where the clocking zeros stop and the message begins.
19
I/O Interface for TTL Magnetic Stripe Readers It is necessary to write a program that will:
1) go through memory, starting from the end that has the start sentinel, and
2) decode the characters (which may be forward or backwards depending on which way the card was swiped and not on a byte boundary), and
3) check for errors then transmit the characters forward back To the host.
Another problem is that the LRC will assume the same value as the Start Sentinel some of the time, and when it does, then the character adjacent to it has to be tested to see if it is an end sentinel. If it is an end sentinel, then this character is an LRC otherwise it is a Start Sentinel. In this way you can make sure which end is really the beginning. See Appendix D, Bidirectional Reading.
CARD READBACK AMPLITUDE VARIATIONS
Causes of readback amplitude variations are as follows:
•Speed of the card - the faster, the more amplitude
•Head contact, head pressure, smoothness of stripe, bumps
•Quality of oxide
•Orientation of oxide (polarization)
•Thickness of oxide
•Type of oxide, low or high coercivity
To check the amplitude variations, connect a scope between ground (pin 5) and drive or gain set (pin 9 or 11), on the F2F read/decode IC. Swipe an encoded card, and check the scope for the variations above.
The waveshape should be similar to Figure 2-1. For pin locations refer to Appendix B, Connection diagram (Pin Outs).
20
APPENDIX A. CHARACTER CONVERSION
TRACK 1 CHARACTER SET Card Data
CharacterSpace !(ND) \"(ND) #(OG) $
%(SS) &(ND) '(ND) ()*(ND) +(ND) ,(ND) -./01234567:(ND) ;(ND) <(ND) =(ND) >(ND) ?(ES) PBBBBBP1 0 0 0 0 0 0 200 0 0 0 0 0 1 210 0 0 0 0 1 0 221 0 0 0 0 1 1 230000100241 0 0 0 1 0 1 251 0 0 0 1 1 0 260 0 0 0 1 1 1 2700010002810010012910010102A00010112B10011002C00011012D00011102E10011112F00100003010100013110100103200100113310101003400101013500101103610101113710110003800110013900110103A10110113B0 0 1 1 1 0 0 3C1 0 1 1 1 0 1 3D10111103E0 0 1 1 1 1 1 3F
ASCII
P
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB
EA22A2AA22AA2A22A3BB3B33BB33B3BB3
O2AA2A22AA22A2AA2B33B3BB33BB3B33B
P
Card Data
B
B
B
B
B
P
ASCII
PCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDD
EC44C4CC44CC4C44C5DD5D55DD55D5DD5
O4CC4C44CC44C4CC4D55D5DD55DD5D55D
TRACK 2 AND 3 CHARACTER SET Card Data ASCII
CharacterPBBBPPEO
01000030B3B10000131BB320001032BB331001133B3B40010034BB351010135B3B61011036B3B70011137BB3P=Parity EP = Even Parity OP = Odd Parity
P0 = Parity bit set to 0 P1 = Parity bit set to 1 SS = Start Sentinel ES = End Sentinel FS = Field Separator
AS = Account Separator (Track 3 only)
ND = Character Not Defined by Credit Card Standards OG = Optional Graphic
P
Card Data
B
B
B
P
ASCII
PBBBBBBBB
EB33B3CBB3
O3BB3B33B
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 99875065-4, 4/03Copyright 2000-2003, Mag-Tek®,Inc
21
I/O Interface for TTL Magnetic Stripe Readers
22
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- 517ttc.cn 版权所有 赣ICP备2024042791号-8
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务