Design of CAN Node Based on dsPIC30F6014

Publisher:rnm888Latest update time:2009-11-10 Source: 微计算机信息 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

CAN, the full name of which is "Controller Area Network", is one of the most widely used field buses in the world. As a remote network communication control method with advanced technology, high reliability, complete functions and reasonable cost, CAN-bus has been widely used in various automation control systems and has incomparable advantages.

The new 16-bit dsPIC30F6014 digital signal controller combines the control advantages of a microcontroller with the high-speed computing characteristics of a digital signal processor (DSP), providing a single-chip solution for embedded systems.

This paper is based on the CAN protocol and combines the outstanding performance of dsPIC30F6014. In the process of designing the communication interface, a CAN node design method based on the dsPIC30F6014 digital signal controller is proposed.

1 dsPIC30F6014 Digital Signal Controller and CAN Bus

1.1 Features of dsPIC30F6014 Digital Signal Controller

The dsPIC30F6014 digital signal controller (DSC) is a single-chip embedded controller that integrates the control functions of a microcontroller (MCU) and the computing power and data throughput of a digital signal processor (DSP). It can operate at speeds of up to 20 and 30 MIPS, is equipped with self-programmable flash memory, and can operate within industrial and extended temperature ranges. The dsPIC30F6014 digital signal controller, which is based on a 16-bit microcontroller, not only has powerful peripherals and fast interrupt processing capabilities, but also integrates the functions of a digital signal processor that can manage high-speed computing activities. The dsPIC30F CPU module uses a 16-bit (data) modified Harvard architecture with an enhanced instruction set that includes strong support for DSP. The CPU has a 24-bit instruction word with a variable-length opcode field. The program counter (PC) is 24 bits wide and can address up to 4M × 24 bits of user program memory space. A single-cycle instruction prefetch mechanism is used to help maintain throughput and provide predictable execution. Equipped with 144K bytes of enhanced flash memory, 8K bytes of static RAM, and 8K bytes of EEPROM, it can support large and complex applications. The dsPIC series products are different from existing embedded systems. The system integrates oscillators, low voltage detection, and watchdog timers. The products do not need to use additional components, which can reduce the motherboard area and system costs, and provide a single chip solution for embedded systems. In addition, it also has a series of on-chip functions, including I/O ports, timers, input capture, output comparison, UART, 12-bit A/D converter, SPI interface, I2C interface, and CAN communication modules. The structure diagram is shown in Figure 1:

这些特性使之成为需要更高精确度、更快转速或无传感器控制的电机控制应用领域如非传感无刷直流电机、磁阻转换和感应电机的理想解决方案,另外还可以应用于因特网接入设备和汽车产品;生物特徵检测保护--如指纹识别;不间断电源、电源管理和话音开关(话音识别系统)等领域。

1.2 CAN bus technical features

CAN is a network mainly used for monitoring and controlling various processes (equipment). It was originally designed by the German company BOSCH for automobile monitoring and control systems. Due to its excellent characteristics and high reliability, CAN is particularly suitable for the interconnection of monitoring equipment in industrial processes. Therefore, it is increasingly valued by the industry. Specifically, CAN has the following characteristics:

(1) CAN can work in multi-master mode. Any node on the network can actively send information to other nodes on the network at any time, regardless of master or slave, and the communication mode is flexible.

(2) CAN can transmit and receive data in point-to-point, point-to-multipoint (group) and global broadcast modes;

(3) Node information on the CAN network can be divided into different priorities to meet different real-time requirements;

(4) CAN uses non-destructive bus arbitrage technology. When two nodes send data to the network at the same time, the node with lower priority will actively stop sending data, while the node with higher priority can continue to transmit data without being affected, which greatly saves the bus arbitrage conflict time and will not cause network paralysis even when the network load is heavy;

(5) The maximum direct communication distance of CAN can reach 10km (rate is less than 5kbps), and the maximum communication rate can reach 1Mkbps (at this time the maximum distance is 40m).

2 CAN Node Design

2.1 CAN node hardware design

Figure 2 shows an example of a CAN bus network. The figure shows three CAN network implementation methods: microcontroller + CAN controller + CAN transceiver; microcontroller with integrated CAN controller + CAN transceiver; CAN serial I/O device + CAN transceiver. Node 1 is composed of MICROCHIP's dsPIC30F6014 integrated CAN controller + MCP2551CAN transceiver; node 2 is composed of MICROCHIP's PIC microcontroller + MCP2550 serial CAN controller with SPI interface + MCP2551CAN transceiver; the CAN node of the PC is composed of Philips' SJA1000CAN controller + PCA82C250CAN transceiver. The research and experimental results of this article are completed under this network framework.

Obviously, dsPIC30F6014 can be connected to the CAN communication network by adding CAN bus transceiver circuit, which greatly simplifies the design of the communication system and reduces the probability of interference to the communication nodes. The CAN module is connected to the physical bus through the CAN controller interface chip MCP2551. MCP2551 is a fault-tolerant high-speed CAN device that can be used as a CAN protocol controller and physical bus interface. MCP2551 can provide differential transceiver capabilities for the CAN protocol controller, which fully complies with the ISO-11898 standard, including meeting the 24V voltage requirement. Its operating rate is up to 1 Mb/s.

2.2 CAN node software design

The 3-layer structure model of CAN bus is: physical layer, data link layer and application layer. The development of the system is mainly based on the design of application layer software. The software design of CAN bus node mainly includes three parts: CAN node initialization, message sending and message receiving. Initialization program design is very important for the normal operation of CAN bus node. It mainly includes the setting of working mode, receiving mask register and receiving code register, bus timer and interrupt enable register. MICROCHIP provides developers with a wealth of development tools and application libraries, which greatly improves the efficiency of code development. Since the CAN protocol does not specify the allocation of information identifiers, different methods can be used according to different applications. Therefore, it is very important to determine the allocation of CAN identifiers when designing a CAN-based communication system. The allocation and positioning of identifiers is also one of the main items of higher-level solutions. The current popular CAN application layer protocols are CANOpen protocol and DeviceNet protocol. DeviceNet protocol is suitable for factory automation control, and CANOpen protocol is suitable for all mechanical embedded networks. For small networks (as shown in Figure 2), Modbus protocol is a good solution. Modbus protocol is a universal language used in electronic controllers. Through this protocol, controllers can communicate with each other and with other devices via a network (such as Ethernet). It has become a universal industrial standard. With it, control devices produced by different manufacturers can be connected to an industrial network for centralized monitoring. Modbus protocol supports master/slave communication as well as peer-to-peer communication. Therefore, Modbus protocol can not only support RS232 and RS485 networks, but also give full play to the performance and communication efficiency of CAN-bus networks.

3 Issues that should be noted in system application

In actual operation, CAN bus failure and frame loss during data transmission are often encountered. The main reasons for correction are as follows:

(1) In order to further improve anti-interference measures, an isolation circuit composed of high-speed isolation devices such as 6N137 should be used between the CAN controller and the transceiver. At the same time, a DC-DC module should be used to isolate the power supply to enhance the anti-electromagnetic interference capability and protect the system circuit from network influences.

(2) The two 120 ohm resistors at both ends of the bus play a very important role in matching the bus impedance. If they are ignored, the anti-interference and reliability of data communication will be greatly reduced, or even communication will be impossible.

(3) When designing software, the setting of the CAN bus timer is very critical. All controllers on the CAN bus must have the same baud rate and bit length. However, different controllers are not required to use the same master oscillator clock. If the clock frequencies of the controllers are different, the baud rate must be adjusted by adjusting the number of time shares in each segment. The following are some requirements for time segment programming:

• Propagation segment + Phase buffer segment 1 > = Phase buffer segment 2

• Phase Buffer Segment 2 > Sync Jump Width

Typically, sampling of the bit should occur around 60-70% of the bit time, depending on system parameters.

Conclusion

The innovative viewpoint of this paper is: the implementation scheme of CAN node using dsPIC30F6014 digital signal controller is introduced in detail. The research and test results show that CAN node constructed by dsPIC30F6014 digital signal controller has many excellent performances and can give full play to the functions of the node, providing a new practical scheme for CAN node design of embedded system.

Reference address:Design of CAN Node Based on dsPIC30F6014

Previous article:Design of electronic password lock based on Max+Plus II and VHDL
Next article:Design of wheel tread scratch detection system based on DSP

Latest Embedded 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号