1 Introduction
In the process of developing automobile instrument testing equipment, it is very important to realize the serial communication between industrial control computers and automobile instruments. Through serial communication, a series of important inspection items and parameter settings before the instrument leaves the factory can be realized, such as the detection of instrument software and hardware versions, instrument mileage reset and instrument adjustment. Corresponding to the "New Jetta" type automobile combination instrument (Siemens VDO company product), in order to achieve technical safety, its serial port adopts a non-standard serial communication protocol, which is difficult to achieve with general serial port communication controls. The communication program must be written from the bottom by personnel familiar with the instrument software structure.
This article adopts C++Builder development platform, and successfully realizes the communication with the "New Jetta" type automobile combination instrument under Windows 98 operating system, and has a beautiful and simple user interface.
2 Brief description of serial communication requirements of NewJetta type instrument
2.1 Hardware connection
The hardware connection between the industrial control computer and the instrument in this article is to connect the K-line of the instrument to the RS-232 serial port of the industrial control computer through a level converter, using half-duplex serial asynchronous communication mode. As shown in Figure 1.
2.2 Software Specifications
The software specifications for serial data communication protocols include communication handshake, multiple checks, error retransmission, timeout processing, etc.
2.2.1 Communication Initialization
When the instrument ignition signal end is started, the communication response can be established about 2 s later. First, send information at a 5 b communication rate. The information includes 1 start bit, 7 data bits, 1 parity bit and 1 stop bit (send **H to the instrument).
After receiving the information, the instrument will wait for a cycle time of about 5 ms, and then the communication module will start. From this point on, all communication bytes will be sent and received at a baud rate of 10 400 b/s (this baud rate is a non-standard baud rate).
After 100 ms, the instrument sends out the synchronization byte (1 start bit, 8 data bits, 1 stop bit, **H), and after another 10 ms, the instrument sends out the low byte of the password. After 10 ms, the instrument sends out the high byte of the password (1 start bit, 7 data bits, 1 parity bit, 1 stop bit, the password value is **H).
After that, the instrument waits for the industrial computer to send back the reversed password high byte. This return method is the error prevention mechanism of this serial communication. If the instrument does not receive this byte, the instrument will send the synchronization byte and password byte again.
When the instrument receives the return byte, the standard module communication starts at a baud rate of 10400 b/s (each byte contains 1 start bit, 8 data bits, and 1 stop bit). At this time, the instrument starts to send the instrument ID. During the transmission process of these 4 modules, there are many information response requirements between the instrument and the industrial computer. If there is an error, the communication will be terminated.
2.2.2 Normal communication process
After the communication is initialized, normal communication begins to be established at a baud rate of 10400 b/s. At this time, the industrial computer can send a command byte stream to the instrument to control the instrument and set parameters. At a specific time interval, the instrument and the industrial computer must still send handshake signals to each other, otherwise the communication will be terminated.
3 Software Program Design
This communication method belongs to zero-modem serial asynchronous communication. In asynchronous communication, character format and baud rate are two important indicators. The communication process in this article involves changes in both baud rate and frame format, and there are strict requirements on the response time of communication.
In the C++Builder visual programming format, functions that directly operate on registers are no longer supported, so the Inporb and Outporb functions are first implemented using embedded assembly. The data flow of this communication is sent in bytes, so a byte receiving and sending function is written as a query method, such as
4 Conclusion
This paper successfully developed a special serial port communication program for instruments using the C++Builder software platform. The system has been put into use in the production line of Siemens VDO (Wuhu) Company for more than a year. Compared with the fast communication method, the communication transmission performance is stable and it has a convenient and beautiful user interface. It has laid the foundation for the realization of instrument detection equipment and has important application value.
|