Introduction of dual cores
At the beginning of the design of the smart car, we analyzed that the most important thing in the design system of the smart car based on photoelectric sensors is the integrity of the signal, 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.
Dual-core communication interface SPI
During the operation of the vehicle, the information of three sensors needs to be collected by the controller, namely photoelectric sensor, speed sensor, and angular velocity sensor. Since the angular velocity sensor needs an accurate sampling cycle, we use the internal timer of the microcontroller to generate a 1.2ms time base. In this 1.2ms cycle, data collection of the three sensors is performed, and the SPI data transmission program is executed once when the timer overflows and interrupts. SPI is a high-speed, full-duplex, synchronous communication bus , and only occupies four lines on the chip pins, namely mosi, miso, sck, and ss. We use a data transmission speed of 1MHz, use 3 bytes to send sensor data, and two bytes to send data from speed sensors and angular velocity sensors.
Communication interface SCI between control system and host computer
The running status of the vehicle during driving cannot be obtained directly by observation, so we use the host computer system for real-time monitoring. Use wap200b wireless serial port module to send data. The module is powered by 3.0V, has a built-in high-speed MCU , and has high data transmission accuracy. The communication between the microcontroller and the module uses a standard serial port, which is set to 115200 baud rate, 8 data bits, 1 stop bit, and no parity check. A total of 7 data are sent in one communication. First, two data are sent as handshake signals, which are 0x00 and 0xFF respectively. Then 3 bytes of data are used to send sensor information, 1 byte of data to send angle information, and 1 byte of data to send speed information. The last bit is reserved for future expansion and 0x00 is sent.
The communication interface I2C between the keyboard and the main control chip
has many parameters that need to be debugged continuously during actual debugging, such as PID parameters, vehicle turning angles and speeds. If you re-download the program every time to set different parameters, it will be time-consuming and laborious, so here we use the keyboard to enter the parameters when the vehicle is driving. The keyboard control chip HD7279 is an intelligent display driver chip with a serial interface that can simultaneously drive 8-bit common cathode digital tubes (or 64 independent LEDs ). The chip can also connect to a keyboard matrix with up to 64 keys. A single chip can complete all the functions of LED display and keyboard interface.
We use the 4 I/O ports of the microcontroller to operate HD7279, namely CS, CLK, DATA, and KEY. Here we can set some parameters through the keyboard, such as the Kp, Ki, and Kd parameters of PID, the speed of straight lines and curves, 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 . Since the cost of analog gyroscopes is relatively low, and the requirements for angle accuracy in the car model control system are not very high, analog gyroscopes are used to correct the body posture in real time. MC9S08DZ60 integrates a 12-bit digital-to-analog conversion channel. Since the output signal range of the analog gyroscope is 0~5V, the reference voltage of the microcontroller is +5V, which is powered separately by a high-precision voltage regulator module to ensure the accuracy of the conversion. The data processing program 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();//Data collection function after AD conversion
}
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);
/Limiting 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 PWMThe channel can independently configure the PWM frequency and duty cycle, with the highest frequency being the bus clock frequency of 20MHz, which can meet the control of the servo and motor. At the same time, this module also has two counter modules that can collect the motor speed value returned by the encoder for 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 ordinary I/O interface The
ordinary I/O port operation of MC9S08DZ60 microcontroller can be used for logic control, display control, information acquisition, etc. The configuration of each pin is also relatively simple. It is necessary to configure the direction register PTXDD, pull-up enable register PTXPE, slew rate register PTXSE and data register PTXD. Take port A as an example:
Int_A()
{
PTADD=0X00;//as input
PTAPE=0XFF;//pull-up enable
PTASE=0XFF;//slew rate enable
}
When the program needs to read the data of port A, it can directly read the value of the PTAD register.
Conclusion
The system realizes the communication between modules in the smart car, makes full use of the chip resources, realizes the real-time monitoring of multiple states of the smart car, ensures the speed control and path optimization of the car model, and provides a good platform for future technological development.
Previous article:Design of vehicle acceleration test system based on single chip microcomputer
Next article:Design of Embedded Vehicle Navigation System Based on Linux
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- ADI Think Tank Secrets New Release丨High Speed Circuit Design Guide is now available for download
- 【LAUNCHXL-CC1350-4】- 1: Install CCS on Ubuntu 20.04
- Is there any circuit with PWM input and 0-10V output? The RC filtering solution is not fast enough.
- Today’s live broadcast: Infineon’s system solutions make electric motorcycle design more reliable and efficient!
- [ESP32-S2-Kaluga-1 Review] MQTT component connection to OneNet
- Review summary: RTT & Renesas high-performance CPK-RA6M4 development board
- Two methods of chip unpacking
- MSP430FR25x2 Capacitive Touch Sensing Mixed-Signal Microcontrollers
- Analog circuit basics: from system level to circuit level
- HyperLynx High-Speed Circuit Design and Simulation (II) Reflection due to unequal transmission line impedance and power supply impedance