A method and device for processing signals of a magnetic head of a two-path closed-loop POS machine
Patent Information
- Application Number
- CN202610893335.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-22
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2046-06-22
AI Technical Summary
[0003]为了克服以上不足,本发明的目的在于提供一种双路闭环联动式POS机磁头信号处理方法及处理装置,以解决现有POS机磁头信号处理因采用单链路固定参数架构,存在增益调节易受干扰、基线漂移校正不彻底、无法适应不同刷卡速度与磁条强度、且无闭环联动导致解码成功率低的技术问题
Smart Images

Figure CN122419402B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of financial payment terminal technology, and in particular relates to a dual-channel closed-loop linkage POS machine magnetic head signal processing method and processing device. Background Technology
[0002] Traditional POS machine magnetic head signal processing typically employs a fixed-gain amplification architecture. However, in actual card-swiping applications, due to factors such as differences in the magnetization intensity of different bank card magnetic stripes, domain attenuation of old or damaged cards, varying user swiping speeds (typically 0.1m / s to 2m / s), and environmental stray magnetic fields and electronic interference from the machine body, the induced electromotive force output by the magnetic head can fluctuate significantly. Weak signals are easily overwhelmed by noise, while strong signals are prone to clipping distortion, leading to card reading failures or data errors. To overcome these problems, some existing technologies have introduced automatic gain control (AGC) or baseline compensation mechanisms, but they still have significant drawbacks: First, signal processing and AGC detection share a single link, making AGC detection susceptible to signal noise interference and resulting in gain adjustment misjudgments, especially in scenarios with weak magnetic stripes and fast card swiping, where gain adjustment lags, and signal clipping or noise embedding frequently occurs. Second, baseline compensation uses only a single hardware DC blocking capacitor or a single software correction algorithm, which cannot effectively suppress both static DC offset and dynamic baseline drift simultaneously. When swiping cards continuously or with magnetic stripes... When the card is dirty, baseline drift is difficult to correct quickly, leading to zero-crossing detection errors and subsequent garbled characters during decoding. Third, the AGC gain adjustment parameters and baseline compensation parameters are fixed values, which cannot adapt to complex scenarios with different card swiping speeds (0.1~2m / s) and different magnetic stripe strengths (weak magnetic stripe / strong magnetic stripe), resulting in poor system adaptability. Fourth, the AGC, baseline compensation, and magnetic stripe decoding processes are independent of each other and lack a closed-loop feedback mechanism. When decoding errors occur, the gain and compensation parameters cannot be automatically adjusted, often requiring manual intervention, which seriously affects the stability and practicality of POS card reading. Summary of the Invention
[0003] To overcome the above shortcomings, the present invention aims to provide a dual-channel closed-loop linkage POS machine magnetic head signal processing method and processing device, so as to solve the technical problems of existing POS machine magnetic head signal processing, which adopts a single-link fixed parameter architecture, resulting in easy interference of gain adjustment, incomplete baseline drift correction, inability to adapt to different card swiping speeds and magnetic stripe strengths, and low decoding success rate due to the lack of closed-loop linkage.
[0004] To achieve the above objectives, this application provides the following technical solution: A method for processing magnetic head signals in a dual-channel closed-loop linkage POS machine includes the following steps: Acquisition steps: The original alternating waveform signal output by the magnetic head induction is synchronously acquired through the first signal acquisition channel, and the DC voltage signal representing the amplitude envelope of the original alternating waveform signal is synchronously acquired through the second signal acquisition channel. The first signal acquisition channel and the second signal acquisition channel are physically separated. Gain closed-loop adjustment steps: Based on the peak amplitude of the DC voltage signal acquired by the second signal acquisition channel, determine whether the peak amplitude of the signal is within the preset target amplitude range; if it exceeds the target amplitude range, generate a gain adjustment command to adjust the gain amplification factor of the signal processing front end so that the peak amplitude of the signal falls into the target amplitude range. Baseline dynamic compensation steps: Extract the real-time baseline value from the original alternating waveform signal acquired from the first signal acquisition channel; generate a baseline compensation control signal based on the deviation between the real-time baseline value and the preset target baseline value; and feed the baseline compensation control signal back to the baseline input terminal of the signal processing front end to compensate for signal baseline drift. Speed adaptive decoding steps: Zero-crossing detection is performed based on the compensated original alternating waveform signal. The card swiping speed is calculated according to the time interval between adjacent zero-crossing points. Based on the preset speed level to which the card swiping speed belongs, the gain adjustment strategy in the gain closed-loop adjustment step is executed in a differentiated manner to decode the adjusted signal.
[0005] By constructing a dual-path physically separated signal acquisition architecture, the first channel is dedicated to acquiring the original alternating waveform for data processing and baseline extraction, while the second channel acquires the amplitude envelope through hardware peak detection for gain determination. The two signals are acquired synchronously without interference. Based on this, two independent closed loops are established: a gain closed-loop adjustment loop and a baseline dynamic compensation loop. The gain loop automatically adjusts the front-end amplification factor based on the peak amplitude, ensuring the signal always falls within the preset target amplitude range, avoiding misjudgments and lags caused by noise interference in traditional single-link AGC. The baseline loop extracts the real-time baseline value from the waveform signal and compares it with the target value, feeding it back to the front-end baseline input to cancel drift, overcoming the limitation that a single DC blocking capacitor or software correction cannot simultaneously suppress static and dynamic drift. Furthermore, speed adaptive decoding is introduced, calculating the card-swiping speed through zero-crossing detection and adjusting the gain strategy according to the speed level, forming a closed-loop linkage of "detection—feedback—adjustment—re-detection" throughout the entire processing link. After adopting the solution of this application, the gain adjustment no longer depends on the data channel contaminated by noise, the baseline drift is corrected in real time at the hardware level, and the signal amplitude under different card swiping speeds can be actively adapted, thereby significantly improving the decoding success rate in complex scenarios such as weak magnetic stripes, damaged cards, and fast and slow card swiping, while reducing the system's dependence on manual intervention.
[0006] In some embodiments, the extraction of real-time baseline values in the baseline dynamic compensation step specifically involves: using a sliding window averaging method, selecting a sliding window of a preset length, and judging in real time the difference between the newly entered sampling point and the previous sampling point; when the difference is less than a preset threshold, the sampling point is determined to be a baseline signal, and the average value of the continuously acquired baseline signals within the sliding window is calculated to obtain the real-time baseline value.
[0007] The baseline value is extracted using a sliding window averaging method. Specifically, a fixed-length sliding window is selected. Each time a new sampling point is entered, its difference from the previous point is compared. Only when the difference is less than a preset threshold is it considered a baseline signal. After continuously acquiring baseline points of the window length, the average value is calculated as the current real-time baseline value. This method effectively eliminates interference from abrupt changes in the effective signal, resulting in a purer and more stable baseline value. This provides an accurate basis for subsequent DAC feedback compensation, avoids zero-crossing detection errors caused by baseline misjudgment, and ultimately reduces decoding garbled characters.
[0008] In some embodiments, the gain adjustment strategy in the gain closed-loop adjustment step is executed differently according to the preset speed level to which the card swiping speed belongs. Specifically, it includes: when the card swiping speed is in the low speed level, a strategy is adopted that allows the gain to increase rapidly, the target amplitude range is adjusted up to the first preset range, and the clipping warning threshold is relaxed; when the card swiping speed is in the high speed level, a strategy is adopted that prohibits the increase of gain, the target amplitude range is adjusted down to the second preset range, and the clipping warning threshold is tightened.
[0009] The system employs a differentiated gain adjustment strategy based on the card swiping speed. At low speeds, it allows for a rapid increase in gain and adjusts the target amplitude range upwards to the first preset range, while simultaneously relaxing the clipping warning threshold. This ensures that weak signals are sufficiently amplified and less likely to be drowned out by noise. At high speeds, it prohibits increasing gain and lowers the target amplitude range to the second preset range, while tightening the clipping warning threshold to prevent the signal from momentarily peaking and causing clipping distortion. This two-way differentiated strategy allows the system to achieve a sufficient signal-to-noise ratio at low speeds and retain ample dynamic margin at high speeds, significantly expanding the effective card swiping speed range.
[0010] In some embodiments, the speed range of the low-speed gear is less than the first speed threshold, and the speed range of the high-speed gear is greater than the second speed threshold and less than the third speed threshold; the method also includes an overspeed determination step: when the card swiping speed is greater than or equal to the third speed threshold, the card swiping is directly determined to be invalid and the decoding is terminated.
[0011] Building upon the speed-based tiered system, an overspeed detection mechanism is introduced. Specifically, the low-speed tier is defined as being below a first speed threshold, and the high-speed tier is defined as being above a second speed threshold but below a third speed threshold. When the card-swiping speed reaches or exceeds the third speed threshold, the system directly determines the card swipe to be invalid and terminates decoding, without performing gain adjustment or signal decoding. This mechanism avoids wasting processing resources on severely distorted signals caused by extremely fast card swipes, while also preventing invalid data from being incorrectly decoded and output, thus enhancing the system's robustness and response efficiency.
[0012] In some embodiments, before the acquisition step, an initialization threshold setting step is further included: setting a noise threshold for triggering entry into card swiping mode, a target amplitude range for maintaining signal quality, a clipping warning threshold for performing gain reduction operation in advance, and an end threshold for determining the end of card swiping.
[0013] An initialization threshold setting step was added before signal acquisition, specifically setting four types of key thresholds: a noise threshold for triggering the card swiping mode, a target amplitude range for maintaining signal quality, a clipping warning threshold for early execution of gain reduction operation, and an end threshold for determining the end of card swiping. By pre-setting these thresholds, the system can accurately distinguish between standby noise and valid card swiping signals, avoiding false triggers; it can provide early warning and reduce gain before the peak value is about to exceed the safety limit, preventing clipping distortion; and it can promptly exit the decoding state after the card is removed, avoiding invalid decoding of noise. These thresholds together constitute a complete signal state machine, ensuring stable operation of the system under various boundary conditions.
[0014] In some embodiments, the gain adjustment step of generating a gain adjustment command specifically involves: increasing the gain amplification factor step by step when the peak amplitude of the signal is lower than the lower limit of the target amplitude range; and decreasing the gain amplification factor step by step when the peak amplitude of the signal is higher than the upper limit of the target amplitude range.
[0015] The generation logic of the gain closed-loop adjustment command has been refined: when the peak amplitude is below the lower limit of the target range, the gain is increased step by step; when it is above the upper limit, the gain is decreased step by step. This step-by-step adjustment method avoids the impact of sudden gain changes on the waveform, allowing the signal amplitude to smoothly converge to the target range. At the same time, in conjunction with the clipping warning threshold, the gain reduction action can be initiated before the peak value approaches the upper limit, thereby maintaining the continuity and decodeability of the waveform during the card swiping process where the signal changes drastically.
[0016] In some embodiments, the first signal acquisition channel and the second signal acquisition channel share a sampling clock and a start trigger signal to ensure that the signals acquired by the two channels are synchronized in time.
[0017] The first and second signal acquisition channels share the same sampling clock and trigger signal. This synchronization mechanism ensures that both ADCs sample and hold and perform analog-to-digital conversion on their respective front-end analog signals simultaneously, resulting in strict time alignment between the original waveform acquired by the data channel and the amplitude envelope acquired by the peak channel, eliminating any time phase deviation. Consequently, the gain adjustment made by the system based on the peak amplitude can be precisely applied to the corresponding waveform segment, avoiding over- or under-adjustment of gain due to timing misalignment.
[0018] In some embodiments, the step of extracting the real-time baseline value from the original alternating waveform signal acquired from the first signal acquisition channel further includes: performing IIR filtering and digital low-pass filtering on the original alternating waveform signal to obtain the desired effective signal.
[0019] The baseline extraction step incorporates IIR filtering and digital low-pass filtering. Even after DC blocking and amplification, the original alternating waveform signal may still retain high-frequency noise or glitches. IIR filtering and digital low-pass filtering further smooth the signal, eliminating high-frequency components unrelated to the magnetic stripe data, thus obtaining a cleaner, more effective signal. This provides a more reliable waveform basis for subsequent zero-crossing detection and speed calculation, significantly improving decoding accuracy, especially in harsh environments with motor interference or power supply ripple.
[0020] In some embodiments, the formula for calculating the card swiping speed is: V = (preset magnetic strip length) / (interval between two zero crossings), where the preset magnetic strip length corresponds to the physical distance between two adjacent magnetic flux reversal source points on the magnetic strip.
[0021] A specific formula for calculating card swiping speed is provided, correlating the time interval between two adjacent zero-crossing points with the physical distance between two adjacent flux reversal source points on the magnetic stripe. Using this formula, the system can directly calculate the instantaneous speed from the waveform without additional sensors, achieving deep integration of speed detection and magnetic head signal processing. The calculated speed value is not only used for the aforementioned speed-level gain adjustment but also serves as a basis for judging the validity of card swiping, making the entire adaptive processing process more precise and intelligent.
[0022] Another aspect of this application provides a POS machine magnetic head signal adaptive processing device based on a dual-path architecture and closed-loop linkage, characterized in that it is used to perform any of the above methods. Attached Figure Description
[0023] Figure 1 This is a flowchart of the dual-channel closed-loop linkage POS machine magnetic head signal processing method of the present invention; Figure 2 This is a structural block diagram of the POS machine magnetic head signal adaptive processing device based on dual-path architecture and closed-loop linkage of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments and the accompanying drawings. It should be understood that these descriptions are merely exemplary and not intended to limit the scope of the invention. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.
[0025] This invention provides a dual-channel closed-loop linkage method for processing magnetic head signals in a POS machine.
[0026] The method begins with the data acquisition step. Specifically, the magnetic head module outputs a weak bipolar alternating pulse signal when it senses the magnetic stripe card passing through. This signal first passes through a DC blocking capacitor, physically isolating the DC component. Subsequently, the signal is fed into a programmable gain amplifier (PGA) for differential amplification and fixed to a reference baseline. The amplified signal is then split into two completely independent paths. The first path, after low-pass filtering, is fed into the MCU's first ADC; this channel is dedicated to acquiring the original alternating waveform signal for subsequent baseline extraction and decoding. The second path is fed into a peak detector circuit, which converts the signal's amplitude envelope into a DC voltage, which is then fed into the MCU's second ADC. These two acquisition channels are physically separated on the circuit board, each with independent routing, and do not interfere with each other. Notably, the two ADCs share the same sampling clock and trigger signal, ensuring that they sample the signal at the same time, eliminating any time discrepancies.
[0027] After signal acquisition, the system performs gain closed-loop adjustment and baseline dynamic compensation steps either before, after, or in parallel.
[0028] Gain closed-loop adjustment steps: The MCU reads the DC voltage acquired by the second ADC, which directly reflects the peak amplitude of the current magnetic head signal. The MCU pre-stores a target amplitude range, for example, set to 40% to 65% of full scale. The system continuously checks whether the current peak amplitude falls within this range. If the peak amplitude is below the lower limit of the range, the signal is too weak, and the MCU generates a gain increase command, sending it to the PGA to increase its amplification factor. Conversely, if the peak amplitude is above the upper limit of the range, the signal is too strong and there is a risk of clipping, and the MCU generates a gain decrease command to reduce the PGA's amplification factor. This adjustment process is performed step-by-step, changing only one level at a time, allowing the signal amplitude to smoothly approach the target range. In this way, the entire gain adjustment forms a closed loop: amplitude detection → deviation judgment → gain adjustment → re-detection, requiring no manual intervention.
[0029] It is worth noting that this application also includes a clipping warning mechanism, which differs from the conventional gain adjustment described above. Conventional gain adjustment only performs a step-by-step gain reduction operation after detecting that the signal peak exceeds the upper limit of the target amplitude range (e.g., 65% of full scale). However, the clipping warning mechanism sets a warning threshold (e.g., 75% of full scale) higher than the upper limit of the target amplitude range. Its function is to issue a warning and initiate rapid gain reduction before the signal peak reaches the truly dangerous clipping point. Specifically, when the DC voltage output by the peak detection circuit continuously approaches or exceeds this warning threshold, the MCU immediately generates a gain reduction command. This command can skip the conventional step-by-step reduction process and directly reduce the gain across levels (e.g., from 32 times to 4 times), thus completing the gain adjustment before clipping occurs and preserving the waveform integrity to the maximum extent. Furthermore, this application also sets a forced protection threshold (e.g., 85% of full scale). If the peak continues to rise and reaches this threshold, the system immediately forces the gain to the lowest level to ensure that the waveform is not completely clipped. By employing this tiered early warning system combined with a progressive and cross-level gain reduction strategy, this application can effectively avoid data loss caused by clipping distortion in extreme scenarios such as high-speed card swiping or strong magnetic stripes.
[0030] Baseline dynamic compensation steps. In actual circuits, due to factors such as temperature changes and ground noise, the baseline of the signal output by the PGA will drift, causing the overall signal to deviate from zero. This method extracts the real-time baseline value from the raw waveform signal acquired by the first ADC. The extraction method is the sliding window averaging method: a sliding window of fixed length is selected, and each time a new sampling point is entered, the difference is compared with the previous sampling point. If the difference is very small, it indicates that it is not a valid signal transition, and the point is determined to be the baseline point; after continuously collecting baseline points of the window length, the average value is calculated as the current real-time baseline value. After obtaining the real-time baseline value, the MCU compares it with the preset target baseline value (e.g., the expected baseline corresponding to a reference level of 1.65 volts) and calculates the deviation. Based on this deviation, the MCU adjusts the output voltage of the internal DAC, which is directly fed back to the baseline control terminal of the PGA to cancel out the drift. Thus, real-time baseline correction is achieved at the hardware level.
[0031] Finally, there is the speed-adaptive decoding step. After baseline correction, the system obtains a clean and valid signal. The MCU performs zero-crossing detection on this signal, that is, finds the moment when the waveform crosses the zero level. The time interval between two adjacent zero-crossings is recorded as T. According to the magnetic stripe encoding rules, the physical distance between two adjacent flux reversal source points is known, for example, about 0.1-2 millimeters. From this, the current card-swiping speed V can be calculated as this physical distance divided by the time interval T. After obtaining the speed, the MCU compares this speed with several internally preset speed levels. Depending on the speed level, the system adopts different gain adjustment strategies. For example, when swiping at low speed, a strategy of rapidly increasing gain, raising the target amplitude range, and widening the clipping warning threshold is adopted; when swiping at high speed, the opposite is true: further increasing gain is prohibited, the target amplitude range is lowered, and the clipping warning threshold is tightened. Then, the adjusted signal is subjected to conventional magnetic stripe decoding to output the card number data. In this way, through the coordinated work of dual-channel separate acquisition, dual closed-loop adjustment, and speed adaptive processing, the entire processing process forms a closed-loop linkage of "detection-feedback-adjustment-re-detection", which significantly improves the decoding success rate under complex card swiping conditions.
[0032] Next, this application further specifies the specific method for extracting real-time baseline values in the baseline dynamic compensation step.
[0033] This method employs a sliding window averaging approach. A sliding window of a preset length is selected, for example, window length N is 10. Each time a new sampling point is entered, the system compares its difference with the previous sampling point. If the difference is large, it indicates that the point represents a transition edge of a valid signal, and the system immediately discards this point and clears the current window to start the selection process again. Only when the difference is less than a preset threshold is the system determined that the sampling point is a baseline signal and then placed into the window. When the number of continuously acquired baseline signals within the window reaches the window length, the system calculates the arithmetic mean of these baseline points; this average is the real-time baseline value at the current moment. Preferably, the window length can be dynamically adjusted according to the actual noise level. When the noise is high, the window length can be appropriately increased to obtain a smoother baseline; when the noise is low, the window length can be decreased to improve the response speed. Alternatively, an exponentially weighted moving average method can be used as an alternative, which can also effectively filter out interference from signal abrupt changes in baseline extraction.
[0034] This application specifies the details of the gain adjustment strategy implemented based on the differences in card swipe speed levels.
[0035] The system internally divides card-swiping speeds into low-speed and high-speed levels, each with its own configured strategy. When a low-speed swipe is detected, the system takes the following actions: it allows for rapid gain increases, with each adjustment step size potentially doubling the standard step size without delay; simultaneously, it raises the target amplitude range from the default 40% to 65% to a higher first preset range, such as 50% to 70%; furthermore, it widens the clipping warning threshold from the default 75% to approximately 85%. When a high-speed swipe is detected, the strategy is completely reversed: the system prohibits any gain increases, locking the current gain; it lowers the target amplitude range to a lower second preset range, such as 30% to 50%; and the clipping warning threshold is tightened to approximately 65%. This differentiated design ensures that weak signals are sufficiently amplified at low speeds and effectively prevents clipping distortion at high speeds.
[0036] This application further defines the specific range of speed gears and the overspeed determination steps.
[0037] Specifically, the low-speed range is defined as a speed less than a first speed threshold, which can be set to 2 centimeters per second. The medium-speed range (i.e., the normal valid card-swiping range) is 2 to 30 centimeters per second. The high-speed range is defined as greater than a second speed threshold (e.g., 30 centimeters per second) and less than a third speed threshold (e.g., 50 centimeters per second). When the card-swiping speed calculated by the system reaches or exceeds the third speed threshold (i.e., 50 centimeters per second), the card swipe is directly deemed invalid, and the decoding process is immediately terminated. At this time, the system no longer performs any gain adjustment actions, nor does it decode subsequent signals. Preferably, the system can also output a "card swipe too fast" prompt message to guide the user to swipe the card again at a normal speed. This overspeed determination mechanism effectively avoids wasting processing resources on severely distorted signals and prevents the generation of erroneous data.
[0038] This application defines the initialization threshold setting step prior to the data acquisition step.
[0039] Before each card swipe, the system first initializes and sets threshold parameters. These thresholds include: a noise threshold, set to 3% to 8% of full scale (e.g., approximately 165 millivolts), used to distinguish between standby background noise and the actual card swipe signal. The system only considers card swiping to have started and enters card swiping mode when the peak detector output voltage exceeds this value. A target amplitude range, as mentioned above, is set to 40% to 65% of full scale to maintain signal quality. A clipping warning threshold, set to approximately 75% of full scale, is used to predict signal peak values and initiate gain reduction when they approach this value, thus preventing actual clipping. A card swipe end threshold, set to 2% to 5% of full scale, is used when the peak detector voltage remains below this value for a period of time, indicating that the card has left the read / write head, immediately stopping decoding and exiting card swiping mode. Through this set of thresholds, the system constructs a complete signal state machine, ensuring stable operation under various boundary conditions.
[0040] This application defines the specific logic for generating gain adjustment instructions in the gain closed-loop adjustment step.
[0041] When the system determines that the peak signal amplitude is below the lower limit of the target amplitude range, the MCU generates instructions to gradually increase the gain. Each adjustment increases the PGA gain by one level, for example, from eight times to sixteen times. Conversely, when the peak amplitude is above the upper limit of the target amplitude range, the MCU generates instructions to gradually decrease the gain, decreasing it by one level each time, for example, from sixteen times to eight times. It is worth noting that this gradual adjustment method avoids the impact of sudden gain changes on the waveform, allowing the signal amplitude to smoothly converge to the target range. In practical applications, it can also be combined with a clipping warning threshold for even faster response: if the peak value rises sharply within a very short time and approaches the clipping warning threshold, the MCU can skip the conventional gradual reduction process and directly reduce the gain by one level, for example, from thirty-two times to four times, to prevent clipping distortion as quickly as possible.
[0042] Preferably, this application defines a synchronization mechanism between the first signal acquisition channel and the second signal acquisition channel.
[0043] The two signal acquisition channels share the same sampling clock source, generated by an internal timer of the MCU. Simultaneously, the start-conversion trigger signal for both ADCs is also the same signal, issued uniformly by the MCU at the beginning of each sampling period. In this way, both channels sample and hold their respective front-end analog signals and initiate analog-to-digital conversion simultaneously. Therefore, the raw waveform acquired by the data ADC and the amplitude envelope acquired by the peak ADC are strictly aligned in time, with no time phase deviation. This has the advantage that the gain adjustment command made by the system based on the peak amplitude can accurately apply to the corresponding waveform segment that generated the peak, preventing over- or under-adjustment of gain due to timing misalignment. Preferably, the two ADCs can also be synchronously calibrated before the start of each sampling period to further eliminate minor offsets introduced by device differences.
[0044] Preferably, this application adds filtering processing to the step of extracting real-time baseline values.
[0045] Specifically, after acquiring the raw alternating waveform signal from the first signal acquisition channel, the system first performs IIR filtering (Infinite Impulse Response Filtering) on the signal. The coefficients of the IIR filter can be pre-designed according to the actual noise spectrum. For example, a second-order Butterworth low-pass filter structure can effectively filter out high-frequency noise higher than the magnetic stripe signal frequency. After IIR filtering, the signal is then smoothed by a digital low-pass filter. These two filters are used in series to significantly eliminate noise components unrelated to the magnetic stripe data, especially interference from the motor, buttons, power ripple, etc. The resulting effective signal waveform is cleaner and smoother, providing a reliable basis for subsequent zero-crossing detection and speed calculation. It is worth noting that the cutoff frequency of the filter needs to be dynamically adjusted according to the card swiping speed range. At low speeds, the cutoff frequency is appropriately lowered to suppress more noise, while at high speeds, the cutoff frequency is increased to preserve the high-frequency details of the signal.
[0046] The specific formula for calculating the card swiping speed mentioned above.
[0047] The formula for calculating the card swiping speed V is: V equals the preset magnetic stripe length divided by the time interval between two zero-crossing points. Here, the preset magnetic stripe length corresponds to the physical distance between two adjacent magnetic flux flipping source points on the magnetic stripe. Taking a common magnetic stripe card as an example, the total length of the data bits on the entire magnetic stripe is approximately 2.54 centimeters, containing 210 data bits. Therefore, the physical distance between two adjacent data bits (corresponding to two adjacent magnetic flux flips) is approximately 2.54 divided by 210, or about 0.12 millimeters. The system obtains the time interval T (in seconds) between two adjacent zero-crossing points through zero-crossing detection, and then V equals 0.12 millimeters divided by T. This speed value can be directly output in millimeters per second. Using this formula, the system does not require an additional speed sensor; it can accurately calculate the instantaneous card swiping speed using only the magnetic head signal itself, achieving a high degree of integration between speed detection and signal processing.
[0048] The above scheme is illustrated below with a set of specific parameter examples, but the scope of protection of this invention is not limited thereto.
[0049] Assume the system uses a single 3.3V power supply and the PGA has a built-in 1.65V bias. Set the following thresholds during the initialization phase: Noise threshold: Set to 3%-8% of full scale, for example, 165mV. This threshold is used to distinguish between standby noise and valid card swipe signals, preventing noise from being amplified and causing false triggering when the PGA is at high gain.
[0050] Target amplitude range: Set to 40%-65% of full scale, i.e., 1.32V-2.145V. AGC gain adjustment will be activated if the voltage exceeds this range.
[0051] Clipping warning threshold: set to 75% of full scale, i.e., 2.475V. When the peak value approaches this value, the system will reduce the gain in advance to prevent clipping.
[0052] Forced protection threshold: set to 85% of full scale, i.e. 2.805V. Once exceeded, the gain is forcibly pulled down to the lowest level (e.g., 1× or 2×, where 1× and 2× are the gain factors of the programmable gain amplifier (PGA).
[0053] Card swipe termination threshold: Set to 2%-5% of full scale, for example, 132mV. If the peak value remains below this value, the card swipe is considered terminated, and decoding stops.
[0054] Dual-channel ADC synchronous acquisition: Data ADC_1 continuously acquires the original waveform at a higher sampling rate, while peak ADC_2 synchronously acquires the amplitude envelope. Both channels share a sampling clock and a start trigger signal to ensure time alignment.
[0055] Example of gain closed-loop adjustment: When the peak ADC_2 detects 0.165V < peak value < 1.32V, the gain is amplified step by step (e.g., step size × 2, no delay). When 2.145V < peak value < 2.475V, decrease the gain step by step; When the peak value is ≥ 2.475V but < 2.805V, skip the step-by-step process and directly reduce the gain by skipping levels (e.g., 16×→4×). When the peak value is ≥ 2.805V, the gain will be immediately forced to the lowest level.
[0056] Example of baseline dynamic compensation: A sliding window averaging method is used, with a window length of N=10. Each new sampling point is compared with the previous point: if the difference is large (effective signal abrupt change), the window is cleared and a new point is selected; if the difference is less than a threshold, it is determined as a baseline point and added to the window. After continuously sampling 10 baseline points, the average is calculated to obtain the real-time baseline value. The target baseline is set to 1.75V (where Vref=1.65V, and the initial DAC output voltage is denoted as VDAC_init = 0.1V, i.e., target baseline = Vref + VDAC_init = 1.65V + 0.1V = 1.75V). If the real-time baseline drift increases by 50mV, the DAC output voltage is adjusted downwards by 0.05V from its initial value, resulting in an adjusted output voltage of 0.05V (i.e., the current DAC output voltage VDAC_new = VDAC_init - 0.05V = 0.1V - 0.05V = 0.05V), which is fed back to the PGA baseline to offset the drift.
[0057] Speed-adaptive decoding example: The magnetic stripe card has a total length of 2.54cm and contains 210 data bits. The distance between adjacent magnetic flux flipping source points is approximately 0.12mm. The zero-crossing detection determines the interval T between two zero-crossing points; therefore, the card-swiping speed V = 0.12mm / T. The speed levels are divided as follows: Low speed: v < 2 cm / s; Medium speed: 2 cm / s ≤ v ≤ 30 cm / s; High speed: 30 cm / s < v < 50 cm / s; Overspeed: v ≥ 50 cm / s (directly deemed invalid, decoding stopped); Differentiated gain strategy: Low speed mode: Allows rapid gain increase (steps ×2, no delay), significant delay for gain decrease, target amplitude range is increased to 50%-70% of full scale, clipping warning is relaxed to 85%, and the upper limit of gain is increased to 64×.
[0058] Medium speed: Default rules, gain increase delay 3-5ms, gain decrease immediate, target range 40%-65%, step size ×2, only decreases and does not increase after entering the data area.
[0059] High-speed mode: Increase gain is prohibited, decrease gain for extremely fast response (no delay, decrease across levels), target range is lowered to 30%-50%, clipping warning is tightened to 65%, and forced protection triggers immediately pull to the lowest gain.
[0060] Overspeed mode: Stops AGC adjustment, stops decoding, and PGA maintains the current gain.
[0061] By implementing the above specific parameters, the decoding success rate can be increased from approximately 85% of the existing technology to over 99% in scenarios such as weak magnetic stripes, damaged cards, and fast / slow card swiping, without the need for manual intervention.
[0062] Another application provides a POS machine magnetic head signal adaptive processing device based on a dual-path architecture and closed-loop linkage.
[0063] The device includes a magnetic head module, a DC blocking capacitor, a programmable gain amplifier (PGA), a low-pass filter circuit, a peak detection circuit, and an MCU (microcontroller) containing at least two ADC channels and one DAC channel. Specifically, the magnetic head module acquires the magnetic stripe signal and outputs a weak bipolar alternating pulse. This pulse is then blocked by the DC blocking capacitor to achieve hardware isolation of the DC component (including DC offset), resulting in a clean AC signal. The PGA differentially amplifies the DC-blocked magnetic head signal to a suitable level and fixes it to a reference baseline. The PGA output is split into two circuits, which process the signal and send it to the MCU's ADC for sampling: one circuit performs low-pass filtering to retain the magnetic head baseline and valid signal, connecting to the MCU's first ADC input (data ADC_1); the other circuit uses a peak detection circuit to detect the peak value of the signal waveform, connecting it to the MCU's second ADC input (peak ADC_2).
[0064] The reason for using a separate hardware peak detection channel (second channel) instead of the traditional method of calculating the peak value from the acquired signal using software is because the magnetic head signal has the following fatal flaw: ① The card swiping speed is not fixed, which causes the signal frequency to vary greatly - only a few kHz when swiping slowly, and tens of kHz when swiping fast. The signal has jitter, pauses and frequency jumps. To accurately capture the peak, the ADC must sample at high speed throughout, which puts a lot of pressure on the CPU power consumption and utilization. ② The magnetic head signal is narrow, sharp, and transient, with the peak value often lasting only a few microseconds. Software detection of the peak value can easily miss a few peak values, resulting in card reading failure. ③ The ADC used for data detection should focus on waveform fidelity, emphasizing zero-crossing, 0 / 1 identification, and decoding. Its priority is waveform fidelity, not amplitude. Therefore, a hardware peak detection circuit must be used to detect the peak value of the signal waveform as the basis for adjusting the gain.
[0065] The MCU's DAC output is connected to the PGA's baseline control terminal for feedback compensation of baseline drift. Additionally, the MCU's general-purpose input / output ports are connected to the PGA's gain control terminal for sending gain adjustment commands. The closed-loop adjustment works as follows: when the data ADC_1 detects baseline drift in the PGA due to temperature or ground noise, the MCU adjusts the DAC voltage output to feed back to the PGA's baseline, canceling the offset and achieving baseline regression to the desired value at the hardware level; when the peak ADC_2 detects a peak voltage, the MCU adaptively adjusts the PGA's gain value according to a preset head signal range.
[0066] During operation, the MCU contains a computer program that executes the aforementioned methods. The entire device operates on a single power supply, is compact, and has a low cost, making it suitable for mass production and use in financial terminal equipment such as POS machines and ATMs. Preferably, the peak detection circuit can use a classic detection circuit composed of diodes and capacitors, or an integrated true RMS detection chip can be used as an alternative to improve detection accuracy.
[0067] It should be understood that the specific embodiments described above are merely illustrative or explanatory of the principles of the invention and do not constitute a limitation thereof. Therefore, any modifications, equivalent substitutions, improvements, etc., made without departing from the spirit and scope of the invention should be included within the protection scope of the invention. Furthermore, the appended claims are intended to cover all variations and modifications falling within the scope and boundaries of the appended claims, or equivalent forms of such scope and boundaries.
Claims
1. A method for processing magnetic head signals in a dual-channel closed-loop linkage POS machine, characterized in that, Includes the following steps: Acquisition steps: The original alternating waveform signal output by the magnetic head induction is synchronously acquired through the first signal acquisition channel, and the DC voltage signal representing the amplitude envelope of the original alternating waveform signal is synchronously acquired through the second signal acquisition channel. The first signal acquisition channel and the second signal acquisition channel are physically separated. The first signal acquisition channel is dedicated to acquiring the original alternating waveform for data processing and baseline extraction, while the second signal acquisition channel acquires the amplitude envelope through hardware peak detection for gain determination. The two signals are acquired synchronously and do not interfere with each other. Gain closed-loop adjustment steps: Based on the peak amplitude of the DC voltage signal acquired by the second signal acquisition channel, determine whether the peak amplitude of the signal is within the preset target amplitude range; if it exceeds the target amplitude range, generate a gain adjustment command to adjust the gain amplification factor of the signal processing front end so that the peak amplitude of the signal falls into the target amplitude range. Baseline dynamic compensation steps: Extract the real-time baseline value from the original alternating waveform signal acquired by the first signal acquisition channel, generate a baseline compensation control signal based on the deviation between the real-time baseline value and the preset target baseline value, and feed the baseline compensation control signal back to the baseline input terminal of the signal processing front end to counteract signal baseline drift. Speed adaptive decoding step: Zero-crossing detection is performed based on the compensated original alternating waveform signal, the card swiping speed is calculated according to the time interval between adjacent zero-crossing points, and the gain adjustment strategy in the gain closed-loop adjustment step is executed differentially according to the preset speed level to which the card swiping speed belongs, and the adjusted signal is decoded. Based on the preset speed level to which the card swiping speed belongs, the gain adjustment strategy in the gain closed-loop adjustment step is executed differently, specifically including: When the card swiping speed is at a low speed, a strategy is adopted that allows for rapid increase in gain, adjusts the target amplitude range to the first preset range, and relaxes the clipping warning threshold. When the card swiping speed is at a high speed, the strategy of prohibiting the increase of gain, lowering the target amplitude range to the second preset range, and tightening the clipping warning threshold is adopted.
2. The method according to claim 1, characterized in that, In the baseline dynamic compensation step, extracting the real-time baseline value specifically involves: The sliding window averaging method is adopted. A sliding window of preset length is selected, and the difference between the newly entered sampling point and the previous sampling point is determined in real time. When the difference is less than a preset threshold, the sampling point is determined to be the baseline signal, and the average value of the continuously collected baseline signals in the sliding window is calculated to obtain the real-time baseline value.
3. The method according to claim 1, characterized in that, The speed range of the low-speed gear is less than a first speed threshold, and the speed range of the high-speed gear is greater than a second speed threshold and less than a third speed threshold, wherein the first speed threshold is less than the second speed threshold; the method further includes an overspeed determination step: when the card swiping speed is greater than or equal to the third speed threshold, the card swiping is directly determined to be invalid and the decoding is terminated.
4. The method according to claim 1, characterized in that, Prior to the data acquisition step, an initialization threshold setting step is also included: The system sets a noise threshold to trigger entry into card swiping mode, a target amplitude range to maintain signal quality, a clipping warning threshold to perform gain reduction operation in advance, and an end threshold to determine the end of card swiping.
5. The method according to claim 1, characterized in that, In the gain closed-loop adjustment step, the specific steps for generating the gain adjustment command are as follows: When the peak amplitude of the signal is lower than the lower limit of the target amplitude range, the gain amplification factor is increased step by step; When the peak amplitude of the signal is higher than the upper limit of the target amplitude range, the gain amplification factor is gradually reduced.
6. The method according to claim 1, characterized in that, The first signal acquisition channel and the second signal acquisition channel share the sampling clock and the start trigger signal to ensure that the signals acquired by the two channels are synchronized in time.
7. The method according to claim 1, characterized in that, The step of extracting the real-time baseline value from the original alternating waveform signal acquired from the first signal acquisition channel further includes: performing IIR filtering and digital low-pass filtering on the original alternating waveform signal to obtain the desired effective signal.
8. The method according to claim 1, characterized in that, The formula for calculating the card swiping speed is: V = (preset magnetic strip length) / (interval between two zero crossings), where the preset magnetic strip length corresponds to the physical distance between two adjacent magnetic flux reversal source points on the magnetic strip.
9. A POS machine magnetic head signal adaptive processing device based on a dual-path architecture and closed-loop linkage, characterized in that, Used to perform the method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Magnetic stripe card decoding circuit and method
CN104112111A
Automatic gain control method and device
CN115842525A