An (Controller Area Network) is a serial communication network with high reliability and support for distributed and real-time control. Can works in Multi-master mode. Any node on the network can actively send information to other nodes on the network at any time, regardless of the master or slave node, without the need for station addresses and other node information. Flexible communication. The CAN protocol model has only three layers, namely, only the physical layer, data link layer, and application layer at the OSI underlying layer. The biggest feature of CAN is its high reliability. In case of serious errors, its nodes automatically turn off the output function, so that other operations on the bus are not affected. The maximum direct communication distance of CAN is 10 km (the speed is below 5 Kbps), and the maximum communication speed is 1 Mbps (the maximum communication distance is 40 MB at this time ). The communication media can be twisted pair wires, coaxial cables, or optical fiber cables. The number of nodes on the can depends mainly on the bus driving circuit. Currently, up to 110 nodes are supported. The standard frame message identifier has 11 bits, while the number of message Identifiers (29 BITs) in the extended frame is almost unrestricted.
1. Application of CAN Bus in ships
The Application of CAN in ships began in early 1990s. In 1994, the German MTU company successfully developed a can-based MCS-51 monitoring system, and opened a new era of CAN network ship system application. Since then, can networks have been widely used in remote control, patrol detection, power station monitoring, and fire alarm systems of ships. The successful application of the CAN network in the ship control system provides a new data transmission protocol to solve the interconnection network communication problem of the ship's equipment (sensors, actuators, control modules, the CAN controller hardware completes the functions and services of the Protocol. In a CAN network, all devices that meet the CAN protocol can be mounted through a bus that can transmit both power and data signals at the same time, and three point-to-point, one-to-many, and broadcast communication modes are provided. For the increasingly wide application of CAN in ships, the National Association for Marine Electronics (NMEA, National
Marine electrons assciation) expands the original nmea0813 protocol to form a new nmea2000 protocol, and develops a unified standard and interface protocol for CAN network applications in ships.
2. Basic Structure of the Monitoring System
In a monitoring system, measurement, control, and execution units are essential. At the same time, network hardware and Protocol controllers are also required in a basic communication network. The typical can-Based Monitoring System Structure Design 1 is shown in.
In Figure 1, the can-based monitoring system consists of the following parts:
(1) The upper PC collects all information transmitted on the bus, monitors the running status of the system, and checks the Operation Parameter Adjustment of all devices and the more time-limited audible/visual alarms and other functions. And access the network through the CAN interface card.
(2) Intelligent Measurement and Control Units (lower computer systems) include intelligent sensors, intelligent actuators, and intelligent controllers. They are installed on the measurement and control site, it is used to directly obtain the parameters of the on-site equipment or perform relevant operations and functions. Compared with traditional devices, intelligent measurement and control units are equipped with CAN controller modules that support the CAN bus communication protocol. Therefore, Unit 3 can not only communicate with the host computer system, but also receive data from Unit 1 or send data to the unit according to the system design requirements. 2. implement communication between the underlying equipment on site, this is very important for some systems.
2.1 intelligent measurement and control unit can Communication Interface Design
The Intelligent Measurement and Control Unit is mainly composed of a single-chip microcomputer, produced by cygnal. The microcontroller is a fully integrated hybrid signal system-level chip (SOC) with a fully compatible command kernel with the MCS-51. The pipeline structure is used internally. The machine cycle will be one system cycle from the standard 12 system cycles, and the peak performance will reach 25 MIPS. In addition, the CAN controller and high-speed A/D converter can be integrated in the to simplify the system design. The CAN controller is integrated with the. To run the CAN bus, the can transceiver must be connected to the single-chip microcomputer to perform electrical conversion and convert the logic signal into a balanced Differential Code. Commonly used can transceiver is the pca82c250 and high-speed TJA1050 produced by Philips. The pca82c250 is used here. It provides the differential transmission and receiving functions for the bus. It is fully compatible with the iso11898 standard and has three different working modes: high speed (up to 1 Mbps), Slope Control and standby, can be selected according to the actual situation.
The working bit rate of the CAN in can reaches 1 Mbps, and the actual rate may be limited by the physical layer of the data transmitted on the CAN bus. The can processor has 32 message objects and can be configured to send or receive data. The input data, message object, and its identity mask are stored in the CAN message Ram. All protocol processing for data sending and receiving filtering is done by the CAN controller without CIP-51 intervention, which minimizes CPU interference for CAN communication.
The CAN controller is a fully functional Bosch CAN module that fully complies with the can specifications 2.0a and 2.0b. The schematic diagram 2 of the CAN controller is shown in. The can core provides shift output, input (cantx and canrx), message string/and conversion, and other protocol-related tasks (such as data sending and receiving filtering ). Message RAM can store 32 message objects that can be sent and received on the CAN network. The can register and message processor provide interfaces for the data transfer and status notification between the CAN controller and the CIP-51.
The CIP-51 can directly or indirectly access the CAN controller registers (can0cn), can test registers (can0tst), and can status registers (can0sta) in the CAN controller through special registers ). Other registers must be accessed through indirect indexing.
2.1.1can controller peripheral hardware circuit implementation
To further improve the system's anti-interference capability, the CAN controller pins cantx, canrx, And the transceiver pca82c250 are not directly connected. Instead, they are connected to pca82c250 through an isolation circuit consisting of high-speed optical coupling 6n173, in this way, the electrical isolation of each node on the bus can be achieved. The communication physical layer circuit diagram 3 is shown.
Some security and anti-interference measures are also adopted in the interfaces of pca82c250 and CAN bus. The Canh and canl pins of pca82c250 are respectively connected to the CAN bus through a 5 Ω resistor, which can throttling to a certain extent, thus protecting pca82c250 from the impact of overcurrent. Each of Canh and canl is connected with a 30pf small capacitor, which can filter out high-frequency interference on the bus and prevent electromagnetic radiation. In addition, a 15 V transient voltage Suppression diode (TVS) is parallel between Canh and canl to protect the pca82c250 from damage at an instantaneous high voltage. The RS pin of pca82c250 is connected with a drop-down resistor. The resistor size can be adjusted according to the bus speed. The value is generally between 16 k Ω-140k Ω, and 47k Ω is selected in figure 3.
V ~ 3.6 V, all its I/O ports allow 5 V (limit value 5.8 v) input, but the I/O port output level is VDD, while pca82c250 is 5 V system, in order to be able to drive its operation, the cantx pin is connected to an upper-tension resistor with a value of 4.7kb.
2.1.2can Communication Software Implementation
The main task of the lower computer can communication is to transmit the detected data to the upper computer or other lower computer nodes. At the same time, the upper computer can set relevant parameters of the lower computer.
As shown above, the CAN node communication mainly includes system initialization, sending programs, and receiving programs. In this example, the system software adopts a structured program design scheme, so that it has better controllability and portability.
2.1.3 system initialization
The initialization program initializes all the packet objects (generally sets all values to zero), and sets the CAN controller register (can0cn) and bitreg, the sender and receiver are initialized respectively. The bit timing register settings are complex. Here, the external crystal oscillator is 11.0592 MHz, and the CAN communication rate is 1 Mbps.
(1) The general steps for initializing the CAN controller are: Set the sfrpage register to can0_page; set the init and CCE bits in the can0cn register to 1; set the timing parameters in the bit timing register and BRP extended register. initialize each message object or set its msgval to 0 (invalid). Clear init.
(2) the initialization of the sending object includes setting the command shield register for sending the message object; Setting the arbitration register; sending direction; specifying the message length and frame type; and selecting the sending message number. Some code is as follows:
Void init_msg_object_tx (char msgnum)
{
Sfrpage = can0_page;
Can0adr = if1108msk; // point to command mask register 1
Can0dat = 0x00b2; // set as write, except for the logo mask and data bit
Can0adr = if1arb1; // point to the arbitration register
Can0dat = 0x0000; // set the arbitration ID to the highest priority
Can0dat = 0xa000; // set the message's valid bit, no extended ID, and the direction is write
Can0dat = 0x0088; // The data length is 8, data frame
Can0adr = if1cmdrqst; // point to the command request register
Can0dat = msgnum; // write the message object number, that is, the message object to which the operation is performed
// 3 ~ After six can clock cycles, the content in the IF register will be moved to the message object in the can memory.
}
The initialization receiving object is similar to the sending object. You only need to change the message sending direction to receive.
(3) The can startup mainly includes setting the bit timing register, setting the command blocking register of the message object, setting the can to allow the init bit, and enabling the interrupt. The Code is as follows:
Void start_can (void)
{
Sfrpage = can0_page;
Can0cn | = 0x41; // enable the CCE and init bits
Can0adr = bitreg; // Point-to-Bit Timing register
Can0dat = 0x2640; // point to command mask register 1
Can0adr = if1108msk;
// Set can ram to write, write Data byte, set txrqst/newdat, CLR intpnd
Can0dat = 0x0087;
Can0adr = if2108msk; // point to command mask register 2
Can0datl = 0x1f; // set receiving: Read can ram, read data bytes
Can0cn | = 0x06; // global initialization of IE and sie
Can0cn & = ~ 0x41; // clear the CCE and init bits
}
(4) send and receive data. After configuring the above information, you can receive data frames on the CAN bus, execute corresponding commands or perform corresponding data processing, and send the feedback information to the CAN data register, you can send the feedback data to the host computer to process the data by notifying you that you can send a message number. The sender code is as follows:
Void can_transmit (char msgnum)
{
Sfrpage = can0_page;
Can0adr = if1data1;
Can0dat = txbuffer;
Can0adr = if1cmdrqst;
Can0datl = msgnum;
}
3 conclusion
With the continuous advancement of science and technology, the ship automation is further developed to the digital aspect. The fieldbus architecture featuring openness, dispersibility, and digital communication can fully adapt to the requirements of the ship control system. The ship Monitoring System Based on CAN Bus has good real-time performance. The CAN Field Bus Technology Control System will be widely used in more ships.
References:
[1] Rao yuntao, Yi Jijun, et al.. Fieldbus can Principle and Application Technology. Second edition. Beijing University of Aeronautics and Astronautics Press, 2007.
[2] Zhang peiren, Sun Li. Principles and Applications of the C-language c8051f series microcontroller. Beijing: Tsinghua University Press, 2006.
[3] Li Wei and others. Application of Fieldbus Technology in the cabin automation system. Ship Engineering, 2002, (2 ).
[4] Application of CAN controller in C8051F040, such as CAI Huafeng, application World, 2005, (1 ).
[5] He Yanyan equality. intelligent node design based on CAN bus of. embedded network application.