DS5250 connection to magnetic card reader

Introduction

Cards with coded magnetic strips on the back are often referred to as magnetic cards and are widely used in financial fields such as banking and stored value. Credit cards, ATMs, and debit cards are typical magnetic cards, and some cards also embed smart card chips. Other applications include gift cards, security cards, and room key cards for games, photocopying, and transit. When using the standard ISO format, these cards have a maximum capacity of only 160 bytes and generally cannot store large amounts of data. Compared to smart cards or portable flash memories, magnetic cards have a storage capacity sufficient to support financial and banking applications and are widely used in this area. Moreover, the magnetic card is low in price, relatively reliable, does not require internal power supply, and is relatively easy to read.

This application note describes how to use the DS5250 Secure Microcontroller to interface with a magnetic card reader. The DS5250 was chosen because it has the security and encryption features needed to develop common card readers, such as point-of-sale POS devices.

The magnetic card reader circuit can perform the underlying task of decoding the magnetic stripe magnetic flux into a bit stream. The DS5250 manages top-level tasks: converting these bits into characters, reading and verifying the data.

Hardware and software requirements

Hardware This example uses the DS5250 Evaluation (EV) board (version B) with the following changes:
Removed pull-up resistor (RN2) for port 0
The actual application also requires the following hardware:
Card Reader - MagTek® three-track reader with 3V decoder ASIC; serial number 21030001, G version or newer version ()
Two pull-up resistors (approximately 10kΩ)
Linear regulator (capable of generating 3V to 3.6V from a 5V supply)
Magnetic card for testing (ATM card, credit card, etc.)

Software This example application is written in C and compiled with Keil's μVision® IDE version 2.40a (). The compiled application is loaded into the DS5250 using Maxim's Microcontroller Toolkit (MTK).

Application Details The following sections describe the implementation of the sample application. The full C code can be downloaded from Maxim's FTP site.

Connecting the Card Reader The MagTek reader has five interface pins (including power and ground):
Pin 1 - STROBE
This signal is only used for the reader input. Driven by the host microcontroller, the data bits of the card are output bit by bit, triggering the reset process.
Pin 2 - DATA
This signal is usually the output of the card reader and contains the card data bits of track A/B/C, which are output synchronously by the STROBE signal. In some cases (eg, when a reset is triggered), the signal can be driven by the host microcontroller.
Pin 3 - VDD
The reader's power supply (2.7V to 3.6V).
Pin 4 - GND
Pin 5 - GND
Since the STROBE and DATA pins operate at 3V, the DS5250 cannot be driven directly through the standard port pins. Therefore, instead of port 0 (which operates in open-drain mode), when the DS5250 sets the pin to a tri-state, the signal is pulled up to 3.6V through the resistor. Since the VIH level of the DS5250 port is compatible with 3V I/O levels, the DS5250 can read DATA signals directly from the DATA line (refer to the DS5250 data sheet for details).

The reader operates at 3V; it cannot be powered directly from the DS5250's 5V supply. Since the DS5250 EV kit does not provide 3V supply, a separate linear regulator (for example, the MAX1658) is used to power the reader.

After the first power-on reset, the host microcontroller must reset the card reader before reading the card. Each time a card scan is performed, it must also be reset in order to clear the memory of the internal reader ASIC so that the reader is ready. Receive a new card reading operation.

When resetting the reader, the host microcontroller (for example, the DS5250 in this application note) must drive STROBE and DATA in the following order (refer to the MagTek documentation for exact voltage levels and timing parameters).
Both DATA and STROBE start in a high (idle) state.
Set DATA low.
Keep DATA low, drive STROBE low, then drive high again.
Drive STROBE low again, then release DATA to make it float high.
When DATA is floating high, STROBE is driven low and then driven high again. At this point, the reader is reset and in a low power wait state.
Drive STROBE low and then drive high again. The card reader is "configured" to enable it to be read.
// Generate a long delay for card reset and read intervals.

Void longDelay()
{
Int i, j;

For (i = 1; i < 5; i++) {
For (j = 1; j < 5000; j++) {
;
}
}
}

// Generate a shorter delay (used between STROBE/DATA transitions).

Void delay()
{
Int i;

For (i = 1; i < 1000; i++) {
;
}
}

// Release the DATA line (P0.0) and allow it to float high.

Void dataHigh()
{
P0 |= 0x01;
Delay();
}

// Drive the DATA line (P0.0) low.

Void dataLow()
{
P0 &= 0xFE;
Delay();
}

// Release the STROBE line (P0.1) and allow it to float high.

Void strobeHigh()
{
P0 |= 0x02;
Delay();
}

// Drive the STROBE line (P0.1) low.

Void strobeLow()
{
P0 &= 0xFD;
Delay();
}

Void resetCardReader()
{
dataHigh();
strobeHigh();
longDelay();

dataLow(); // Force DATA low.
longDelay();
strobeLow(); // Drive STROBE low, then high again.
strobeHigh();
strobeLow(); // Drive STROBE low, then release DATA.
dataHigh();
longDelay();

strobeHigh(); // Drive STROBE low and high again two more times
strobeLow(); // to complete the reset and leave the card reader
strobeHigh(); // in the ready state, prepared to scan a card.
strobeLow();
}
Detecting the card reader operation Once the card reader is reset and configured, the card reader operation can be performed. When reading a card, the MagTek reader performs a complete read cycle; no main controller intervention is required. The entire contents of all three tracks A, B, and C in the magnetic strip of the card are stored in the card reader IC. After the card reading cycle is completed, the data can be synchronously output by the main controller bit by bit.

The card reader tells the host when to start reading the card and when to complete the card reading through the handshake cycle.
This cycle begins with STROBE low and DATA floating high (idle state).
When the card reader detects that the magnetic strip has moved past the reader probe, it begins scanning the card. It drives the DATA line low to tell the host to start reading the card.
The host drives STROBE high and then goes low to respond.
The card reader drives DATA high again.
Once the card cycle is complete, the reader drives DATA low again. This operation tells the host that the card reading process has been completed and the card data can be synchronized.
// Wait for the DATA line to be driven low by the card reader.

Void waitForDataLow()
{
Int i = 0xFF;

dataHigh(); // Make sure that DATA is floating high.

While ((i & 1) == 1) {
i = P0;
}
}

....

resetCardReader();
Printf("");
Printf("Waiting for card swipe...");
Printf("");

waitForDataLow(); // DATA low indicates that card swipe has begun.
strobeHigh();
longDelay();
strobeLow();
longDelay();
waitForDataLow(); // DATA low indicates that card swipe is complete.

Page 1 of 2

We are Manufacturer,the leader in Printer Parts & Supply industry. 8 years in printer parts and supplies industry in China.our quality and service are dependable. 

Our products are manufactured in quality certified factory. All parts are extensively tested by quality control experts to ensure high quality. These parts are choice for printer maintenance and repair need. 

Pickup Roller and Pressure Roller busing for HP Laserjet printer, material imported from japan. brand new.100% work well. long life.all parts go through district inspection before shipment.

Thank you and wish you have a good shopping experience!



Pickup Roller&Pressure Roller Bushing

Pickup Rollers,Pressure Roller Bushing,Paper Pickup Roller,Bushing Pressure Roller

Dunhua Office Equipment Co., Ltd. , https://www.dunhuaparts.com