“CAN bus is a serial communication network that effectively supports distributed control or real-time control. CAN can realize a fully distributed multi-machine system, and there is no distinction between master and slave; CAN can transmit and receive data in several ways of point-to-point, point-to-multipoint and global broadcast; CAN direct communication distance can reach up to 10km (transmission distance). The communication rate is up to 1Mbps (the transmission distance is 40m); the number of nodes on the CAN bus can reach 110.
“
Authors: Zhou Zhiguo, Xiao Pei, Cheng Sen
1 Introduction
The field bus technology that emerged in the 1990s is a fully decentralized, fully digital, intelligent, two-way, multi-node communication system structure used between field instruments and control systems and control rooms. It is a revolution in control structure; The system gives a large part of the control power to the intelligent nodes in the field, and the interactive information is transmitted through the field bus. The fieldbus control system is gradually replacing the distributed control system and becomes the mainstream system; among them, the CAN bus has high reliability, good stability, strong anti-interference ability, good real-time communication, low system cost, low maintenance cost, etc. It has a wide range of application prospects.
2. CAN bus overview
CAN bus is a serial communication network that effectively supports distributed control or real-time control. CAN can realize a fully distributed multi-machine system, and there is no distinction between master and slave; CAN can transmit and receive data in several ways of point-to-point, point-to-multipoint and global broadcast; CAN direct communication distance can reach up to 10km (transmission distance). The communication rate is up to 1Mbps (the transmission distance is 40m); the number of nodes on the CAN bus can reach 110.
CAN performs bus access arbitration based on priority, and the value in the bus is one of two complementary logical values: “explicit” or “recessive”. An “explicit” value represents a logical “0”, while a “recessive” value represents a logical “1”. When the “visible” and “recessive” bits are sent at the same time, the final bus value will be “visible”. The CAN bus value signal contains the transmission address, the so-called identifier (ID), and the identifier also has the function of identifying the priority. When many nodes start to send data together, the identifier is sent first, and each transmitter compares the transmission level with the level monitored on the bus. If they are equal, the transmitter continues to transmit; when a “recessive” level is sent , and the “visible” level is monitored, indicating that the node has lost arbitration and will not send more bits. Obviously, the lower the identifier, the higher the node priority. The CAN bus signal transmission is broadcast, and all nodes can monitor the signal on the bus. When the node monitors that the identifier of the data frame on the bus matches its own identifier, it will receive the data frame. Error monitoring and automatic isolation features ensure proper bus operation.
3. Power factor dynamic compensation system
The power factor dynamic compensation system performs real-time monitoring and dynamic compensation for the reactive power of the low-voltage power system, and indirectly monitors the power grid operation status and load power consumption status through voltage and current transformers. Under the condition of ensuring the reliable operation of the system and reducing the cost, the system adopts the system structure mainly composed of the upper computer system and the network node module, taking into account the factors of versatility, real-time and expansibility. The overall structure of the system is shown in Figure 1. The intelligent node achieves the reasonable allocation of power through the collection and detection of each analog quantity and switch quantity information, and transmits the relevant parameters to the host computer through the CAN bus controller from the CAN bus. The host computer completes fault recording, automatic data analysis, man-machine interface Display and report printing. The compensation unit is composed of a capacitor bank and a thyristor trigger circuit. It inputs the capacitor according to the solution value of the smart node to generate a compensation current and inject it into the low-voltage power grid to compensate reactive power.
4. Application of CAN bus in power factor dynamic compensation system
The upper computer system is composed of a general personal computer and a CAN bus communication interface adapter card PCCAN connected to the inside of the general PC. The system is responsible for the overall scheduling of the system, sending commands to network nodes, receiving node data, and analyzing, storing, displaying and printing node information. The intelligent node is responsible for detecting current and power, and compensating for reactive power. The intelligent node module adopts the hardware structure with 80C196KC microprocessor as the core. Intel’s high-performance 16-bit microcontroller 80C196 adopts CHMOS technology, which has the advantages of low power consumption, fast running speed and high integration. The controller hardware structure CPU does not use the customary accumulator structure, but uses the register-register structure instead, which eliminates the bottleneck effect when the accumulator exists, and improves the operation speed and data throughput capacity. These characteristics make 80C196 very suitable for the field controller with large amount of data and complex functions. CAN communication interface adopts SJA1000 communication controller and 82C250 bus receiver. SJA1000 is an independent CAN communication controller produced by PHILIPS Company, it is a substitute product of 82C200, and its pins are compatible with 82C200. 82C250 is the interface chip between the CAN controller and the physical bus, it provides the differential transmission capability of the bus and the differential reception capability of the CAN controller. The CAN hardware interface circuit is shown in Figure 2:
AD0 to AD7 of SJA1000 are time-division multiplexing address/data lines, which are connected with the system bus pins P1.0 to P1.7 of the microcontroller as the external expansion memory of the microcontroller. The INT pin of SJA1000 is connected to the HSI.0 pin. When the interrupt is enabled, once an interrupt occurs, the 16-pin INT of SJA1000 will be activated, and a transition from high level to low level occurs, and the external interrupt of 80C196KC After HSI.0 accepts this interrupt signal, the CPU immediately responds to the interrupt and turns from executing other tasks to executing the interrupt task.
The CAN bus communication interface adapter card of the host computer adopts the pcl841 board produced by Advantech. The pcl841 can run on two sets of CAN networks at the same time, providing a base address space of 4 KB and a CAN control frequency of 16 MHz. The library functions provided at the same time have seven subroutines to call:
1 caninitHW() Initializes the CAN interface
2 canExitHW() Release the CAN node
3 canReset() resets the CAN controller
4 canConfig() Set CAN command word
5 canNormalR~n() Set the CAN working mode
6 canSendMsg() send data frame
7 canReceiveMsg() accepts data frame
By calling these seven subroutines, most of the work of the CAN bus communication software can be completed, which greatly reduces the difficulty of the developer’s work, reduces the workload, and shortens the development cycle.
5. Software realization of control system communication
Because the time required for the CAN controller to send a data frame is microseconds, the timing of the compensation system control cycle is milliseconds (20ms), and the interrupt frequency of the upper computer is only a few seconds at most. Therefore, the microprocessor of each intelligent node Accept the information sent by the host computer in the external interrupt service routine, and continuously transmit data information to the host computer in the main program. According to the CAN protocol, the lower the ID identifier, the higher the priority, so by defining different ID identifiers to make The data sent by the host computer is given priority over the intelligent node. Its main program and external interrupt service routine flow chart are shown in Figure 3 and Figure 4 respectively.
Through repeated debugging, the program of the communication part has been made into a module, and the application in the actual system is good. Part of the code of the communication module program is given below (written in C96 high-level language)
main()
{
…
*CR=0x001b; /*Start reset mode, open receive, error, overload interrupt, and set
*ACR=0x02; /*Initialize the receive code register
*AMR=0xfd; /*Initialize the accept mask register
*BTR0=0x00;
*BTR1=0x14; /*Determine the baud rate, synchronization jump width, bit period length, and number of samples
*OCR=0xaa; /*Select output mode
*CR=0x001a; /*Initialization is over, SJA1000 returns to its working mode
…
cansend:
temp2=*SR&0x04; /*Query the status register
if(temp2==0x00) goto cansend;
sebuffer=(unsigned char*)0x800c;
*seid=0; /*The destination of sending data
*sedlc=i1; /*Number of sent data
for(i1=0;i1<6;i1++)
{
*sebuffer=a[i1];
sebuffer++;
} /* Send data to the send buffer
*CMR=0x05; /*Send data
wait1:
temp2=*SR&0x00;
if (temp2==0x08) goto wait1 /*Send completed or not
callms( ); /* delay
goto cansend; /* continue to send data
}
6 Conclusion
The CAN communication system has achieved practical application in the control and monitoring of the power factor dynamic compensation system after sufficient debugging. Practice has proved that CAN field bus monitoring system has the advantages of full digital communication, strong anti-interference ability, good real-time performance, high measurement and control accuracy, so it will be widely used with the development of automatic monitoring system.
The Links: SKM400GB123D G190EG01-V1 PM800HSA120