System functions and applications
The system sends various status information (such as sensor light-off, speed, steering wheel angle, and battery power) during Smart car driving to the host computer in real time through wireless serial communication, and draw a curve of the Status values of each part about time. With these curves, it is not difficult to see the status of the Smart Car in various positions on the track, and the advantages and disadvantages of various control parameters will be clear at a glance. It is particularly important to select the PID parameters for motor control. Through the speed-time curve, the differences between the PID parameters can be easily found. For a team using CCD sensors, the system becomes the eyes of the debuggers. You can see what smart cars see.AlgorithmIt is very helpful. In addition, the data can be further processed, for example, the first derivative can be obtained to obtain more information.
System Hardware and Software Design
The design scheme is divided into three parts: On-board data collection system, wireless data transmission system, and host computer data processing system. System basic build 1 is shown in.
Figure 1 Structure and flowchart of the intelligent real-time monitoring system
On-board Data Acquisition System
The on-board data acquisition system is mainly used by single-chip microcomputer to collect the speed, sensor status, battery voltage, steering wheel angle and other information during driving. In order that the monitoring system does not occupy the internal resources of S12 single chip microcomputer and supports hot swapping, we separate the monitoring system except power supply from the smart car control system. We chose ATMEL's ATmega16 microcontroller as the processor of the data collection system. The I/O port of the single-chip microcomputer is used to collect the signal of the binary photoelectric sensor, continuous Photoelectric Sensors, battery voltage, and CCD camera signals are collected using the/D port of the single-chip microcomputer. The speed information is collected by the photoelectric encoder and the counter of the single-chip microcomputer. The collected data is sent to the host computer every 20 ms.
Wireless Data Transmission System
The lower computer transmits a set of Optical Encoder values (speed), battery, angle, and current sensor STATUS (sensor) to the upper computer every 20 ms) in the ideal state, the host computer should receive the cyclical data of the above values, in this case, the upper computer only needs to load the data in order into their respective arrays and draw a picture. However, data may be lost during wireless transmission. Therefore, it is necessary to add appropriate data verification. Otherwise, data loading errors may occur, resulting in confusion in drawing. In practice, we add the frame headers 0x00 and 0 x ff to each group of data. In case of data errors, the frame data is discarded.
The wireless transceiver part of the data adopts the qc96 wireless transceiver module of Sunray. This module can send and receive serial data with a baud rate of 100 bps, up to M.
Data receiving and processing on the upper computer
The host computer consists of four modules:
· Data receiving module
Function: the upper computer collects raw data sent by the lower computer through a serial port.
Implementation: There are two methods to implement serial communication in VC ++: MSComm control and Windows API function. MSComm is simple and easy to use. It is suitable for simple systems. Windows API functions are widely used but complicated and complicated. The system uses the former because the serial communication function of this module is relatively simple. In the actual process, the event-driven approach is used. This method provides timely response, high reliability, and consumes less resources than the query method.
· Storage module
Function: You can directly store the collected raw data for further analysis and processing.
Implementation: after each oncomm event is triggered, the data received by the serial port is directly stored in the temp temporary file, in addition, you can store the values in the temp temporary files to the specified files as required.
· Data analysis and processing module
Function: analyze and process the collected raw data, including discarding error data, removing frame headers, and loading data, you can also analyze and process saved data.
Implementation: Read and load data from temp temporary files or specified files.ProgramCode:
Void cchuankokjdlg: find_data (car_data c_data [], byte c_source [], int c_length)
{
Int I = 0;
While (I <c_length-6) // prevents subscript out of bounds
{If (c_source [I] = 0x00) & (c_source [I + 1] = 0 xff) & (c_source [I + 6] = 0x0 0) & (c_source [I + 7] = 0xff) // judge the frame header and load data
{
C_data [length]. speed_data = c_source [I + 2];
C_data [length]. battary_data = c_source [I + 3];
C_data [length]. direction_data = c_source [I + 4];
C_data [length]. sensor_data = c_source [I + 5];
I = I + 1;
}
Else
I ++;
}
}
· Graphic Display Module
Function: displays the processed data in a graphical interface to observe the running status of smart vehicles more intuitively.
Implementation: The data loaded into each array in the previous module is drawn in the user-selected mode. You can view only one image, or put the four images together for comparison and viewing. The actual running interface and result 2.
Figure 2 graphic display interface running Module
Conclusion
By adding a wireless transceiver module, the system transmits the real-time status information of the Smart car to the host computer. Through VC ++ programming, the system visually presents the Smart car with images, the real-time monitoring of Smart Car status is achieved, which greatly facilitates the adjustment of Smart Car parameters such as PID and provides great help for the study of the track memory algorithm.
(Source: World of electronic products)