Design of truck voice alarm based on CAN communica

  • Detail

Design of truck voice alarm based on CAN communication

automotive diagnosis technology is an indispensable part of automotive safety technology. It can give a voice alarm in time when a car breaks down, so as to avoid accidents. Can (controller area network) is one of the most widely used field buses in the world. Due to the excellent characteristics of CAN bus technology, it is widely used in automotive electrical system and some other real-time control units. A communication network based on CAN bus has the advantages of high speed, strong noise resistance and good versatility

the truck voice alarm system based on CAN bus technology designed by us can provide a safe driving environment for car passengers. The voice alarm system adopts Motorola's m68hc908gz16 microcontroller, which has small size, complete resources and high cost performance

can bus bit timing

can bus adopts synchronous serial communication mode, and the characters in the data stream and the bits within the characters are synchronized, which requires both the receiver and the sender to control the sending and receiving of data with synchronous clock. To keep bit synchronization in a fairly long data stream, the receiver must be able to identify when each binary bit starts, which is bit timing. Generally, in order to ensure the strict consistency between the receiver clock and the transmitter clock, the receiver extracts the synchronization signal from the data stream through the demodulator, or the receiver and the transmitter use a unified clock. But even so, it is still difficult to solve the problem of bus transmission delay. To solve the above problems, bit timing of CAN bus improves bit encoding/decoding

can bus bit timing is composed of four parts: synchronization segment (sync_seg), propagation segment (prop_seg), phase segment 1 (phase_seg1) and phase segment 2 (phase_seg2). The synchronization section is used to synchronize the nodes on the bus and wait for a skip edge in this section; The propagation section is used to compensate the physical delay time in the network; Phase segment 1 and phase segment 2 are used to compensate phase error. Read the bus level at the sampling point

m68hc908gz16 microcontroller (see Figure 1) has a built-in can controller, which provides a baud rate control register; SJW (resynchronization jump width) determines the time quantum in which one bit time is extended or shortened during a resynchronization; BRP is the baud rate pre division coefficient; SPL (sampling mode bit) determines the number of significant bits sampled

Figure 1 the internal structure of mc68hc908gz16

bit timing is mainly used to define the communication rate of CAN bus. For each node on the same bus, on the one hand, it is necessary to organically combine enterprise related charge management with deepening the reform of "release management service" to define the same communication rate, otherwise communication cannot be carried out. The calculation formula of bus working frequency of CAN controller is as follows:

, in which: BRP is the pre frequency division factor of the system, and its value range in tseg1 domain is 0 ~ 63; The values of tseg1 and tseg2 are determined by bit timing register programming, and meet 1 ≤ tseg1 ≤ 7, 2 ≤ tseg2 ≤ 15. The setting of median timing of the alarm defines the communication frequency as 250kb/s. Set dsc=brp=1, tseg1+tseg2=5, the system crystal oscillator frequency is 8MHz, that is, xtal=8mhz, and the can communication frequency is 250kb/s calculated from the above formula

the last bit timing setting result is: brp=1, tseg2=2, tseg1=3

Figure 2 voice alarm system structure

design overview

the design goal of the truck voice alarm system is: low cost; Powerful function; Suitable for daily application; It can be applied to all kinds of vehicles. The system can realize the following functions: using can network to receive truck fault codes; 2、 By recognizing the signal transmitted from the can system, and processing the signal to get the corresponding voice prompt, through the connection with the voice chip to realize the corresponding fault voice playback alarm

the voice alarm system takes Motorola's mc68hc908gz16 processor as the core, and uses its rich interface expansion to use peripheral modules such as voice playback and can communication interface, making the product design more humanized. Mc68hc908gz16 processor has the following advantages:

1 Rich hardware resources

mc68hc908gz16 is a flash MCU with 16K flash storage space and 1K RAM storage space inside. There is a phase-locked loop circuit inside, which can make the bus frequency up to 8MHz when using a low-speed crystal oscillator. At the same time, it has up to 37 general i/o ports, which can be easily connected with other peripheral devices

Figure 3 schematic circuit diagram of truck alarm

2 Strong anti-interference ability

can controller is integrated inside, and can communication has strong anti-interference characteristics, which ensures that the product can operate efficiently and stably in harsh environmental conditions

this design adopts can communication to complete the design of truck voice alarm system, and the system structure is shown in Figure 2

data communication is realized through mscan08 module integrated on mc68hc908gz16. Using the i/o port of c68hc908gz16, we used the ISD digital voice chip of ISD company, which is common in the market. The chip adopts 3V DC power supply and can record and save voice information for 2min. The sampling frequency is 8kHz, and the information resolution can reach 200ms, which can reproduce speech, music, tone and effect sound very realistically

hardware design

it can be seen from Figure 3 that the truck alarm circuit is mainly composed of three parts: microcontroller mc68hc908gz16 (internally integrated mscan08 module), voice chip ISD4002, and can bus transceivers tle6250 and zjys. The microcontroller is responsible for the initialization of mscan08 module, and realizes the communication tasks such as data receiving and sending through can module. The can communication control module mainly completes the communication protocol of can. The can control module can complete all functions of the physical layer and the data link layer, and is suitable for automobiles and general industrial environments. Using can communication can not only reduce the wire connection, but also enhance the ability of diagnosis and monitoring

can transceiver tle6250 is used to provide the driving ability of bus differential transmission and reception, and has the advantages of best matching of output signals canh and canl, lower electromagnetic radiation, no standby mode, etc. Two 25pf small capacitors are connected in parallel between canh and canl and the ground, which can filter out high-frequency interference on the bus and prevent electromagnetic radiation

software description

software programming mainly realizes two functions: using the bus to receive fault codes; The corresponding voice fault alarm is realized by converting the fault code. Voice playback is designed according to its function. Most operations of the whole program are completed in the main program, while can reception is completed in interruption

the operation in the main program is to initialize each register and i/o port, and then carry out corresponding processing according to the flag bit in the dead cycle. The specific process is shown in Figure 4

Figure 4 main program flow chart

1 Voice module software design

ISD4002 chip is used in the voice module. The single chip microcomputer establishes a connection with ISD4002 through i/o interface, and controls the address of voice playback through command word, so as to realize the control of voice playback

n communication module software design

when programming can bus, a series of control word configurations need to be defined and configured on the device. The specific steps include: defining the can control register, defining the bit timing, defining the shielding mode of the information body, initializing the information body, sending data and receiving data of the information body

(1) initialization of mscan08 module

initialization of mscan08 module and food flexible packaging is mainly to define the communication rate. Configure the bit timing register to determine the communication rate of can, configure the global mask register to determine the filtering strategy, and initialize each information body. To initialize the message body, you need to determine the message body type (send or receive), and set the ID, SRR, IDE and RTR that conform to the CAN protocol. Can communication must be initialized first. After the initialization of the mscan08 module is completed, the mscan08 module can return to the working state for normal communication tasks

(2) data receiving and sending

message sending is completed independently by the CAN controller. The microcontroller only needs to transmit the sent data to the corresponding sending information body of the sending mscan08 module, and then set the "sending request" flag in the command register. The flow chart of message sending is shown in Figure 5. Make judgment before sending. The sending program is divided into sending remote frames and data frames. The remote frame has no data field, and its program flow chart is shown in Figure 5 (left)

Figure 5 can sending and receiving flow chart (sending flow on the left and receiving flow on the right)

the receiving of mscan08 module is very flexible. If the meaning of ID is specified according to the CAN bus application layer protocol, the required data can be received into the message buffer by setting 3 mask registers (1 global and 2 special), and the unnecessary data can be filtered out, and then the meaning represented by the data can be determined by reading the ID of the current message buffer. There are two main ways to receive an82527 message: interrupt mode and query mode. Interrupt mode is adopted in this system. The message receiving flow chart is shown in Figure 5 (right)


the truck voice alarm system has been tested on the bench, and has achieved good communication effect with other controllers in the bench experiment, which can achieve good voice alarm function. In addition, the design needs further real vehicle verification, and its basic design idea can also be applied to cars not only because of its technical advantages. (end)

Copyright © 2011 JIN SHI