Research on the Application of CPLD Chip in Automobile Driving Simulator System

The car driving simulator uses computer real-time control and computer graphics processing technology to simulate the actual driving process of the car, which is used to train drivers, shorten the cycle of getting on the car and reduce the cost of driving training. The car driving simulator consists of hardware and software. The hardware consists of a computer, a Display device, a steering wheel, a dashboard and other components, and the software consists of subsystems such as a computer simulation visual system, sound simulation, and operating platform of the road environment. This paper will study the design of hardware control system.

Author: Hu Dingjun; Zhang Qian

The car driving simulator uses computer real-time control and computer graphics processing technology to simulate the actual driving process of the car, which is used to train drivers, shorten the period of test driving, and reduce the cost of driving training. The car driving simulator consists of hardware and software. The hardware consists of a computer, a Display device, a steering wheel, a dashboard and other components, and the software consists of subsystems such as a computer simulation visual system, sound simulation, and operating platform of the road environment. This paper will study the design of hardware control system.

1 The principle and function of the control system

The car driving simulator system includes three parts: the mechanical part, the control system and the simulation software. The ignition device, steering wheel, clutch device, foot brake device, handbrake device, accelerator device, gear device and instrument device of the mechanical part are all simulated in kind; The status of the foot brake, handbrake, accelerator and gear position, and the detection results are sent to the computer, and the driving scene is changed through the simulation software. Change the indication on the dashboard. The schematic diagram of the control system is shown in Figure 1.

Research on the Application of CPLD Chip in Automobile Driving Simulator System
Figure 1 Schematic diagram of the control system

The program of computer sampling data is written in VC++ language. For the accuracy of the data, the collected data is refreshed every 20ms. In this way, the state of ignition device, clutch device, foot brake device, handbrake device, accelerator device and gear device is detected every 20ms, and the detection result is transmitted to the computer. In the process of driving, since the steering wheel is constantly turning, this requires the program to be able to detect the direction and angle of the steering wheel in real time.

2 Steering wheel position detection

In the actual design process, it is necessary to determine the steering and rotation angle of the steering wheel, that is to say, first determine whether to turn left or right, and then determine the angle of rotation. The schematic diagram of the rotation direction and rotation angle of the steering wheel is shown in Figure 2. Two photoelectric induction switches JK122 are selected and installed next to the turntable. The two photoelectric induction switches are placed at x1 and x2. When the turntable rotates, there are teeth blocking the photoelectric Induction switch, the output is 1, otherwise the output is 0.

Research on the Application of CPLD Chip in Automobile Driving Simulator System
Figure 2 Schematic diagram of the rotation direction and rotation angle of the steering wheel

Assuming that the distance between any two teeth is d, as long as the distance between x1 and x2 is not equal to n/2.d (n is an arbitrary integer), when the turntable rotates, the output waveforms at x1 and x2 will be as shown in Figure 3. Show.

Research on the Application of CPLD Chip in Automobile Driving Simulator System
Figure 3 Output waveforms at x1 and x2

It can be seen that, if the initial states of x1 and x2 are both 0, the state changes to 00-01-11-10-00 during forward rotation, and 00-10-11-01-00 during reverse rotation. As long as you know the current state and the next state of x1 and x2, you can know the steering wheel steering at this time. We must judge the initial state of 00 when designing. Connect the x1 and x2 signals to the input terminals of the two T flip-flops respectively, and use the inverted signal as the reset signal of the flip-flop. When the initial state is 00, the outputs of both flip-flops are 0. If the latter state is 01, the output of the flip-flop T1 is 1, indicating forward rotation; if the latter state is 10, the output of the flip-flop T2 is 1. Indicates inversion. Since the next state must be 11, after the flip-flop is cleared, the judgment can be restarted when the state is 00. After judging the steering, it is also necessary to judge the angle of rotation. Here we add two T flip-flops T3 and T4. When the state of input x1 and x2 changes from 11 to 10, the output of flip-flop T3 is 1. On the contrary, if it changes from 11 to 01, the output of flip-flop T4 is 1. Finally, the output signals of the four flip-flops are phase-ored and sent to the counter as clock signals, and the output signals of T1 and T3 are phase-ored as the input signals of the counter, so when the steering wheel rotates forward, the counter accumulates upward, while the reverse is reversed. When turning, it decreases downward, and finally the rotation angle of the steering wheel can be known by reading the output data of the counter. This text adopts CPLD technology to design the control circuit, the schematic diagram is shown in Figure 4.

Research on the Application of CPLD Chip in Automobile Driving Simulator System
Figure 4 CPLD design schematic

As can be seen from the figure, the design of CPLD technology is generally a “top-down” design, and the design process is as follows:

(1) Behavioral design; determine the function, performance and allowable chip area or cost of the designed system or CPLD chip.

(2) Structural design: According to the characteristics of the system or CPLD, it is decomposed into subsystems with clear interfaces, detailed interrelationships, and as simple as possible to obtain an overall structure. This structure may include arithmetic operation units, control units, data channels, various arithmetic state machines, and so on.

(3) Logic design; adopt the logical structure of rules as much as possible or adopt the logic unit or module that has been tested by itself.

(4) Circuit design; the logic diagram will be converted into a circuit diagram. In many cases, hardware simulation is required to finally determine the correctness of the logic design.

Finally, the designed circuit is compiled to form a fuse file, and the file is downloaded to the selected CPLD to become an ASIC that can complete fixed functions. In the whole development program, it can be realized by software MAX+plusII programming, and the chip EPM7128SLC84-15 produced by Altera Corporation is selected.

3 Software design of the control system

The software part of this system consists of the main detection program, the driving instrument program and the steering wheel and other switching input programs. The detection main program includes data acquisition module, CPLD module, and is assigned to different ports of instrument and digital input. In the initialization of the port, set all the initial states to 0. Through the software timer scan, the state of each port is transmitted to the main program in real time. The flow chart of the main program is shown in Figure 5.

Research on the Application of CPLD Chip in Automobile Driving Simulator System
Figure 5 Main program flow chart

Using VC++ language, the data exchange information such as the state and angle in the hardware is made into a hardware connection library. It acts as a bridge to closely combine all the operations of the hardware with the visual system of the software part to become a complete car driving simulation. training system.

4 Conclusion

The system uses CPLD technology, fully considers the corresponding time of steering wheel, clutch, foot brake, handbrake, accelerator, and gear shift, and is closely integrated with the visual system of the software part through the agreement. And through the example designed in this paper, it can be seen that the reasonable application of CPLD technology greatly improves the flexibility of system design, improves the reliability and integration of the system, shortens the cycle of product development, and can also reduce design costs and save money. PCB area and wiring difficulty. Therefore, in the current Electronic design, making full use of the design architecture of the CPLD will achieve twice the result with half the effort. At present, the control system has been produced for promotion and application, and has achieved good economic and social benefits, and has been well received by the students. The author’s innovation point: Many researchers in the entire hardware control system mainly use single-chip microcomputers combined with serial ports and parallel ports to communicate. Due to the fact that the address allocation and wiring of the single-chip microcomputer are cumbersome and the reliability is not strong, the data exchange between the single-chip microcomputer and the single-chip microcomputer also has certain limitations. We have adopted CPLD technology and the data acquisition module can easily compile and operate the ignition status of the hardware part, the angle of the steering wheel, the direction of rotation, the state of the clutch, footbrake, handbrake, accelerator, and gear, and exchange data in time. , greatly improving the controllability and reliability of the control system, reducing the production cycle and cost.

The Links:   NL8048AC19-13 SKM800GA126D