(Part 1 of this article is here; it begins with a magnetic card waveform primer, and then discusses automatic gain control, peak detection including comparator-based peak detection, sample and hold circuits, and using the ADC for peak detection)
Preventing false readings due to noise
Due to the shape of the magnetic card waveform, a comparator- or differentiator-based peak detector can be susceptible to false readings. During each peak, the waveform is changing quickly, which allows the delay imposed on the waveform to create appropriate separation for the comparator to detect the peaks.
However, during the transition between each peak, the waveform changes more slowly, which means very little voltage separation is created between the waveforms. Any noise during this period can cause the comparator to trip and cause an erroneous reading. This noise can (and should) be reduced by proper board layout, bypass capacitor selection, using a low-noise power supply and PGAs, and related techniques; but all noise cannot be completely eliminated.
There are other application-level techniques that can be used to help prevent erroneous readings in the system despite the noise that is present. One technique is to add hysteresis to the comparators. Hysteresis will reduce the likelihood that small noise spikes will cause the comparator to trip. Transitions at the peaks of the waveform will exceed the hysteretic threshold and will still allow the peaks to be detected accurately.
Another useful and effective technique is to employ the use of a window comparator for each channel. The thresholds for the window comparator can be set so the waveform is only checked for peaks when the waveform protrudes outside the set positive and negative thresholds. This prevents any false detection when the waveform is slowly transitioning between peaks.
This method is illustrated in Figure 4 . For an ADC-based peak detector, this method provides an additional bonus because the ADC does not need to sample the waveform while it is inside the window – which reduces the load on the ADC and CPU.
Figure 4: Windowed comparator
(Click on image to enlarge)
A SoC can be a good option for implementing the magnetic card reading methods and techniques discussed in this article if it has all the required resources to implement any of these solutions on a single chip with very few external components. Table 1 summarizes a range of available resources and the function each resource can fulfill in implementing a multi-channel magnetic card reader that provides accurate performance across a variety of different environments and card swipe speeds.
Table 1: This table shows a range of available resources in SoC devices, in this case the PSoC 5 from Cypress, and the functions each resource can serve in implementing a multi-channel magnetic card reader.
(Click on image to enlarge)
About the author
Dan Sweet is a PSoC Applications Engineer at Cypress Semiconductor Corp. He graduated from Western Washington University with a BS in Electrical Engineering Technology.