This paper introduces a CAN bus distributed measurement and control system based on the single-chip microcomputer AT89C52. It mainly describes 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 design of the CAN bus interface with the single-chip microcomputer as the core of the system, which solves the problem of using the single-chip microcomputer to store and process the measurement signals obtained by various sensors on site, and then sends the information to the CAN bus through communication with the CAN controller.
1 Technical characteristics of CAN bus network[1][2]
Communication data block encoding can realize multi-master working mode, flexible data transmission and reception mode, and multiple transmission modes such as point-to-point, point-to-multipoint and global broadcast can be realized; the conventional test and control functions of the host in the DCS structure can be dispersed to each intelligent node, and the node controller sends the collected data to the bus through the CAN adapter, or requests data from the bus, so that the host is freed from the original heavy bottom-level equipment monitoring tasks and performs higher-level control and management functions, such as fault diagnosis, optimization and coordination, etc.
Adopting non-destructive priority-based bus arbitration technology, it has the function of distinguishing temporary errors and permanent fault nodes and automatically detaching faulty nodes, so that the communication of other nodes in the system is not affected; at the same time, CAN has the function of automatic retransmission of error frames, and has high reliability;
The signal transmission uses a short frame structure (8 bytes) with good real-time performance;
nodes can be connected or removed at will without shutting down the bus, which enhances the flexibility and scalability of the system;
The use of unified standards and specifications ensures good interoperability and interchangeability between devices, and good system versatility;
The communication medium can be twisted pair cable, without special requirements; on-site wiring and installation are simple, easy to maintain, and economical.
In short, the CAN bus has the advantages of strong real-time performance, high reliability, simple structure, good interoperability, and low price. It overcomes the defects of traditional industrial buses and is an effective solution for building distributed measurement and control systems.
2 System Overall Hardware Design
First, define the function of each node, and determine the number, type, and signal characteristics of the detection or control quantity of each node. This is the first step in networking the microcomputer measurement and control system. The principle is to avoid repeated testing as much as possible. Most of the intelligent node modules are input and output modules, and the regulation 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 isolated type, self-tuning PID, and isolated 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, output increment calculation (a variety of regulation algorithms can be selected through configuration, including cascade regulation), output, and automatic identification of process parameters of the self-tuning module are implemented in this module, ensuring the safety and reliability of the regulation loop.
Secondly, select each node controller and the corresponding CAN adapter components. Since each measurement and control node has relatively simple functions and a small amount of data, the requirements for the CPU are greatly reduced, and the 8051 series microcontroller can meet the requirements. The CAN bus adapter components mainly include: controller interface, bus transceiver and I/O devices. The 82C200 CAN controller produced by Philips and the matching 82C250 CAN transceiver are used. The 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.
Finally, 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.
3. Hardware composition of the system[3][4][5]
(1) CAN bus interface module
① Microprocessor
There are two major categories of CAN bus devices that are widely used at present: 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, etc. According to the actual needs of the current market, development tools and subjects, the intelligent nodes of the system all use ATMEL 8-bit single-chip microcomputer AT89C52 as the microprocessor.
② CAN controller
The CAN controller uses SJA1000 as the controller. SJA1000 is a highly integrated CAN controller. It has a multi-master structure, bus access priority, group 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, send buffer, receive buffer, bit stream processor, bit timing logic, send and receive logic, error management logic, controller interface logic, etc.
SJA1000 has many new features: receiving and sending standard and extended structure messages; 64-byte receive FIFO; single/dual receive filters for both standard and extended frame formats; error counters with read/write access; programmable error alarm limits: the most recent error code register; each CAN bus error can generate an error interrupt; lost arbitration interrupt with lost arbitration positioning function; single-transmit mode (no retransmission when a master error or lost arbitration is sent); listen-only mode (monitoring the CAN bus, no response, no error flag); support for hot plugging (no interference software-driven bit rate monitoring). Therefore, the system's intelligent nodes all use SJA1000 as CAN controllers.
③ CAN bus transceiver
The CAN bus transceiver uses PCA82C250 as the bus transceiver. PCA82C250 is the interface between the CAN protocol controller and the physical bus. 82C250 can provide different transmission performance for the bus and different reception 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 the anti-interference measures, an isolation circuit composed of a high-speed isolation device 6N137 is used between the two CAN devices. The hardware connection between the CAN device and the microprocessor is shown in Figure 2.
The design of the hardware circuit is not too difficult, but there are several points that should be noted:
The two 120Ω resistors at both ends of the bus play a very important role in matching the bus interference. Ignoring them will greatly reduce the anti-interference and reliability of data communication, or even make communication impossible. (2005-11-28 15:07:00 Readings: 21 ) [page]
The resistor Rs between the 8th pin of 82C50 and the ground is called the slope resistor. Its value determines whether the system is in high-speed working mode or slope control mode. Connecting this pin directly to the ground will put the system in high-speed working mode. In this mode, to avoid radio frequency interference, it is recommended to use shielded cables as the bus. When the baud rate is low and the bus is short, the slope control mode is generally used. The rising and falling slopes depend on the resistance value of the resistor. Experimental data show that 15~200kΩ is the ideal value range of Rs. In this mode, parallel lines or twisted pairs can be used as the bus.
The TX1 pin of SJA1000 is suspended, and the potential of the RX1 pin must be maintained at about 0.5Vcc, otherwise, the level logic required by the CAN protocol cannot be formed. If the system transmission distance is short and the environmental interference is small, current isolation is not required. In this way, the VREF end (about 0.5 Vcc) of 82C250 can be directly connected to the RX1 pin, thereby simplifying the circuit.
In the system, the chip select signal of SJA1000 is generally obtained by decoding the address bus, and the address of each register of the CAN controller is determined from it. In practical applications, P2.7 of the AT89C52 microcontroller is used as the chip select signal. Therefore, the address of SJA1000 is: 7F00~7F32H.
When power-on reset, the power-on reset of AT89C52 needs a level change from low to high to activate, and the RST pin 17 of SJA1000 is activated, which requires a jump from high level to low level. Therefore, an inverter must be added.
(2) Data acquisition module
The data acquisition module is used to transmit the data of various sensors to the CAN bus. The entire circuit includes: watchdog X5045, microcontroller 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 collecting data, various sensors transmit the 0-5V analog quantity to ADC0809, 0809 transmits the converted digital quantity to 89C52, and finally the microcontroller sends the collected data to SJA1000 and transmits it to the bus through the CAN bus transceiver 82C250 to complete the data collection work.
(3) Control module
It is an isolated controller with CAN communication function. The module has a data input point, which can be a command or other signal, an analog output for control systems with continuously changing output actuators, such as controlling stepper motors; and a digital output for control systems with two-position actuators, 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, and the PV and SV values of the controlled object can be displayed during operation. The module can realize automatic adjustment according to the set control point and the time of rise and fall. With a CAN communication port, it can communicate with a microcomputer, that is, the control module can be connected to the CAN network system. The upper and lower control points, PID values, implementation time and other control parameters of each control point can be set for the control modules on multiple nodes through the host computer, and the measured values of each controller can be recorded in real time, and the change curve can be drawn for the experimenter to 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 three parts: CAN initialization, data sending and data receiving.
① CAN initialization
It is mainly used to set the communication parameters of CAN. The registers that need to be initialized are: mode register (Peli CAN mode), time division register, receive code register, mask register, bus timing register, output control register, etc. It should be noted that these registers can only be written during reset. Therefore, before initializing these registers, it is necessary to ensure that the system has entered 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
Each sensor on site converts and processes the detection signals (digital, analog, and switch) of multiple environmental parameters, and sends them to the send buffer of the CAN controller, and then starts the send command of the CAN controller. At this time, the CAN controller will automatically send data to the bus without the intervention of the sensor's microcontroller. 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 information frame, and the CAN controller with the smallest identifier value has priority use of 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 to start the interrupt receiving service program. The 89C52 reads the data from the receiving buffer of the CAN controller by executing the interrupt receiving service program and further processes it.
(2) Monitoring module
It integrates all functions such as data acquisition, parameter setting, and data statistical analysis. At the same time, in order to realize the operator's manual intervention in the production process, such as modifying the given value, control parameters, and alarm limits, the parameter modification function is added; in order to establish human-machine information connection and display the data transmitted from each node in graphics, charts, or other dynamic ways, this system can use any MMI (Man-Machine interface) software with a DDE (Dynamic Data Exchange) interface; in order to better manage various data, a configuration control method is adopted, which can receive DDE connection requests 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 passed to the intelligent module's fixed software through the transmission media. And the module's response is returned to the MMI software and user software as the result of the DDE operation.
5 Conclusion
The application of advanced field bus technology (CAN BUS) to the intelligent measurement and control system has greatly improved the reliability of the system; the independent development of intelligent nodes based on single-chip microcomputers that meet international standards has not only saved a lot of money, but also enabled the purchase of common similar equipment, saving a lot of R&D costs; the upper computer based on the industrial computer provides a good human-machine interface, making the operation more convenient and intuitive.
References:
[1] Lin Qiang, Yang Xianhui, et al. Fieldbus and its network integration. Measurement and Control Technology, 1999, 18 (5): 24-26
[2] Gu Hongjun et al. Industrial enterprise network and fieldbus technology and application. Beijing: People's Post and Telecommunications Press, 2002.4.265-416
[3] Xiao Hairong, Zhou Fengyu. Design of intelligent node of CAN bus system based on SJA1000 [J]. Computer Automatic Measurement and Control, 2001,9(2)
[4] Wu Kuanming. CAN bus principle and application system design [M]. Beijing University of Aeronautics and Astronautics Press
[5] Application of independent CAN device SJA1000 [J]. Journal of Nanjing Institute of Technology, March 2002
Previous article:The production of kitchen timer based on AT89C2051 single chip microcomputer
Next article:Various patterns of water lights c51 program
Recommended ReadingLatest update time:2024-11-16 17:38
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to get a multi-channel reference power supply
- TMS320F28335GPIO Example - Light up the LED
- Analysis of 2020 E-sports Contest C: The realization process of the 99-point ramp car
- MSP430F4152 development board schematic diagram
- #Power supply roadblock#Experience sharing summary
- Programming example of msp430 keypress
- Compensation Designer 2P2Z controller S domain model understanding
- Are there any recommended books for beginners in circuit development?
- MSP430 G2553 Launchpad implements capacitance measurement
- [GD32L233C-START Review] 12. Button - External Interrupt