Smart test
Design of Distributed Static Force Measuring System Using 8051 Series Single Chip Microcomputer
This article introduces a CAN bus distributed measurement and control system based on the single-chip AT89C52. It mainly explains the overall design of the system, as well as the software and hardware design of the control module and the acquisition module. The focus is on the single-chip computer with CAN bus interface. It is designed to solve the problem of using a single chip microcomputer to store and process the measurement signals obtained by each sensor in the field, and then send the information to the CAN bus through communication with the CAN controller.
1. Technical characteristics of CAN bus network
Use communication data block coding to realize multi-master working mode, flexible data transmission and reception modes, and realize multiple transmission modes such as point-to-point, point-to-multipoint and global broadcasting; the conventional test and control functions of the host in the DCS structure can be distributed to each For intelligent nodes, the node controller sends the collected data to the bus through the CAN adapter, or applies for data from the bus. The host is freed from the heavy monitoring tasks of the underlying equipment, and performs higher-level control and management functions, such as faults. Diagnosis, optimization and coordination, etc.;
Using non-destructive priority-based bus arbitration technology, it has the function of distinguishing temporary errors and faulty nodes and automatic detachment of faulty nodes, so that the communication of other nodes in the system is not affected; at the same time, CAN has the function of automatically retransmitting error frames, High reliability;
The short frame structure (8 bytes) for signal transmission, good real-time performance;
You can mount or remove nodes at will without closing the bus, which enhances the flexibility and scalability of the system;
Using uniform standards and specifications, so that each device has better interoperability and interchangeability, and the system has good versatility;
Twisted pair wire can be used as the communication medium without special requirements; field wiring and installation are simple, easy to maintain, and economical.
In short, CAN bus has the advantages of strong real-time, high reliability, simple structure, good interoperability, and low price. It overcomes the shortcomings of traditional industrial buses and is an effective solution for building distributed measurement and control systems.
2. The overall hardware design of the system
First, define the function of each node, and determine the number, type, and signal characteristics of each node's detection or control variables. This is the step of networked microcomputer measurement and control system. The principle is to avoid repeated testing as much as possible. Most of the smart node modules are input and output modules, and the regulating loop can form a loop across modules. However, considering the safety of the regulation loop, in order to ensure that the loop regulation is not affected when a major failure occurs in the host computer or the entire communication line, modules with regulation functions such as isolation type, self-tuning PID, and isolation type temperature regulator are designed. Their input and output channels are all in the same module, and the underlying software is very powerful. All input processing, calculation of output increments (multiple adjustment algorithms can be selected through configuration, including cascade adjustment), output, including automatic The automatic identification of the process parameters of the tuning module is realized in this module, which ensures the safety and reliability of the regulation loop.
Secondly, select each node controller and the corresponding CAN adapter component. Due to the relatively single function of each measurement and control node, the amount of data is small, so the requirements for the CPU are greatly reduced, and the 8051 series single-chip microcomputer can meet the requirements. CAN bus adapter parts mainly include: controller interface, bus transceiver and I/O devices. The 82C200CAN controller produced by Philips and its supporting 82C250CAN transceiver are used. 82C200 has all the necessary features required to complete the high-performance communication protocol. The 82C200 with a simple bus connection can complete all the functions of the physical layer and the data link layer.
000.png
, according to the CAN bus physical layer protocol, the bus medium is selected, the wiring scheme is designed, and the CAN bus distributed measurement and control network is connected. As shown in Figure 1.
Using 8051 series single-chip microcomputer to realize the design of distributed static measurement system
3, the hardware composition of the system
(1) CAN bus interface module
① Microprocessor
There are two broad categories of widely popular CAN bus devices: one is an independent CAN controller, such as 82C200, SJA1000 and Intel 82526/82527, etc.; the other is a microcontroller with chip CAN, such as P8XC582 and 16-bit Microcontroller 87C196CA/CB and so on. According to the actual needs of the current market, development tools and topics, the intelligent nodes of the system all use ATMEL 8-bit microcontroller AT89C52 as the microprocessor.
② CAN controller
CAN controller chooses SJA1000 as the controller. SJA1000 is a highly integrated CAN controller. It has a multi-master structure, bus access priority, grouping and broadcast message functions, and hardware filtering functions. The input clock frequency is 16MHh clock, and the output is programmable. It consists of the following parts: interface management logic, transmit buffer, receive buffer, bit stream processor, bit timing logic, transceiver logic, error management logic, controller interface logic, etc.
SJA1000 has many new functions: standard structure and extended structure message receiving and sending; 64-byte receiving FIFO; standard and extended frame format have single/dual receiving filter; error counter for read/write access; Knitting error alarm limit: Near error code register; every CAN bus error can generate error interrupt; lost arbitration interrupt with lost arbitration positioning function; single-shot mode (no retransmission when main error or lost arbitration is sent); Listen only mode (monitor CAN bus, no response, no error mark); support hot swap (no interference software-driven bit rate monitoring). Therefore, the intelligent nodes of the system all use SJA1000 as the CAN controller.
③ CAN bus transceiver
CAN bus transceiver chooses PCA82C250 as the bus transceiver. PCA82C250 is the interface between the CAN protocol controller and the physical bus. The 82C250 can provide different sending performance for the bus and different receiving performance for the CAN controller. And it is fully compatible with the "ISO 11898" standard. The purpose of PCA82C250 is to increase the communication distance, improve the instantaneous anti-interference ability of the system, protect the bus, reduce radio frequency interference (RFI), and achieve thermal protection. In order to further improve anti-interference measures, an isolation circuit composed of a high-speed isolation device 6N137 is used between the two CAN devices. The hardware connection of CAN device and microprocessor is shown as in Fig. 2.
The design of the hardware circuit is not too difficult, but there are a few points that should be paid attention to:
Two 120Ω resistors at both ends of the bus play a very important role in matching bus interference. Ignoring them will greatly reduce the anti-interference and reliability of data communication, and even make communication impossible.
The resistance Rs between the 8th pin of the 82C50 and the ground is called the slope resistance, and its value determines whether the system is in a high-speed operation mode or a slope control mode. Connect this pin directly to ground, and the system will be in high-speed working mode. In this mode, in order to avoid radio frequency interference, it is recommended to use shielded cables as the bus; and when the baud rate is low and the bus is short, the slope is generally used In the control mode, the slope of rising and falling depends on the resistance value of the people. Experimental data shows that 15"200kΩ is the ideal value range of Rs. In this mode, parallel wires or twisted pairs can be used as the bus.
The TX1 pin of the SJA1000 is left floating, and the potential of the RX1 pin must be maintained at about 0.5Vcc, otherwise, the level logic required by the CAN protocol will not be formed. If the transmission distance of the system is short and the environmental interference is small, galvanic isolation can be avoided. In this way, the VREF end (about 0.5 Vcc) of the 82C250 can be directly connected to the RX1 pin, thereby simplifying the circuit.
In the system, the chip selection signal of SJA1000 is generally obtained by decoding the address bus, and thus the address of each register of the CAN controller is determined. In actual application, P2.7 of the AT89C52 is used as the chip selection signal. Therefore, the address of SJA1000 is: 7F00”7F32H.
When power-on reset, the power-on reset of AT89C52 requires a level change from low to high to activate, while the 17-pin RST of SJA1000 is activated, and a transition from high to low is required. Therefore, This must add an inverter.
(2) Data acquisition module
The data acquisition module is used to transmit the data of various sensors to the CAN bus. The whole circuit includes: watchdog X5045, single-chip 89C52, latch 74LS373, A/D converter ADC0809, CAN controller SJA1000 and transceiver 82C250. The circuit board is shown in Figure 3.
The working principle of the data acquisition module: after all kinds of sensors collect the data, the 0-5V analog quantity is transmitted to ADC0809, 0809 will transfer the converted digital quantity to 89C52, and the single-chip microcomputer will send the collected data to SJA1000 through the CAN bus transceiver The 82C250 is uploaded to the bus to complete data collection.
(3) Control module
is an isolated controller with CAN communication function. The module has a data input point, which can be a command or other signal, and an analog output for use by a control system whose output actuator is a continuous change, such as controlling a stepper motor; there is also a digital output for the actuator It is used in two-position control systems, such as switchgear. This controller can be used as a regulator alone, because a complete display window and operation buttons are provided on the module, which can set the temperature setting value, PID adjustment parameters, etc. The PV value of the controlled object can be displayed during operation. SV value.
The module can realize automatic adjustment according to the set control point and the time of rising and falling. With CAN communication port, it can communicate with the microcomputer, which means that the control module can be connected to the CAN network system. The upper and lower limit control points, PID value, realization time and other control parameters of each control point are set by the host computer for the control modules on multiple nodes, and the measured values of each controller are recorded in real time, and the change curve is drawn for the experimenter. Analyze the experimental results. As shown in Figure 4.
4, system software design
(1) CAN bus communication module
The communication software of the CAN bus measurement and control system is divided into 3 parts: CAN initialization, data transmission and data reception.
① CAN initialization
It is mainly to set CAN communication parameters. The registers that need to be initialized are: mode register (Peli CAN mode), time division register, receiving code register, mask register, bus timing register, output control register, etc. It should be noted that these registers can only be written and accessed during reset. Therefore, before initializing these registers, you must ensure that the system enters the reset state, and the initialization words of the bus timing registers of each CAN controller in the system must be the same .
② Data transmission
The sensors on the scene convert the detection signals (digital, analog, and switch) of the environment's multi-parameters, and then send them to the sending buffer of the CAN controller, and then start the sending command of the CAN controller. At this time, the CAN controller Will automatically send data to the bus, no longer need the sensor's microcontroller to intervene. If there are multiple sensor CAN controllers in the system sending data to the bus at the same time, the CAN controller will arbitrate through the identifier in the message frame, and the CAN controller with the identifier value has the priority to use the bus.
③ Data reception
When the CAN controller in the entire greenhouse microcomputer measurement and control system detects that there is data on the bus, it will automatically receive the data on the bus, store it in its receiving buffer, and send a receiving interrupt to the 89C52 microcontroller, start the interrupt receiving service program, and 89C52 passes Execute the interrupt receiving service program, read data from the receiving buffer of the CAN controller, and perform further processing on it.
(2) Monitoring module
integrates all data acquisition, parameter setting, data statistical analysis and other functions. At the same time, in order to realize the manual intervention of the operator in the production process, such as modifying the given value, the control parameter and the alarm limit, etc., the parameter modification function is added; in order to establish the human-machine information connection, and the data transmitted from each node can be Graphics, charts or other dynamic methods are displayed. This system can use any MMI (Man-Machine interface) software with DDE (Dynamic Data Exchange) interface; in order to better manage various data, a configuration control method is adopted, which can Receive the DDE connection request from MMI software and user software, and pass the request to the communication driver part, which is converted by the communication driver into a communication signal and transferred to the firmware of the intelligent module through the transmission medium. And the response of the module is returned to the MMI software and user software as the result of the DDE operation.
5 Conclusion
The advanced field bus technology (CAN BUS) is applied to the intelligent measurement and control system, which greatly improves the reliability of the system; independently developed an intelligent node based on a single-chip computer that meets international standards, which not only saves a lot of money, but also allows the purchase of general similar equipment , Can save a lot of research and development costs; the upper computer based on the industrial computer provides a good man-machine interface, which makes the operation more convenient and intuitive.