0. Introduction
Fieldbus technology and intelligent instrument technology are the two fastest growing technologies in the automation and control industry. Among fieldbus technologies, CAN bus is a rapidly developing protocol standard and has been widely used in the field of automation. This article introduces an intelligent transmission system based on CAN bus. Controller Area Network (CAN) is a data communication protocol developed by Bosch in Germany in the early 1980s to solve the data exchange between numerous control and test instruments in modern cars. CAN bus can effectively support serial communication networks for distributed control or real-time control. The communication medium can be twisted pair, coaxial cable and optical fiber.
1 System network composition
In order to meet the requirements of both centralized management and decentralized control of the control system, the current and voltage transmission system based on the CAN bus adopts a bus network topology, which is simple in structure and low in cost. The network composition is shown in Figure 1.
Figure 1 Overall structure of the current/voltage transmission system of the CAN bus.
The field CAN intelligent transmission node is based on a microcontroller and is equipped with a CAN communication interface. Its main function is to collect real-time data from various field devices and deliver the collected data to the monitoring station through the CAN bus, so that the monitoring station can obtain basic information of the collected data and conduct data analysis. The monitoring station (PC) communicates with the CAN intelligent measurement and control node through the CAN2PC bus adapter card in the slot. In this system structure, a multi-master structure is not adopted, but a one-master-multiple-slave network architecture is adopted. This method reduces the load on the network to a certain extent.
2 Hardware Design of CAN Intelligent Transmitter Node
The CAN intelligent transmitter node has the functions of field data acquisition, control and communication with the CAN bus. The node is based on the PIC18F258, an 8-bit enhanced Flash microcontroller with a CAN controller produced by Microchip with a high cost performance. The built-in CAN module is compatible with the ISO CAN performance test requirements, with a maximum bit rate of 1Mb/s and implements the CAN2.0B protocol specification. The transmitter node is mainly composed of four parts: signal conditioning unit, A/D acquisition module, microcontroller controller and CAN bus communication module. The detection objects of this intelligent transmitter node are mainly standard current signals (420mA/020mA/010mA) and voltage signals (05V/010V/±5V/±10V) used in industry. First, the current and voltage signals select the corresponding channels through the multi-way switch and enter the signal conditioning link to convert the signals into voltage signals that can be accepted by the ADC and can effectively utilize the ADC input range. The conditioned signal is converted by A/D to realize the digital conversion of the original analog signal. The data is stored in the corresponding RAM area through the I/O port of the microcontroller, and the corresponding software filtering design is performed on the data. When the upper computer issues a command to require the lower computer to send back the collected data, the lower computer uses the CAN bus interface unit to send the basic information such as the collected data to the CAN bus. Figure 2 is the overall block diagram of the system structure.
Figure 2 System structure block diagram.
2.1 Detection circuit design
Since the system requires high precision for voltage and current detection, the built-in 10-bit ADC of PIC18F258 was not used in the system design. Instead, the successive approximation 16-bit analog-to-digital converter MAX1166 produced by Maxim Corporation of the United States was used as an external ADC. In addition to the successive approximation register SAR, high-precision comparator and control logic required for the successive approximation ADC, the chip also integrates the clock, 4.096V precision reference source and interface circuit. The data bus of MAX1166 is 8-bit, so it is very convenient to connect with the currently widely used 8-bit microprocessor. In the design of this system, how to realize the design of multiple voltage and current signal detection schemes is one of the key points. [page]
2.1.1 Current detection principle
The detected current is converted into a voltage signal through the sampling resistor RSENSE built into the current detection chip MAX472. MAX951 performs signal calculation and converts it into a signal that meets the ADC analog voltage input range (0.5V). Figure 3 is a schematic diagram of the detection principle of 420mA current.
Figure 3 420mA current detection principle.
The MAX472 output current is
IOUT=ILOADRSENSE/RG1(1)
The output voltage is thus
UOUT=ILOADROUTRSENSE/RG1(2)
Where RSENSE---sense resistor
ILOAD---Detection current
RG1---Gain resistor
ROUT---OUT pin output resistance
Since the current detection circuit converts the input small signal current into a voltage signal suitable for A/D conversion. Therefore, the range of UOUT has been determined as the maximum voltage range that the ADC can allow for input. Substituting UOUT into formula (2), the ROUT value can be obtained based on the UOUT output range and RSENSE, ILOAD and RG values. The 420mA current is converted to 1.256.25V through MAX472. MAX951 performs a corresponding subtraction operation on the signal to obtain 05V. For 020mA/010mA, the ROUT resistance value can be obtained by a similar method, thereby obtaining the corresponding UOUT. 2.1.2 Voltage detection principle. The voltage signal is mainly processed by the resistor voltage division method. By making different inputs to the input terminals, the voltage after voltage division reaches the input range required by the ADC, thereby meeting the requirements of different voltage range inputs. The voltage detection principle is shown in Figure 4. According to the UO voltage, the INA, INB, and INC input ranges are calculated, and their corresponding INA, INB, and INC input methods are shown in Table 1.
Figure 4 Voltage detection principle.
Table 1 Voltage input correspondence table. Note: In this system design, Uref=5V.
[page]
2.2 CAN bus communication hardware circuit designThe CAN controller uses the built-in CAN controller of the microcontroller. Its interface circuit uses the CAN transceiver PCA82C250, power isolation module and high-speed photoelectric isolator 6N137, and adopts protection circuit. PCA82C250 is a CAN transceiver produced by Philips. It is the interface between the CAN controller and the physical bus, which is used to improve the bus drive and communication anti-interference ability. Its differential receiver has a wide common mode rejection ratio and is resistant to electromagnetic interference. It is compatible with the ISO11898 standard, with a speed of up to 1Mb/s, and is resistant to instantaneous interference in the automotive environment. It has a bus protection circuit and a current limiting circuit inside, and has a current standby working mode and a slope control to reduce radio frequency interference. PCA82C250 can connect up to 110 nodes, and the unpowered nodes have no effect on the bus.
When the signal is transmitted over a long distance on the transmission line, if there is a discontinuous impedance, reflection will occur and distort the signal. Usually, a 120Ω terminal resistor is connected at the end of the transmission line to eliminate the reflection. In order to ensure the signal quality, the interface between PCA82C250 and CAN bus adopts certain safety and anti-interference measures. The internal CANH and CANL pins of PCA82C250 are connected to the CAN bus through a 5Ω resistor, which can play a certain role in current limiting and protect the pins from overcurrent shock; a small 30pF capacitor is connected in parallel between the bus and the ground, which has certain functions of anti-electromagnetic radiation and anti-high-frequency interference; an IN4148 reverse protection diode is reversely connected between the bus and the ground to play an overvoltage protection role.
3 Software Design of CAN Intelligent Transmission Node
3.1 Main Program
System initialization mainly includes the initialization of I/O port, CAN controller, interrupt and user flag data. This process mainly configures and defines the basic resources of PIC18F258, configures the reused PORTA resources as a general digital I/O port, and sets its input and output characteristics to ensure that the input, output and control signal pins of MAX1166 are correctly configured, turn on the corresponding interrupt source, configure the CAN interface, assign the initial value to the user flag data, and the initialization process ends. After setting the corresponding data channel of the analog signal input, the microcontroller starts to detect the current and voltage signals when it is powered on. Once the upper computer sends a command to request the lower computer to send back the collected data and other related information, the lower computer immediately generates an interrupt and sends back a frame of data information. The monitoring flow chart is shown in Figure 5.
Fig. 5 System monitoring flow chart.
3.2A/D conversion module software design
A/D conversion is realized by MAX1166. The conversion process of MAX1166 can be divided into three stages: conversion preparation, analog-to-digital conversion and conversion result output. PIC18F258 simulates the control signal of MAX1166 through I/O port timing, so that MAX1166 can work normally. The specific control process of MAX1166 is shown in Figure 6.
Figure 6 ADC conversion flow chart.
[page]
2.2 CAN bus communication hardware circuit design
The CAN controller uses the built-in CAN controller of the microcontroller. Its interface circuit uses the CAN transceiver PCA82C250, power isolation module and high-speed photoelectric isolator 6N137, and adopts protection circuit. PCA82C250 is a CAN transceiver produced by Philips. It is the interface between the CAN controller and the physical bus, which is used to improve the bus drive and communication anti-interference ability. Its differential receiver has a wide common mode rejection ratio and is resistant to electromagnetic interference. It is compatible with the ISO11898 standard, with a speed of up to 1Mb/s, and is resistant to instantaneous interference in the automotive environment. It has a bus protection circuit and a current limiting circuit inside, and has a current standby working mode and a slope control to reduce radio frequency interference. PCA82C250 can connect up to 110 nodes, and the unpowered nodes have no effect on the bus.
When the signal is transmitted over a long distance on the transmission line, if there is a discontinuous impedance, reflection will occur and distort the signal. Usually, a 120Ω terminal resistor is connected at the end of the transmission line to eliminate the reflection. In order to ensure the signal quality, the interface between PCA82C250 and CAN bus adopts certain safety and anti-interference measures. The internal CANH and CANL pins of PCA82C250 are connected to the CAN bus through a 5Ω resistor, which can play a certain role in current limiting and protect the pins from overcurrent shock; a small 30pF capacitor is connected in parallel between the bus and the ground, which has certain functions of anti-electromagnetic radiation and anti-high-frequency interference; an IN4148 reverse protection diode is reversely connected between the bus and the ground to play an overvoltage protection role.
3 Software Design of CAN Intelligent Transmission Node
3.1 Main Program
System initialization mainly includes the initialization of I/O port, CAN controller, interrupt and user flag data. This process mainly configures and defines the basic resources of PIC18F258, configures the reused PORTA resources as a general digital I/O port, and sets its input and output characteristics to ensure that the input, output and control signal pins of MAX1166 are correctly configured, turn on the corresponding interrupt source, configure the CAN interface, assign the initial value to the user flag data, and the initialization process ends. After setting the corresponding data channel of the analog signal input, the microcontroller starts to detect the current and voltage signals when it is powered on. Once the upper computer sends a command to request the lower computer to send back the collected data and other related information, the lower computer immediately generates an interrupt and sends back a frame of data information. The monitoring flow chart is shown in Figure 5.
Fig. 5 System monitoring flow chart.
3.2A/D conversion module software design
A/D conversion is realized by MAX1166. The conversion process of MAX1166 can be divided into three stages: conversion preparation, analog-to-digital conversion and conversion result output. PIC18F258 simulates the control signal of MAX1166 through I/O port timing, so that MAX1166 can work normally. The specific control process of MAX1166 is shown in Figure 6.
Figure 6 ADC conversion flow chart.
Previous article:Small problems encountered by PIC microcontroller when continuously receiving serial port data
Next article:Understanding of PIC watchdog timer WDT (watch dog timer)
- Popular Resources
- Popular amplifiers
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- ZigBee Protocol Stack
- EEWORLD University ---- Fundamentals of VLSI Design (Fundamentals of Digital Integrated Circuit Design) (Southeast University)
- As long as your phone is not upgraded, it will not lag! How often do you change your phone now?
- CH340 circuit to prevent current backflow
- Bluetooth module responds incorrectly
- 【RT-Thread Reading Notes】Reflections on RT-Thread Learning Chapter 6
- LTspice(2) .TEXT uses Xnn
- 【ST NUCLEO-H743ZI Review】——by supermiao123
- How to Reduce the Temperature in Your Car's Fuse Box
- 【What should I do】Bullshit