1 Working principle of prepaid smart CPU IC card gas meter
The prepaid smart CPU IC card gas meter is composed of an intelligent measurement and control system based on a single-chip microcomputer installed on a conventional mechanical gas meter. The measurement and control system is mainly composed of a single-chip microcomputer, a SAM (Secure Access Module) module, a CPU IC card interface, a metering circuit, a protection detection circuit, and a gas circuit control valve. The system structure is shown in Figure 1.
2 Functions realized by prepaid smart IC card gas meters
(1) Metering and control functions: Make full use of the single-chip microcomputer to measure various gas usage; control user gas usage through the control valve.
(2) Encryption function: A CPU card with extremely high encryption strength is used and one card is assigned to each household. After passing multiple internal and external authentications, gas purchase and other operations can be realized only when a certain authority is reached.
(3) Display function: It can display the remaining gas, monthly cumulative and quarterly cumulative gas, etc.; various system status displays, such as battery undervoltage, alarm status, gas overcurrent, etc.
(4) Reminder function: When the remaining gas is not much (equal to a certain set value), the valve is closed once to remind the user to purchase gas.
(5) Alarm function: Battery undervoltage alarm, gas overcurrent alarm to prevent pipeline rupture, valve opening and closing fault alarm, alarm of external combustible gas alarm interface, card abnormal operation alarm, gas meter cover opening alarm, etc. When an alarm occurs, the control valve is closed first, then the buzzer sounds and the LCD displays. Each alarm event will be recorded in the SAM module, and will be written back to the user's gas purchase card when the user purchases gas next time, and then returned to the gas sales department by the gas purchase card, so that it can be queried by the competent department or bank.
(6) Self-protection function: prevent high voltage attack and short circuit at IC card port and battery connection, cover opening detection, battery-free detection, select special pulse sensor that is not afraid of strong magnetic field, etc.
3 Hardware design of prepaid smart IC card gas meter
Because this prepaid IC card gas meter is a civilian product for families, the following principles should be taken into account when designing the hardware: low cost; low power consumption, extend battery life as much as possible; high reliability, no crash and loss of purchased gas data.
3.1 Selection of control microcontroller
The control microcontroller is the 8-bit microcontroller uPD789167 produced by NEC. uPD789167 is a low-cost microcontroller with 44pin package, with 24KB ROM, 512B RAM, 8-channel 8-bit A/D converter, external 32kHz subclock, 6 timers, 4 external interrupts and other resources, and has a very low cost after masking.
3.2 Design of clock circuit
This design uses the 3.58MHz main clock and 32kHz sub-clock of the uPD789167 microcontroller. The former runs when the microcontroller is working at high speed, and is provided to the SAM module and the external CPU-type IC card after internal 2-frequency division. In order to reduce power consumption, the 3.58MHz main clock stops oscillating when the power is turned on, the SAM module and the IC card are accessed, and the 32kHz crystal keeps oscillating to complete the internal software running time, the accumulation and statistics of gas volume, and assist in judging the gas volume per unit time, determining whether the gas is over-flowing, and driving the display of the LCD module when necessary.
3.3 Selection of SAM module and CPU-type IC card
Compared with ordinary memory cards and logic encryption cards, CPU cards have higher security because they use advanced technologies such as CPU, on-chip operating system (COS), file system, encryption and decryption algorithms. In order to improve the confidentiality performance of the smart gas meter, this design selects the SAM module and CPU card of Beijing Wuqi Company as the medium for security authentication, data storage and transmission. This product has independent intellectual property rights and complies with international standards and industry standards such as ISO7816 and PBOC. It supports hierarchical file structure and can establish a three-level application directory, which is suitable for the requirement of one card for multiple uses. It supports multiple file types including binary, fixed (variable) length records, wallet records, etc. It contains an E2PROM that can be erased and written 500,000 times, with a capacity ranging from 0.5K to 16KB. It has been successfully applied in industries such as electric meters. The interface between the CPU and the SAM module is shown in Figure 2. The standard stipulates that the CLOCK frequency must be greater than 1MHz. In this design, the CLOCK is 1.79MHz. When the SAM module is not accessed, the power supply of the SAM module is cut off, and the -RST and CLOCK pins of the CPU also output low levels, and the I/O pins of the CPU are set to input and internal non-pull-up mode.
As shown in Figure 3, the power supply is divided into two routes. One route is 3 batteries after 3V voltage regulation, and VCC supplies power to CPU, etc.; the other route is not voltage regulated, and VDD supplies power to the switch valve circuit. The two routes use their own Farad capacitors, which do not interfere with each other, ensuring the reliable closure of the valve when the power is off and the reliable storage of data transmitted to the SAM module.
In order to prevent high voltage attacks from the battery terminals, TVS tubes and 200mA recoverable fuses are configured. Combined with the protection of the IC card port, the safety of this gas meter is guaranteed.
3.5 Watchdog circuit
In a power supply circuit with a large-capacity capacitor, the power supply charges and discharges slowly, and the ordinary RC reset circuit often cannot produce a correct reset. In the normal use of the user, the gas meter is not allowed to crash. For this purpose, a reset and monitoring circuit (low-cost watchdog circuit) with power-on reset, watchdog, low-power and low-cost oscillator type is designed using 74HC14, as shown in Figure 4. In the figure, a 30kΩ resistor is combined with a 104 capacitor and a diode to form an RC power-on reset; at a working voltage of 3V, the watchdog clearing time interval must be less than 0.9 seconds. In the gas meter designed in this design, the CPU wakes up once every 0.5 seconds to detect and accumulate gas pulses, and at the same time sends a high-level clearing pulse with a width of 20μs. In addition, other gates of 74HC14 are also used in the shaping circuit of gas pulses and the isolation circuit of the IC card holder clock line.
The gas valve uses a specially designed low-power self-holding valve, which consumes power only during the switching process and does not consume power at other times. The solenoid valve drive circuit is shown in Figure 5. The minimum switching voltage requirement is 2.5V. The maximum current when opening the valve is about 120mA, and the maximum time is 2 seconds; the maximum current consumption when closing the valve is 100mA, and the maximum time is 1 second. The valve opening has a detection switch in place. If the valve opening timeout occurs, the CPU will issue a valve failure alarm signal and close the valve at the same time. The valve drive circuit uses a separate power supply VDD with a 0.22ΩF/5.5V capacitor (see Figure 3) to ensure the success of the valve opening and closing.
3.7 IC card interface circuit
The IC card interface directly performs human-computer interaction and is most likely to be damaged intentionally or unintentionally. The most common phenomena are short circuit and high voltage series connection. Therefore, the interface circuit must have a complete protection function. The IC card holder and protection circuit are shown in Figure 6. After the CPU finds that IC SWITCH is at a low level, it knows that a card has been inserted, and then starts the 3.58MHz crystal oscillation, outputs -IC PWR CTRL low level, and supplies power to the card holder. Then, after a 5ms delay, it checks whether the power supply of the card holder is accurate from the IC VCC end. This can be detected by the A/D converter of the microcontroller. If the voltage is too low, the power supply is immediately turned off and the card reading is abandoned. Each signal line has a current and voltage limiting protection circuit composed of a positive temperature coefficient thermistor (MZ12A-75S102M008, resistance value is 1000Ω, operating current is 16mA) and an embedded diode (1N4148) to prevent external high voltage series connection. Because the resistance on the power line cannot be too large, the thermistor must be selected separately, so MZ12A-3R5N010 (resistance is 3.5Ω, operating current is 200mA) is selected.
3.8 Cover opening detection circuit
As shown in Figure 7, S1 is a reed, which is closed when the gas meter is covered at the factory. When the gas meter is opened, S1 is disconnected. Although both the left and right circuits in Figure 7 can detect the cover opening, that is, the level of the "cover opening detection" terminal changes when the cover is opened, the power consumption of the left circuit is obviously greater than that of the right circuit. First, since the input pin of the CPU allows a maximum leakage current of 3μA, the resistance of the 200kΩ resistor cannot be increased, otherwise it will affect the judgment of the high and low levels. Assuming VCC=3V, the static current on the left is 3V/200kΩ=15μA, and the static current on the right is 3V/1MΩ=3μA, which is 1/5 of the former, so this design uses the circuit on the right. The CPU detects the "cover opening detection" terminal within the wake-up time of every 0.5 seconds. Once the cover is opened, the valve will be closed, an alarm will be sounded, and an open cover event will be recorded in the SAM module.
3.9 Alarm and LCD display circuit The
uPD789167 single-chip microcomputer drives the LCD module to display in a serial communication mode, but the LCD is disconnected from the power supply when it is not displaying to save energy. In addition, a buzzer alarm circuit is provided to remind the user when a fault is just discovered.
4 Low-power design technology
The design of this gas meter is: not only must the CPU maintain the real-time clock and have a watchdog, but the power consumption must be very low (the normal working current is slightly greater than 30μA). To this end, the following measures are adopted to ensure the low-power operation of the machine.
4.1 Use low-power devices
In this design, low-power devices are used as much as possible. For example, the 3V regulator uses Ricoh's low-power products; a low-power self-maintaining valve is used, which only consumes power during the switching process.
4.2 Use low-power circuit design
(1) The CPU and other peripheral circuits are powered only after the battery voltage drops to 3V, so that the chip consumes less current when working at a low voltage.
(2) The SAM module and IC card holder are normally powered off and only powered during read and write authentication.
(3) When it does not affect the CPU level judgment, use a larger resistor (such as in the cover opening detection and battery detection circuits).
The pulse sampling circuit also consumes power only when there is a pulse.
4.3 Software coordination to achieve low power consumption
(1) Let the microcontroller work at a low speed as much as possible. The software only allows the 3.58MHz crystal to oscillate when accessing the SAM module and the CPU IC card. Normally, only a 32kHz crystal can be used to complete the work.
(2) Reasonably configure the various pins of the CPU, and the output pins output appropriate levels so that they do not output or absorb current normally; the input pins generally do not use internal pull-up resistors but external resistors because the internal pull-up resistors are small, with a typical value of 30kΩ when masked, and consume more power when the input is low level; the redundant pins of the CPU are set to output mode and output low level.
(3) When the CPU works under the 32kHz crystal, it is in HALT mode and wakes up once every 0.5 seconds or an interrupt. The software checks several interrupt flags, counts, runs, and clears the dog immediately after entering HALT sleep, thereby effectively saving power.
5 Software Design of Prepaid Smart IC Card Gas Meter
5.1 Software Function Modules
The software is written in NEC78k0S C language, using modular and hierarchical programming methods. The core parts include the following modules: SAM, CPU card communication module (T=0, character mode, serial rate 9.6Kbps); SAM, CPU card authentication and read/write module; gas metering module; power management module; LCD display module; alarm module; factory test module, etc. (due to space reasons, they are not described in detail here).
5.2 Authentication process of SAM and CPU card
In this gas meter, the software must receive and process multiple CPU cards: user gas purchase card, inspection card, manufacturer test card (such as valve detection card, etc.), modification master key card, etc. The directory file structure and authentication access method of each CPU card are different. Taking the user gas purchase card as an example and inserting the card into the gas meter after purchasing gas, the software authentication process is explained:
(1) Identify the type of card from the readable binary file of the card, that is, the user gas purchase card.
(2) The gas meter reads the card serial number and user number from the user card and compares the user number with the one stored in SAM. If they are not consistent, the card reading is rejected.
(3) If the user numbers are consistent, the IC card gas meter sends the card serial number to the SAM module. The SAM module encrypts the card serial number and generates a corresponding internal authentication key.
(4) The gas meter uses the internal authentication key to internally authenticate the user card.
(5) The gas meter uses the external authentication key to externally authenticate the user card.
(6) The gas meter reads the gas purchase data from the user card gas purchase application binary file, determines its integrity, and determines whether the number of gas purchases is consistent with that in the IC gas meter. If they are inconsistent, the application binary file (data) is written back to the IC card gas meter to exit; if they are consistent, enter (7).
(7) The IC card gas meter uses the gas volume external authentication key to externally authenticate the SAM module. If they are consistent, the gas volume and status data are stored in the SAM module, and the data is written back to exit, completing the gas purchase operation; otherwise, only the data is written back to exit.
6 Conclusion
The CPU IC card prepaid gas meter based on NEC single chip microcomputer and SAM module has made useful exploration in terms of security and confidentiality, anti-attack, low power consumption and low cost. After several months of actual use, it has been proved to achieve the expected effect.
Previous article:Intelligent residual current protector electromagnetic compatibility design
Next article:Multi-output flyback power supply for audio amplifiers
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Playing with Zynq Serial 50——[ex69] FIR filter IP simulation example
- Five solutions to common wireless transmission delay problems
- I am quite confused about the following constant current circuit
- Installation of the digital multimeter + RL78G14 development environment based on the serial port
- 【Recruitment】Full-time and part-time RF engineers
- Explore Ultra-Wideband (UWB) Technology
- #It turns out I owe so many trees#Have you planted trees? Happy Arbor Day~
- Simple LM317 adjustable power supply
- AD09 cannot open AD files.
- AC servo motor based on STSPIN32F0