subject: Psoc 5 As A Magnetic Card Reader [print this page] A good Magnetic Card Reader requires reliable and accurate performance across a variety of different environments and card swipe speeds; regardless of the physical condition of the card. There are three essential elements of a magnetic card that must be implemented in order to ensure this performance: (1) automatic gain control (AGC) to automatically adjust the amplitude of the input waveform to maximize dynamic range; (2) accurate peak detection and raw data decoding; and (3)preventing noise in the system from causing erroneous readings.
Using a PGA and an ADC, the input waveform can be measured and scaled to maximize the dynamic range of the system;which will allow a wide range of input waveforms to be detected. This article will also show what techniques can be used to accurately detect peaks in the input waveform to read the essential information from the magnetic card.
Automatic Gain Control
The first essential element of a magnetic card reader is the automatic gain control (AGC), which automatically adjusts the amplitude of the input waveform to maximize the dynamic range of the system. The amplitude of the waveform is highly dependent on the card swipe speed. Faster swipe speeds produce waveforms with peaks of greater amplitude, and slower swipe speeds produce waveforms with peaks of smaller amplitude. The voltage produced by the magnetic read head is small, but can vary by more than 25 dB across all swipe speeds. A fixed gain can be used to bring this voltage to a usable level, but to ensure the signal is at the optimum level at all swipe speeds, AGC is a necessity. During a given swipe, a user will inadvertently change their swipe speed several times. As such, the gain of the circuit should be adjusted throughout the swipe to be sure any changes in signal amplitude are accounted for.
There are two essential components required to implement AGC: an ADC and a PGA. In order to know what gain should be applied to the PGA at any given time, we must know the current amplitude of our input waveform. The ADC can be used to monitor the input signal level and adjust the PGA when needed. If the input signal passes below a set minimum threshold, the gain is increased. If the input signal passes above a set maximum threshold and approaches saturation, the gain is decreased.
Since the peaks of a magnetic card signal are very pronounced, it can be difficult for an ADC to sample the input signal at a high enough rate to ensure the amplitude of the peaks in the waveform are accurately measured. To help reduce the load on the ADC, a peak and hold circuit can be used to hold the amplitude of each peak. The exact time at which the amplitude is sampled is not important, as long as the sampling and updating of the PGA occur regularly.
Peak Detection
In order to decode the data contained within the waveform, the peaks of the input waveform must be detected. This can be done in a multitude of ways, each way having benefits and drawbacks. Constructing a basic peak detection circuit is relatively easy, but creating a peak detector for a magnetic card reader can be difficult for several reasons:
1.The rate of the incoming peaks can vary anywhere from a few hundred bits per second to over 10 kb/s, depending on the swipe speed, card and card channel.
2.The amplitude of the peaks can vary greatly. This can be partially remedied with the use of AGC, but still needs to be considered for precise peak detection.
3.The peaks of the magnetic card waveform are pronounced, but the regions between each peak can be very flat which can cause noise issues in comparator or differentiator based designs.
Conclusion
A SoC can be a good option for implementing the magnetic card reading methods and techniques discussed in this article. A SoC such as Cypress PSoC 5 has all the required resources to implement any of these solutions on a single chip with very few external components.
PSoC 5 Available Resource source Function
Op-Amp: 4 built-in, used as initial gain stage
PGA: 4 built-in, 1x to 50x gain used for AGC
ADC: 2 SAR (1 Msps each @ 12-bits), able to directly sample multiple channels
DAC: 4 current or voltage DAC's. Useful for reference generation for window comparators,or waveform recreation in sample and track peak detection method
Comparator: 4 low offset comparators with optional 10 mV hysteresis and clocked output, 8 additional low-precision comparators available for up to 4 window comparators.
Sample & Hold: 4 clocked sample and hold circuits (if not using PGA)
CPU : ARM Cortex M3, 80 MHz
All of these resources make the PSoC 5 an excellent choice for implementing a multi-channel magnetic card reader that provides accurate performance across a variety of different environments and card swipe speeds. Many of these functions are implemented in the analog subsystem of the PSoC; leaving plenty of resources to manage other portions of the magnetic card system including data analysis, encryption and external communication.