Application of ultrasonic sensor in automatic card dispenser on highway
In order to save the labor cost to achieve the purpose of cost reduction and efficiency, it is more and more widely used to install automatic card issuing machine at the entrance of toll station instead of issuing toll cards manually. Some shortcomings of automatic card issuer in the process of use have gradually emerged, such as, due to the improper operation of the driver or the improper installation position of the card issuer and other reasons, when the vehicle completely stopped after the distance from the card issuer is far away, the driver can not smoothly take the card. In order to solve the problem, increase the sliding platform in the automatic card issuer, the use of ultrasonic ranging function to detect the distance between the vehicle and the card issuer, automatic expansion and translation, shorten the distance between the vehicle and the card issuer, avoid the driver to get off the card, to achieve safety, convenience, fast take the card line, save time, increase traffic efficiency.
1 Principle of ultrasonic ranging sensor
Objects make a sound when they vibrate. In physics, frequency is defined as the number of times an object vibrates per second, in Hertz. Ultrasonic waves are sound waves higher than 20,000 Hertz . Ultrasonic ranging sensor includes ultrasonic transmitter and ultrasonic receiver, through the transmitter to emit a certain frequency of ultrasonic (frequency is generally greater than 20 kHz) in a certain direction, at the launch of ultrasonic time, ultrasonic transmission in the air to meet the obstacles immediately reflected back, The ultrasonic receiver stops timing as soon as the ultrasonic wave is reflected back. Ultrasonic ranging sensor is to use the ultrasonic wave in the air propagation, encounter obstacles round trip time, and then multiplied by the ultrasonic transmission speed, the distance from the obstacle can be obtained, the principle diagram is shown in Figure 1.
Suppose S is the distance between the measured obstacle and the rangefinder, the round-trip time of ultrasonic wave is t, and the propagation speed of ultrasonic wave is v, then the measured distance S = vt / 2.
2 System Design
Expressway automatic card issuing machine includes the upper station and the lower station card issuing box, respectively used for large vehicles and small vehicles card issuing, The main hardware control circuit includes the control circuit with STM32 single chip microcomputer as the main control chip, the upper station rangefinder, the upper station box mobile motor and driving circuit, the upper station box brake and driving circuit, the lower station rangefinder, the lower station box mobile motor and driving circuit, the lower station box brake and driving circuit, the vehicle inspection device and the model identification device.
When the vehicle enters the toll lane, the model identifier automatically identifies the vehicle type and sends the model data to the card issuer through the serial port of RS-485. Subsequently, the vehicle is driven to the position of taking the card, the vehicle inspection device detects the vehicle, and the card issuer determines whether the card is issued at the upper station or the lower station according to the vehicle type. Large vehicles issue the card at the upper station and small vehicles issue the card at the lower station. According to the ultrasonic distance sensor to measure the distance between the body of the card issuer and the vehicle, the sliding device of the body of the card issuer automatically adjusts the moving distance of the body.
3. Data interface of ultrasonic ranging sensor
Ultrasonic ranging sensor adopts mature, stable and reliable ultrasonic radar technology, ranging range is wide, can accurately detect the obstacle distance within 0~3 m, ranging accuracy can reach 1 cm, combined with the sliding platform to move out the appropriate distance, to ensure that through the automatic card lane vehicle drivers can safely access the access card, At the same time to avoid the card issuer collision with the vehicle.
The electrical interface for communication of the ultrasonic ranging sensor is a single line UART square. The high level (+5 V) is logic 1, the low level (0 V) is logic 0, and the idle level is high. The whole communication protocol is composed of five sequential information codes, P0, P1, P2, P3 and P4, where P0 is fixed as 0xC4, P1, P2, P3 and P4 respectively correspond to the ranging data of four ranging probes (the ultrasonic ranging sensor adopted in this project has four probes). The waveform timing diagram of the information code is shown in Figure 3.
Each information code consists of a leading code (010), an 8-bit data code, and a stop bit. Pi=010+Di+1, where i is 0, 1, 2, 3, and 4. The time width of each bit of an information code is 80 μs.
Definition of ultrasonic ranging sensor data code:
P0, control code, fixed at 0×C4;
P1, P2, P3, P4: The ranging data corresponding to the four ranging probes are shown in the sequence from left to right in the information code sequence diagram. The unit is 2 cm, the value range is 0~ 150, and the corresponding measuring distance is 0.0~3.0 m. For example, 0×10 represents 32 cm. The special value 0xFF represents infinity, where no obstacle was detected.
The data output line of the ultrasonic ranging sensor is connected to the I/O port of the single chip microcomputer, and set as external interrupt, triggering the falling edge. When the sensor has the output of distance data, the MCU triggers the falling edge interrupt. After a delay of 40μs, the timer interrupt of 80μs is opened and each bit of data of the 5 information codes is read in the timer interrupt.
4 SCM control program design
The sliding platform adopts 24V DC motor to control the expansion of the sliding platform, which can slide smoothly under the condition of bearing 100kg mass. The maximum telescopic distance of the sliding platform can reach 200mm. When the vehicle is far away from the card issuer, the sliding platform can be fully extended 200 mm. When the vehicle is close to the card issuer, the sliding platform can slide the appropriate distance without colliding with the vehicle, which is convenient for the driver to safely take the card or swipe the card. The telescopic distance is determined according to the four ultrasonic wave ranging sensor probes on the chassis shell to measure the distance between the vehicle and the chassis. When the distance is greater than the set value, the sliding platform automatically extends horizontally. After pressing the button to take out the card, the chassis automatically retractable.
The main control board MCU program is written in C language, compared with assembly, C language in function, structure, readability, maintainability has obvious advantages, easy to learn and easy to use.
The main control program mainly includes model data reception, vehicle inspection interrupt, ultrasonic ranging sensor data reception, box movement and braking. Serial port interrupt mode is adopted to receive data packets for vehicle model data. The vehicle inspection instrument is used to detect whether the vehicle is parked in the card position. It is a switching signal and accesses the external interrupt input port of the single chip microcomputer. Box movement includes box stretching out and returning to the original position, acceleration, constant speed and deceleration. When starting from a static state, acceleration moves; when moving at a constant speed in the middle, it moves at a deceleration when approaching the stopping position.
5 Closing Remarks
Ultrasonic ranging sensor has the characteristics of simple and convenient, easy to implement, low cost, high precision, not easy to be affected by the environment and so on. It can detect transparent objects, including the echo reflected from the glass and liquid surface, but also can resist fog, dust and dirt particles, and can detect the complex shape of objects stables, such as grid tray, spring and so on. In the range of 3 m, compared with infrared or laser ranging has obvious advantages, widely used in daily life, such as reverse auxiliary system, intelligent guide system, mobile robot, liquid level measurement, etc.
 Wang Ruirong. Design of ultrasonic rangefinder based on Microcontroller [J]. Electronic Testing,2021 (5):22-23,33.