CSE467: Advanced Logic Design

Carl Ebeling, Winter 1999


Lab 5

Interfacing to the Magnetic Stripe Reader

Distributed Feb 10 - Due: Feb 26 
In this lab assignment, you will build an interface circuit for a magnetic stripe reader, and connect this to the the LCD display interface circuit that you designed in Lab 4. The end result will be a circuit that displays the contents of the magnetic stripe when the card is passed through the reader.

We are going to make up for the lost Monday labs by making this assignment an "on your own" assignment.  That is, you can do it whenever you want.  We will be manning the lab during the regular Feb. 10 and 17 Wednesday lab times, and we will add some hours for you Monday lab people.  We hope, however, that by this time you are comfortable with the tools and the Xilinx boards so that you can make progress mostly on your own.

The Magnetic Stripe Reader

The interface to the magnetic stripe reader is very simple as shown below. We have put a DIP connector on the wires so that you can plug it easily into a protoboard. Note that only half the pins are used (1-7).
    DIP              Wires             Card Reader
 __________                        _____________________
|1 GND   14|----------------------|                     |
|2 +5    13|----------------------|                     |
|3 RCP2  12|----------------------|                     |
|4 RDP2  11|----------------------|                     |
|5 CLS   10|----------------------|                     |
|6 RCP1  9 |----------------------|                     |
|7 RDP1  8 |----------------------|_____________________|
|----------|
The attached data sheet describes the interface signals. All these signals are assert-low signals. For example, the CLS signal is asserted low when a card is in the reader.

The card reader sends data serially using paired clock and data signals. The RCP1 and RDP1 signals are the clock and data signals for the first track of the magnetic stripe. RCP2 and RDP2 are for the second track, which you can ignore unless you want an extra challenge. RCP1 is the clock signal whose 1-0 transition is used to indicate when the data on RDP1 should be sampled. Remember that both clock and data signals are asserted low. The datasheet gives example waveforms for these signals.

The question now is what these serial bits read by the card reader mean. To figure this out, we are going to make you do some detective work using the logic analyzer. So this isn't too hard, we will give you some hints about what magnetic stripe cards contain. Once you figure out the format of the serial data coming from the card reader, you should document it and then design a circuit that will take this serial data and pass it along to the LCD display as characters using the protocol you've already designed. When a card is inserted into the card reader, you should clear the display and then display the characters that are read.

You will need to connect three pins (RCP1, RDP1 and CLS) to the XESS board.  You can use the pins 14, 68, and 72 for this.  You will still need a RESET input signal.

Magnetic Stripe Format

Our card readers can read two tracks on the magnetic card stripe. At this point we are concerned only with track #1 (RCP1 and RDP1). Track 1 contains data in a 6-bit alphanumeric format with one parity bit. (See table at the end of this document.) The start of data is signaled by the character '%' (hex 5). The end of data is signaled by the character '?' (hex 1F). This end of data sentinel is followed by a LRC character (Longitududinal Redundancy Check). Each bit of the LRC character represents the parity over that bit position for all the data characters. We won't worry about checking the LRC, which gives an extra dimension of protection against bit errors. Another special character, '^' (hex 3F) is used as a field separator. Track 1 typically has an account number and a name on it.

Using the logic analyzer, look at the clock and data signals data and determine the exact data protocol. (It helps to use a card that has data you might understand!) Document this protocol first, and then design an interface circuit that takes this serial data and converts it to characters that can be sent to the LCD display. The cards have more data than you'll be able to display, so you may want to just display the number or the name.

Hand In: (due Feb. 26)

Turn in the circuit schematics and Verilog for your design along with any documentation that will help us understand it. Have one of us sign off on the front page when you demo the working circuit to us.


ANSI ALPHA Data Format

Used for Track #1 data.
         ------Data Bits-------   Parity
         b1  b2  b3  b4  b5  b6     b7    Character   Function

          0   0   0   0   0   0     1      space (0H) Special
          1   0   0   0   0   0     0        ! (1H)      "
          0   1   0   0   0   0     0        " (2H)      "
          1   1   0   0   0   0     1        # (3H)      "
          0   0   1   0   0   0     0        $ (4H)      "
          1   0   1   0   0   0     1        % (5H)   Start Sentinel
          0   1   1   0   0   0     1        & (6H)   Special
          1   1   1   0   0   0     0        ' (7H)      "
          0   0   0   1   0   0     0        ( (8H)      "
          1   0   0   1   0   0     1        ) (9H)      "
          0   1   0   1   0   0     1        * (AH)      "
          1   1   0   1   0   0     0        + (BH)      "
          0   0   1   1   0   0     1        , (CH)      "
          1   0   1   1   0   0     0        - (DH)      "
          0   1   1   1   0   0     0        . (EH)      "
          1   1   1   1   0   0     1        / (FH)      "

          0   0   0   0   1   0     0        0 (10H)    Data (numeric)
          1   0   0   0   1   0     1        1 (11H)     "
          0   1   0   0   1   0     1        2 (12H)     "
          1   1   0   0   1   0     0        3 (13H)     "
          0   0   1   0   1   0     1        4 (14H)     "
          1   0   1   0   1   0     0        5 (15H)     "
          0   1   1   0   1   0     0        6 (16H)     "
          1   1   1   0   1   0     1        7 (17H)     "
          0   0   0   1   1   0     1        8 (18H)     "
          1   0   0   1   1   0     0        9 (19H)     "

          0   1   0   1   1   0     0        : (1AH)   Special
          1   1   0   1   1   0     1        ; (1BH)      "
          0   0   1   1   1   0     0        < (1CH)      "
          1   0   1   1   1   0     1        = (1DH)      "
          0   1   1   1   1   0     1        > (1EH)      "
          1   1   1   1   1   0     0        ? (1FH)   End Sentinel
          0   0   0   0   0   1     0        @ (20H)   Special

          1   0   0   0   0   1     1        A (21H)   Data (alpha) 
          0   1   0   0   0   1     1        B (22H)     "
          1   1   0   0   0   1     0        C (23H)     "
          0   0   1   0   0   1     1        D (24H)     "
          1   0   1   0   0   1     0        E (25H)     "
          0   1   1   0   0   1     0        F (26H)     "
          1   1   1   0   0   1     1        G (27H)     "
          0   0   0   1   0   1     1        H (28H)     "
          1   0   0   1   0   1     0        I (29H)     "
          0   1   0   1   0   1     0        J (2AH)     "
          1   1   0   1   0   1     1        K (2BH)     "
          0   0   1   1   0   1     0        L (2CH)     "
          1   0   1   1   0   1     1        M (2DH)     "
          0   1   1   1   0   1     1        N (2EH)     "
          1   1   1   1   0   1     0        O (2FH)     "
          0   0   0   0   1   1     1        P (30H)     "
          1   0   0   0   1   1     0        Q (31H)     "
          0   1   0   0   1   1     0        R (32H)     "
          1   1   0   0   1   1     1        S (33H)     "
          0   0   1   0   1   1     0        T (34H)     "
          1   0   1   0   1   1     1        U (35H)     "
          0   1   1   0   1   1     1        V (36H)     "
          1   1   1   0   1   1     0        W (37H)     "
          0   0   0   1   1   1     0        X (38H)     "
          1   0   0   1   1   1     1        Y (39H)     "
          0   1   0   1   1   1     1        Z (3AH)     "

          1   1   0   1   1   1     0        [ (3BH)    Special
          0   0   1   1   1   1     1        \ (3DH)    Special
          1   0   1   1   1   1     0        ] (3EH)    Special
          0   1   1   1   1   1     0        ^ (3FH)    Field Separator
          1   1   1   1   1   1     1        _ (40H)    Special

BCD Data Format

This 4-bit code is used for Track #2.
        --Data Bits--   Parity
        b1  b2  b3  b4   b5    Character  Function

        0   0   0   0    1        0 (0H)    Data
        1   0   0   0    0        1 (1H)      "
        0   1   0   0    0        2 (2H)      "
        1   1   0   0    1        3 (3H)      "
        0   0   1   0    0        4 (4H)      "
        1   0   1   0    1        5 (5H)      "
        0   1   1   0    1        6 (6H)      "
        1   1   1   0    0        7 (7H)      "
        0   0   0   1    0        8 (8H)      "
        1   0   0   1    1        9 (9H)      "
        0   1   0   1    1        : (AH)    Control
        1   1   0   1    0        ; (BH)    Start Sentinel
        0   0   1   1    1        < (CH)    Control
        1   0   1   1    0        = (DH)    Field Separator
        0   1   1   1    0        > (EH)    Control
        1   1   1   1    1        ? (FH)    End Sentinel

ebeling@cs.washington.edu