Design of Data Acquisition System for Vehicle Driving Simulator

Data acquisition systems have a direct impact on interactivity and authenticity to the car driving simulator. According to the requirements of the vehicle driving simulator to complete the multi-channel data acquisition and processing with high speed and high precision, a set of real-time data acquisition system was designed. The system uses STM32F103ZET6 chip to process data acquisition, and communicates with the host computer through serial port. The experimental results show that the designed data acquisition system has good real-time performance, high accuracy and meets the expected functional requirements.


Introduction
In today's era, as a common means of transportation for people's production and life, automobile is an indispensable part of people's life, which brings convenience to people's life. But the following road traffic safety problems make the government feel more pressure. The appearance of automobile driving simulator can effectively alleviate this situation. It has important application value.
The driving simulator can simulate the driving environment and let the driver get the real driving experience. Generally speaking, driving simulator is composed of real-time control system, motion system, operation monitoring control system, integrated information processing system and data transmission system [1].
Data acquisition and processing system is the core of the whole driving simulator. The design idea of data acquisition system for driving simulator is introduced below.

Basic principles 2.1 Vehicle driving simulator
Car driving simulator is a kind of simulation system which can simulate the driving operation of the car and get the real driving experience. The working principle of vehicle driving simulator is shown in Figure 1.

Data acquisition system
Data acquisition system is to arrange a series of chips on a board according to their respective functions under certain electrical rules, and finally form a PCB with specific functions. These chips are controller, memory, clock signal, A/D or D/A converter, etc. The structure of data acquisition system is shown in Figure 2.

Hall sensor
Hall effect: When an electrified semiconductor wafer is vertically placed in a magnetic field, an electric potential is generated on both sides of the wafer. As shown in Figure 3. To control the current through the X direction, Apply magnetic field B in the Z direction, It's going to generate an electromotive force in the y direction.
This phenomenon is called Hall effect, where is Hall potential, Its size can be expressed as: . ( Where: is the hall coefficient, which is determined by the properties of the semiconductor material; d is the thickness of the semiconductor.
Hall sensor is a kind of magnetic field sensor based on Hall effect. Hall sensor is a kind of electromagnetic sensor, which can be used in some occasions using magnetic field to measure displacement, mainly through the magnetic field and its changes to detect displacement, speed, angle and so on. Hall effect is produced when Hall sensor works, which is mainly measured by the relationship between permanent magnet and Hall element [2]. The circuit structure of Hall sensor is shown in Figure 4.

Selection of sensors
The signal collected by data acquisition system is divided into analog quantity and digital quantity. As shown in Table 1. There are 28 switching values: the wiper is divided into four states, namely off, fast, slow and intermittent. The car lock is divided into four states, namely unlocking, car starting, closing starting and locking. The steering wheel can be divided into four states, i.e. left steering wheel, left steering wheel, right steering wheel and right steering wheel. The lighting is divided into five states, namely headlight, small lamp, high beam, left turn signal and right turn signal. The gears are divided into seven states, i.e. first gear, second gear, third gear, fourth gear, fifth gear, neutral gear and reverse gear. The clutch is divided into two states, i.e. clutch on and clutch off. The handbrake is divided into two states, that is, the handbrake is opened and the handbrake is closed. There are two analog channels, namely foot brake and throttle.

Hardware design of data acquisition system
The hardware of the system consists of core controller, data acquisition circuit, RS232 serial port circuit, USB interface circuit, power supply circuit, clock circuit, reset circuit, JTAG download circuit, etc [3]. the general block diagram of the hardware is shown in Figure 5. This system will choose a 32-bit STM32F103ZET6 chip as the processor, it is a high-speed processor with 48 pins, the processing speed can reach 72MHZ [4]. The power supply system is the basis for the normal operation of the whole circuit, so it is necessary to add antiinterference when designing the power supply system to ensure the stable operation of the chip, as shown in Figure  6. This time, high-speed transmission is adopted, and the transmission speed of USB can reach 12mbid, while the data transmitted this time is less, which fully meets the real-time performance of signal transmission [5]. The circuit is shown in Figure 7. UART serial port is used to communicate between PC and MCU. Because RS232 level can not be directly connected to STM32, a level conversion chip is needed. Here we choose SP3232 for level switching. The circuit diagram is shown in Figure 8. The system adopts power on reset, and the circuit diagram is shown in Figure 9. The basic function of the reset control circuit is to provide the reset signal when the system is powered on, and cancel the reset signal until the system power supply is stable and the crystal oscillator works normally. If the system fails and cannot be solved by software method, press the reset button to restart the system. JTAG download circuit is used to debug and write MCU program. The circuit diagram is shown in Figure 10. STM32F103ZET6 chip clock circuit clock signal can use external crystal oscillator mode, this circuit external crystal oscillator is 8MHz, circuit diagram is shown in Figure 11.  The data acquisition of analog quantity is mainly the acquisition of throttle and brake. We simulate and demonstrate the process of foot brake and throttle by installing potentiometer, and reflect the force of foot brake and throttle in the range of 0 ~ 100. The circuit of the potentiometer is shown in Figure 12. The data acquisition of switching value mainly includes the acquisition of wiper, car lock, steering wheel, light, gear, clutch, handbrake and other parts. This time, Hall sensor is used to collect these signals. A permanent magnet is installed in these hardware devices to be collected, and a Hall element is installed under the permanent magnet. When the operator has a signal, with the increase of displacement, the induced electromotive force is also increasing, and the voltage value is also increasing. The magnitude of displacement can be judged by the magnitude of the voltage value. The circuit diagram is shown in Figure 13. Combined with the functions of the above modules and the corresponding circuit schematic diagram, the PCB diagram of the whole data acquisition system is obtained, as shown in Figure 14, and the actual PCB is shown in Figure 15.

Software design of data acquisition system
Software design of data acquisition system the software of data acquisition control system mainly completes the acquisition and processing of multi-channel signals. When the lower computer receives the instructions from the upper computer, it sends the data to the upper computer according to the communication protocol, and performs the corresponding operation according to the output instructions. The software adopts C language modular programming, which is mainly composed of main program, data acquisition and processing program, USB communication interrupt service program, RS232 communication interrupt service program, output control program, etc. The main program flow chart and interrupt service program flow chart are shown in Figure16 ， figure17 and Figure 18 respectively. In the data acquisition circuit, the flow chart of gear acquisition is listed here, as shown in Figure 19.    The main program mainly completes the initialization of the system, including system clock initialization, interrupt vector initialization, GPIO port initialization, serial port initialization, USB initialization and so on; USB communication and RS232 communication programs realize the communication between MCU and host computer, according to the data acquisition rate and real-time requirements, USB module adopts the virtual serial port transmission mode; The data acquisition and processing program mainly completes the acquisition and processing of encoder signal and 28 channel switch input signal; the output control program controls the two channel switch output according to the upper computer command.

Design and debugging of upper computer
The data communication between upper computer and lower computer adopts "call answer" processing mode. GUI interface design of host computer, GUI interface is developed by QT project, the main language used is C#. The GUI interface of upper computer includes lights, steering wheel, gear, wiper, door lock, horn, clutch, brake, throttle and other information. When the GUI interface receives data, it first sets the baud rate and serial port number of communication, then scans the serial port, and finally analyzes the scanned array containing data, and transmits the signal represented by each data in the array to the upper computer interface for display. The data analysis process is shown in Figure 20. After the design of the GUI interface, when USB is inserted into the computer, the host computer will scan the device. After the connection is successful, the GUI interface will display the information of lights, steering wheel, gear, wiper, car lock, horn, clutch, brake, accelerator and so on. When the operator changes the clutch, throttle, brake displacement and steering wheel angle, we observe whether the data in GUI interface changes and whether the data change range is within the set range.
When the operator changes the operation information of clutch, throttle, foot brake and steering wheel, the data in GUI interface changes in real time. The debugging results show that the acquisition system can acquire the operation signal accurately and in real time.

Concluding remarks
The purpose of driving simulator is to make the vehicle more safe and reliable. How to quickly obtain the information of vehicle motion state has become a research topic for many technicians. This method has enough accuracy and confidence, and has important application value.
This paper designs a data acquisition system of automobile driving simulator based on STM32F103ZET6 chip. The practice shows that the main control chip of STM32F103ZET6 has strong data operation and processing ability, which ensures the authenticity and timeliness of data acquisition of automobile driving simulator, and has high reliability, and achieves the expected design goal.