Design and implementation of current and voltage transmitter based on CAN bus

Publisher:风清扬yxLatest update time:2013-05-23 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

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 diagram

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

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

Figure 4 Voltage detection principle.

Table 1 Voltage input correspondence table. Note: In this system design, Uref=5V.

Table 1 Voltage input correspondence table

[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.

Figure 5 System monitoring flow chart

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

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.

Figure 5 System monitoring flow chart

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

Figure 6 ADC conversion flow chart.

Reference address:Design and implementation of current and voltage transmitter based on CAN bus

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)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号