Design of a data acquisition device based on CAN bus
2026-04-06 05:47:03··#1
0 Introduction Modern industrial production processes are generally continuous or batch operations, thus requiring strict process control and safety measures. Data acquisition systems collect and process data in real time during production, providing production process data and dynamic monitoring. Data acquisition systems play a crucial role throughout the entire production process. Therefore, this paper presents a design method for a data acquisition device. This design utilizes the CAN (Controller Area Network) bus, which features high intelligence, high transmission efficiency, strong real-time performance, and wide applicability. 1 Introduction to the CAN Bus CAN (Controller Area Network) is a local area network control bus conforming to the international standard ISO11898. The CAN bus was originally designed by the German company BOSCH for automotive monitoring and control systems, belonging to a bus-based communication network. The CAN bus standardizes the compatibility between any two CAN nodes, including electrical characteristics and data interpretation protocols. The CAN protocol consists of two layers: the physical layer and the data link layer. The physical layer determines the electrical characteristics during actual bit transmission. In the same network, the physical layer of all nodes must be consistent, but different physical layer methods can be used. The data link layer functions of CAN include frame organization, bus arbitration and error detection, error reporting and handling, confirmation of information to be sent and confirmation of received information, and providing an interface for the application layer. Its main features are: (1) It can work in a multi-master mode, and any node on the network can become a master node and can transmit information to other nodes; (2) Non-destructive bus arbitration and error definition, the resolution of bus conflicts and error definition can be automatically completed by the controller, and it can distinguish between temporary and permanent faults and automatically shut down faulty nodes; (3) CAN nodes can be set to different transmission priorities to meet different real-time requirements; (4) Differential drive is adopted, which can be used in high noise interference environment; (5) The communication distance can reach 10 km (5Kbps), and the rate can reach 1Mbps (within 40m). 2 Structural principle of data acquisition device The data acquisition device designed in this paper takes into account various field requirements and line optimization factors. Special components were selected in the design to simplify the circuit as much as possible and improve the reliability of the circuit. This data acquisition circuit has four analog differential inputs (signal range 0-10 V) and two outputs; four digital inputs and four outputs, and one CAN bus communication port; CAN communication uses the CANOPEN protocol. This data acquisition circuit uses a single-chip microcomputer C8051F005 as the control core, together with a CAN controller SJA1000, a CAN driver 82C250, and two TLP521-4 chips to form an interface circuit with analog and digital input/output. All lines of port P1 of the C8051F005 are connected to the inputs or outputs of the two TLP521-4 chips to serve as the data interface for digital signals; all lines of port P0 serve as the address/data multiplexed bus for interfacing with the CAN controller SJA1000; and some lines of port P2 are used to control the CAN controller SJA1000. The structure of this data acquisition circuit is shown in Figure 1. 2.1 Design of Analog Input Acquisition Module Analog input acquisition is crucial to this system. To improve data acquisition accuracy and anti-interference capabilities, the analog input acquisition module adopts a differential configuration. The four analog inputs are time-division switched via an analog multiplexer. This system uses a high-speed analog multiplexer DG529, sharing a single preamplifier circuit to feed data into the C8051F005 A/D converter for conversion. This approach significantly simplifies the circuit structure and improves efficiency. The specific preamplifier circuit is shown in Figure 2. This preamplifier circuit employs a floating differential configuration to enhance data acquisition stability. The signal switched from the DG529 is first sent to the AD620 for impedance matching. Then, a high-precision operational amplifier OP07 is used, with a 1.2V level superimposed on the signal to create a floating differential configuration. After attenuation by a resistor network of R7-R10 and buffering by the operational amplifier LM258, the signal is sent to the AIN0 and AIN1 pins of the C8051F005 for phase difference before A/D conversion. Diodes D1-D4 protect the microcontroller's I/O lines. The analog output is directly achieved using the C8051F005 DAC converter and then amplified by an operational amplifier. 2.2 Design of the Digital Input Acquisition Module The digital input uses optocouplers for opto-isolation to isolate the electromagnetic connection between the front and rear channels, improving anti-interference capability, and simultaneously converting the input digital signal to the 3.3V level standard of the C8051F005. The digital output, like the input, also uses opto-isolation. The specific circuit is shown in Figure 3. 2.3 Communication Module Structure The communication system of this data acquisition unit mainly consists of a CAN communication controller SJA1000, a CAN communication driver circuit 82C250, and an opto-isolation section. The communication module is responsible for implementing the functions of the logical link control (LLC) sublayer, media access control (MAC) sublayer, and physical layer of the fieldbus architecture, completing the reliable reception and transmission of specific data. The CAN controller SJA1000 is connected to the physical bus interface chip 82C250. To protect the internal chips of the data acquisition unit and improve anti-interference capability, an optocoupler is added between SJA1000 and 82C250 for isolation. Considering the high transmission rate of the CAN network, the speed of ordinary optocouplers is insufficient. Therefore, this design selects a high-speed optocoupler (6N137) as the isolation device. Furthermore, the two power supplies used in the optocoupler circuit must be completely isolated; otherwise, the optocoupler would be meaningless. The circuit connection between SJA1000 and 82C250 is shown in Figure 4. 3. CAN Communication Design CAN bus communication uses the CANopen protocol. CANopen is a network system based on CAN serial communication. The CANopen specification covers the application layer and communication protocol subset, the construction of program devices, recommended cable and connector types, SI units and prefix interpretation, etc., thus ensuring consistency in communication, connection, specific control, and software development for CAN controllers from different manufacturers, greatly facilitating system use and maintenance. Figure 5 shows its reference model. In the CANopen application layer, device communication and application objects are exchanged. All these objects can be accessed through 16-bit indices and 8-bit sub-indices. These objects (COBs) will be mapped to one or more predefined and configured frames. Figure 6 is a schematic diagram of the access methods for each CAN protocol layer. Through object indexing, data objects can be processed and accessed more conveniently and directly at the application layer. The CAN protocol specifically includes the following aspects: (1) Identifiers use 11-bit identifiers, and the data link layer is the same as CAN2.0A. (2) Master-slave node relationship in the network A CANopen system must have one and only one master node, but can have multiple slave nodes (0~126), among which the master node has special functions such as starting the network, stopping the network, node checking, and network booting. (3) PDO protocol In the CANopen protocol, CAN data information can be regarded as a process data object (PDO), which is the standard way for devices to transmit processing information. The PDO sender can be regarded as a PDO producer, while the PDO receiver can be regarded as a PDO consumer. This communication is a one-to-many communication method. (4) SDO service SDO (Services Data Object) can provide a means to obtain the relevant status data of a specified node. When the SDO client sends a data request, the server sends a corresponding data response, which is similar to the remote data frame in the original CAN protocol. (5) Predefined Connection Sets: CANopen specifies predefined connection sets to simplify network configuration and use. (6) Sending and Receiving PDOs: CANopen specifies corresponding memory areas for sending and receiving data on the network. This is equivalent to directly manipulating addresses in C language, thus enabling completely transparent transmission of PDO data, which greatly facilitates program development. 4 Conclusion Fieldbus technology represents a major revolution in the field of automation control. The system designed in this paper is a proactive exploration to adapt to this revolution. Application practice has proven that the CAN fieldbus-based data acquisition unit is not only highly reliable but also more flexible in configuration than the commonly used PLC system. It is believed that this system will be more widely used in various aspects of industrial production.