Design of Intelligent Vehicle Control System Based on Dual-core Multi-interface

Design of Intelligent Vehicle Control System Based on Dual-core Multi-interface

The basic construction of the system is shown in Figure 1, which includes sensor signal acquisition and processing, power motor drive, steering servo control, and control algorithm software development.

The introduction of dual-core

At the beginning of the design of the smart car, we analyzed that the important thing in the design system of the smart car based on the photoelectric sensor is the signal integrity, that is, the more track information and car position information obtained through the sensor, the better. By comparing the number of interfaces and performance requirements of 8-bit and 16-bit microcontrollers, this design decided to use two 8-bit microcontrollers MC9S08DZ60 as the core control unit.

Communication interface between two cores SPI

During the operation of the vehicle, the information of the three sensors needs to be collected by the controller, which are the photoelectric sensor, the speed sensor, and the angular velocity sensor. Since the angular velocity sensor needs to have an accurate sampling period, we use the internal timer of the microcontroller to generate a 1.2 ms time reference. In this 1.2ms period, the data collection of the three sensors is executed, and the SPI data transmission procedure is executed when the timer overflow is interrupted. SPI is a high-speed, full-duplex, synchronous communication bus, and only occupies four wires on the pins of the chip, namely mosi, miso, sck, ss. We use a 1MHz data transmission speed, use 3 bytes to send the sensor data, and two bytes to send the speed sensor and angular velocity sensor data.

Communication interface SCI of control system and upper computer

The running status of the vehicle during driving cannot be directly obtained through observation, so we use the host computer system for real-time monitoring. Use wap200b wireless serial port module to send data, the module uses 3.0V power supply, built-in high-speed MCU, data transmission accuracy is high. The standard serial port is used for communication between the MCU and the module, which is set to 115200 baud rate, 8 data bits, 1 stop bit, and no parity. A total of 7 data are sent in one communication. First send two data as handshake signals are 0x00 and 0xFF, then use 3 bytes of data to send sensor information, 1 byte of data to send angle information, 1 byte of data to send speed information, the last bit reserved For future use, send 0x00.

Communication interface I2C between keyboard and main control chip

During the actual commissioning of the vehicle, there are many parameters that need to be constantly adjusted, such as the PID angle and speed of the vehicle. It will take time and effort to re-download the program every time when setting different parameters, so here we use the keyboard to enter the parameters when the vehicle is driving. The keyboard control chip HD7279 is a smart display driver chip with a serial interface that can simultaneously drive 8 common cathode digital tubes (or 64 independent LEDs). The chip can also be connected to a keyboard matrix of up to 64 keys at the same time. It can complete all the functions of LED display and keyboard interface.

We use 4 I / O ports of the single chip microcomputer to operate HD7279, namely CS, CLK, DATA, KEY. Here we can set some parameters through the keyboard, such as PID Kp, Ki, Kd parameters, straight line and curve speed, etc.

Application of A / D module in collecting angular velocity

The A / D conversion module in this system is mainly used to collect the output value of the gyroscope. Because the cost of the simulated gyroscope is relatively low, and the angle accuracy requirement is not very high in the car model control system, the simulated gyroscope is used to correct the posture of the car body in real time. MC9S08DZ60 integrates 12 digital-to-analog conversion channels. Because the output signal range of the analog gyro is 0 ~ 5V, the reference voltage of the single-chip microcomputer is + 5V, which is separately powered by the high-precision voltage regulator module to ensure the conversion accuracy. The data processing procedure after A / D conversion is as follows:

void Gyro_Process (void)

{

if (Gyro_Start == 1)

{

unsigned int Max, Min, i, Value;

signed long Sum;

Gyro_Data_Num = 0;

while (Gyro_Data_Num <13)

{

Gyro_CollecTIon (); // AD conversion

Data collection function

}

Gyro_Start = 0;

for (i = 1, Max = 0, Min = 0xffff, Sum

= 0; i <13; i ++)

{

Value = Gyro_Data_BUF [i];

Sum + = Value;

if (Max

Max = Value;

if (Min> Value)

Min = Value;

}

Sum = Sum-Max-Min;

SUM_Test = Sum;

CarAngel_V = (((((signed long) (Sum / 10)-(signed long) Gyro_MidValue) * 10000) >> 16);

/ Limit processing /

if (CarAngel_V> 0)

{

CarAngel_V = (CarAngel_V *

1013) / 1000;

}

if (CarAngel_V <0)

{

CarAngel_V = (CarAngel_V *

1004) / 1000;

}

if (CarAngel_V> 32767)

{

CarAngel_V = 32767;

}

if (CarAngel_V <-32767)

{

CarAngel_V = -32767;

}

if (Gyro_CalibraTIon_Flag == 1)

CarAngelRate = (unsigned int)

(CarAngel_V + 32767);

else

CarAngelRate = 32767;

}

} Application of TPM module in servo motor

MC9S08DZ60 has 8 independent PWM channels. The PWM frequency and duty cycle can be independently configured. The highest frequency is the bus clock frequency of 20MHz, which can satisfy the control of the steering gear and the motor. At the same time, this module also has two counter modules, which can collect the motor speed value returned by the code wheel for use in speed closed-loop control. The PWM initialization in the motor control is as follows:

void Motor_init (void)

{

TPM2SC = 0x00; / * Stop and

reset counter * /

TPM2MOD = VV_MAX; // 15khz / * Period value setTIng * /

(void) (TPM2C0SC == 0); / * Channel 0 int. flag clearing (first part) * /

/ * TPM2C0SC: CH0F = 0, CH0IE = 0, MS0B = 1, MS0A = 0, ELS0B = 0, ELS0A = 4 * /

TPM2C0SC = 0x24;

/ * Int. Flag clearing (2nd part) and channel 0 contr. Register setTIng * /

TPM2C0V = VV_MAX / 2; // 50% duty cycle / * Compare 0 value setting * /

(void) (TPM2SC == 0); / * Overflow int. flag clearing (first part) * /

/ * TPM2SC: TOF = 0, TOIE = 0, CPWMS = 0, CLKSB = 0, CLKSA = 1, PS2 = 0, PS1 = 0, PS0 = 0 * /

TPM2SC = 0x08; / ​​* Int. Flag clearing (2nd part) and timer control register setting * /

Application of common I / O interface

The general I / O port operation of MC9S08DZ60 microcontroller can be used for logic control, display control, information collection, etc., where the configuration of each pin is relatively simple, you need to configure the direction register PTXDD, pull-up enable register PTXPE, slew rate register PTXSE and data register PTXD, take A port as an example:

Int_A ()

{

PTADD = 0X00; // As input

PTAPE = 0XFF; // Pull-up enable

PTASE = 0XFF; // The slew rate is enabled

}

When the program needs to read the data of the A port, the value of the PTAD register can be directly read out.

Conclusion

The system realizes the communication between the various modules in the smart car, fully utilizes the resources of the chip, realizes the real-time monitoring of the multi-state of the smart car, ensures the speed control and path optimization of the car model, and provides future technical development A good platform.

G Bar Vape 10000

G Bar Vape 10000,G Bar E-Cigarette 10000 Puff,E-Cigarette 10000 Puff,Disposable G Bar Vape 10000

Shenzhen Niimoo Innovative Technology Co., Ltd , https://www.niimootech.com