Design of Taxi Meter Based on HT46RU24 MCU

Publisher:月光男孩Latest update time:2010-06-07 Source: 电子工程世界Keywords:HT46RU24 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 System Hardware Composition

The overall structure is shown in Figure 1. The hardware mainly consists of the HT46RU24 microcontroller, Hall sensor, no-load switch, keyboard circuit, data storage circuit, clock circuit, display circuit, buzzer, IC card circuit and serial port circuit.

1.1 HT46RU24 microcontroller.

The HT46RU24 microcontroller is a low-power, high-performance 8-bit microcontroller developed by HOLTEK. It has a ROM of 8k*16, a RAM of 384 bytes, and a maximum of 40 bidirectional IO ports. In addition, it also has an 8-channel 12-bit resolution A/D conversion, which can be used to monitor external analog signals, such as detecting battery voltage, current, temperature, humidity, pressure, brightness, etc. It provides two modes of PWM output that can be used for temperature control, speed regulation, constant voltage, constant current, etc. The controllable PFD output is used for sound generation or as a carrier signal for infrared transmission.

The HT46RU24's UART is a full-duplex asynchronous communication device. The baud rate can be set by software and it has an automatic error detection function. When using the UART to transmit data with other systems, the software burden can be reduced and the efficiency of the entire system can be improved.

The HT46RU24 microcontroller has high noise immunity, WDT and LVR functions to enhance the stability of the MCU.

The HALT and wake-up functions can reduce power consumption. The HT46RU24 microcontroller can also be used as an I2C slave. The pin diagram is shown in Figure 2.

1.2 Hall sensor

Connect the Hall sensor installed on the output gear of the vehicle's gearbox to the external interrupt interface of the microcontroller. Every time the wheel rotates one circle, the Hall sensor will generate a falling edge pulse to trigger an external interrupt.

1.3 Keyboard Circuit

In order to save IO ports, a 2*4 matrix keyboard is designed. The functions represented by each key in the program design are shown in Table 1.

Figure 2 HT46RU24 pin diagram

Table 1 Button Functions

1.4 No-load switch circuit (as shown in Figure 3)

[page]

Design an unloaded switch. When the switch is closed, it reads a low level "0", and when it is open, it reads a high level "1". By reading the switch value twice, the different states of the taxi can be determined, as shown in Table 2. Reading "0" twice means that the taxi is in an unloaded state, and reading "1" twice means that the taxi is in a passenger-carrying state. Reading "0" for the first time and "1" for the second time means that the taxi changes from an unloaded car to a passenger-carrying car, and reading "1" for the first time and "0" for the second time means that the taxi changes from a passenger-carrying car to an unloaded car.

Figure 3 Switching circuit

Table 2 Switch status judgment

1.5 Data Memory and Clock Circuit

The AT24C256 that extends the I2C bus stores statistical information, and the PCF8563 is used as a clock output. These two chips can share IO ports to save the use of IO ports. The AT24C256 memory chip has a storage capacity of 256K, paged storage, and each page has a capacity of 64 bytes. The PCF8563 chip has a programmable clock output, an interrupt output and a power-off detector circuit.

1.6 Display circuit and buzzer circuit

Use the LCD SMG12864 that can display Chinese characters and graphics to display mileage prices, delay prices, surcharges, statistical information, etc. This LCD has a built-in GB2312 code simplified Chinese character library (16x16 dot matrix), 128 characters (8x16 dot matrix) and 64x256 dot matrix display RAM (GDRAM). There are two connection methods to the microcontroller: 8-bit parallel and serial. In this design, parallel communication is used. The circuit diagram is shown in Figure 4. PA0 must be set when programming the software.

The buzzer unit is designed to emit different prompt sounds when performing some special operations.

Figure 4 LCD display circuit

1.7 IC card circuit (as shown in Figure 5)

The meter has the IC card payment function, and the IC card used is SLE4442 card, which is a logic encryption card designed by Siemens of Germany. SLE4442 card has a storage capacity of 3KB and a completely independent programmable encryption code memory (PSC), and is currently a widely used IC card in China.

Figure 5 IC card circuit

[page]

1.8 Serial port circuit (as shown in Figure 6).

Design a serial port circuit to complete the communication between the taximeter and the PC. The taximeter transmits statistical information to the PC, receives and stores basic information transmitted from the PC, including wheel diameter, clock correction, starting price, mileage price, return price, waiting price and other charging parameters. VB, VC and other software can be used to design the serial port communication interface on the PC. Through the serial port circuit, the manager can collect detailed and accurate operation data. After being processed by the PC, these data can be used to make detailed daily reports, monthly reports, operation analysis tables, etc., which can more intuitively reflect the operation of the taxi, so that the management department can fully grasp the first-hand information and make accurate judgments and decisions in time for the situation, thereby realizing computerized and scientific management.

Figure 6 Serial port circuit

2. Software Structure

In the main program, the most important thing is to do different processing according to the switch status. State 0: keep empty; State 1: keep carrying passengers; State 2: empty car becomes carrying passengers; State 3: carrying passengers becomes empty car. The main program flow is shown in Figure 7.

Figure 7 Main program flow

2.1 Keep the car empty

The empty car part is mainly used for display, PC communication and IC card consumption. By setting the program, different functions can be completed by pressing different buttons. For example, by pressing the "0" key, the LCD screen will display the statistics of the day, and by pressing the "2" key, the statistics of the previous day will be displayed, and by pressing the "4" key, the statistics of the next day will be displayed. The specific functions to be completed are shown in Table 1.

2.2 Empty car becomes loaded with passengers

This part needs to disable serial port interruption and start pricing. Starting pricing is to do some initialization work for the pricing and timing programs to be completed in the passenger part. For example, it is necessary to read pricing parameters, clear the meter, timing, and total delay units, determine whether it is a night shift, start the timer, etc.

2.3 Keeping passengers

The passenger part mainly processes the delay price and mileage price. It uses the 50MS timer interrupt and external interrupt. It is necessary to define the timing unit to store the time between two external interrupts and define the cumulative delay unit to store the cumulative waiting time. When the 50MS interrupt arrives, F_50MS is set. The 50MS interrupt processing program will be called in the passenger part. The process is shown in Figure 8. This program mainly processes the timing unit. If the timing unit is greater than 10S, the delay price subroutine ADD_PT is called.

Through the Hall sensor, each time the wheel rotates a circle, an external interrupt will be triggered. In the interrupt subroutine, the timer must be turned off first, the T0 count value is stored, the timer is reset to the initial value of 50MS, F_int0 is set and the timer is turned on. The external interrupt processing subroutine will also be called in the passenger part. The process is shown in Figure 9. When the vehicle speed is detected to be lower than a specific value, the error price needs to be calculated and the timing unit is added to the accumulated error unit. Among them, ADD_PS is the mileage price subroutine.

[page]

2.3.1 Incorrect prices.

The time delay price procedure is mainly to determine whether the accumulated waiting time exceeds the specified waiting time (Twait). After exceeding the time, the time delay price is increased by 10S every 10S. The flow chart is shown in Figure 9, where F_wait indicates the starting price waiting time has arrived.

2.3.2 Mileage Price

The key to the mileage price subroutine is to determine the size of the meter unit S, whether it is the starting price, a short-distance price of 3KM-8KM, or a long-distance price of more than 8KM.

2.4 Passenger-carrying vehicle becomes empty

This part needs to complete the operations of stopping pricing, storing statistical information, and allowing serial port interruption. The key is to store statistical information. There are a maximum of 31 days in a month, and 4 bytes of capacity are required every day, so at least 124 bytes of information for a month are required. Because the memory chip AT24C256 used is paged storage, each page has a capacity of 64 bytes. If 128 bytes are allocated to each month's information, it is easy to store and view daily statistical information through the calculation formula: (month-1)×32×4+(day-1)×4+ADDRESS_AT3 (ADDRESS_AT3 represents the starting address allocated to statistical information in AT24C256). Therefore, we allocate 2 pages of 128 bytes of capacity to each month's information.

3. Conclusion

This article describes in detail the software and hardware principles of the taxi meter using the HT46RU24 microcontroller. The program design is clear, organized, and easy to maintain. The entire circuit is complete, compact, and low-cost. It also has the advantages of simple operation, convenient management, safety, reliability, and powerful functions. The core of the meter, the HT46RU24 microcontroller, has flexible software programming, high degrees of freedom, powerful functions, low power consumption, high cost performance, and mature technology.

References:

[1] Li Qixiong, Zheng Yanxiong, Cai Mengchang. Principles and Application Examples of HOLTEK HT46 Series Microcontrollers[M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 1st edition, April 2005.

[2] Fan Yizhi, Chen Liyuan. Visual Basic and RS232 Serial Communication Control [M]. Beijing: Tsinghua University Press, 2nd edition, June 2002

Keywords:HT46RU24 Reference address:Design of Taxi Meter Based on HT46RU24 MCU

Previous article:Quality Control Experience: Six Ways to Reduce the Defect Rate of Automotive PCBs
Next article:Design of hardware-in-the-loop real-time simulation test platform for fuel cell vehicle controller

Latest Automotive Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号