The characteristics of CAN bus and servo motor are introduced, and the communication control characteristics of servo motor based on CAN bus are discussed.
1. Introduction
CAN (Controller Area Network) bus is a serial communication local area network that effectively supports distributed control or real-time control. Due to its high performance, high reliability, good real-time performance and unique design, it has been widely used for data communication between various detection and actuators in control systems, and has become a popular application in the industrial control field.
Servo motors, with their compact structure, easy control, stable operation, and fast response, have become an increasingly important actuator in modern industrial automation systems. They are widely used in applications requiring high levels of automation and precise control of speed, position, and torque, such as printing machinery, papermaking machinery, textile machinery, industrial robots, high-speed elevators, and CNC machine tools.
The servo motors produced by the German company Lenz provide a CAN bus interface, making them easy to connect to a CAN bus for data transmission and control. This expands the functionality and application range of servo motors, enabling them to be used more effectively and flexibly in modern industrial control systems.
2. Characteristics of the CAN bus
As a network specifically designed for industrial automation, the CAN bus has the following advantages:
(1) Simple and convenient to use. Many CAN controller chips, such as SJA1000T and Philips82C250, implement most of the CAN physical layer and data link layer. When using them, users only need to do two things: initialize the CAN controller and perform data transmission and reception operations on the CAN bus.
(2) High efficiency and reliability. CAN adopts a short frame structure, with the data field length in the data frame being a maximum of 8 bytes, resulting in fast transmission speed (maximum communication rate up to 1 Mbps) and low probability of interference. Furthermore, as a multi-master bus, each node obtains bus control through bus arbitration and possesses a robust error handling mechanism, ensuring secure and reliable data transmission under various interference environments.
(3) The system has good expandability. The CAN bus is a message-oriented encoding, not a device-oriented encoding, so it is very convenient and flexible to add or remove nodes on the CAN bus, making it easy to expand the system.
3. Servo motor connected to CAN network
Lenz servo motor servo controllers provide a dedicated CAN bus interface X4, which allows them to be easily connected to CAN bus-based industrial control systems using ordinary twisted-pair cables as the communication medium, just like other CAN nodes.
Lenz's servo controllers and servo motors use a rotary transformer or photoelectric encoder to establish feedback, forming a high-precision servo control system. The servo motors upload their operating status and information to the servo controllers in real time. As nodes on the CAN bus, the servo controllers can not only communicate with the host computer and receive various operation, control, and parameter setting commands from the host computer via the CAN bus, but also exchange data quickly with each other, establishing a certain coordination or control relationship.
The host computer gains CAN bus support by connecting a CAN-enabled communication adapter card and is responsible for monitoring and managing the operation and status of the entire system. Due to the increasingly widespread application of the CAN bus in industrial control, many companies have launched interface adapter cards supporting the CAN bus, such as Advantech's PCL-841 communication card, Beijing Huakong's HK-CAN20 communication card, and Beijing Sanxingda's intelligent CAN-PC bus adapter card PCCAN, etc. Users can use these interface adapter cards to run complex communication tasks and perform digital communication and coordination management between each CAN node and the host computer.
4. Functional modules of the servo controller and data channel based on CAN bus
Lenz servo motor servo controllers feature a rich library of internal function modules, including common logic modules, arithmetic modules, signal type conversion modules, ramp function generators, phase integration modules, as well as more specialized digital-frequency input/output modules, digital-frequency processing modules, servo control processing modules, speed setting processing modules, and so on. Users can utilize these function blocks to freely configure the controller's signal flow, making it easily adaptable to different practical applications.
To enable CAN bus-based applications, the servo controller provides dedicated CAN bus function modules CAN-IN and CAN-OUT as process data channels for data transmission. CAN-IN1 and CAN-OUT1 are specifically used for communication and data transmission between the servo controller and the host computer. The CAN-IN1 input function module receives data from the host computer. CAN-IN1 has 8 bytes of data space available for user configuration, allowing it to provide various control signals, including binary signals, 16-bit analog signals, 16-bit speed signals, and 32-bit phase signals, to other internal function modules. The host computer can send commands to the CAN-IN1 module configured according to the actual application to achieve various functions such as servo motor speed setting, motor fast stop, motor forward/reverse switching, switching between normal mode speed and constant low speed, motor enable, and motor disable. Similarly, the CAN-OUT1 function module also has 8 bytes of data space available for user use and can be configured to provide the host computer with real-time information such as motor status, actual motor speed, and actual motor phase.
Function blocks CAN-IN2, CAN-IN3, CAN-OUT2, and CAN-OUT3 are used for rapid data exchange between servo controllers. By configuring the correspondence between CAN-OUT2 or CAN-OUT3 of one servo controller and CAN-IN2 or CAN-IN3 of another, a data transmission channel between the servo controllers can be established. During motor operation, various data information from one servo controller is transmitted to the other. A common example is using the speed command from one servo controller, after certain calculations, as the speed command signal for another servo controller, enabling the two servo motors to operate at proportional speeds. This feature is of great significance for the coordinated control of multiple servo motors. The host computer can also monitor this type of data information transmitted on the CAN bus.
Meanwhile, the servo controller also provides two parameter input channels and two parameter output channels. On the CAN bus, the host computer can set and modify various parameters within the servo controller through the two parameter input channels, such as the acceleration and deceleration time of the servo motor, the gearbox gear ratio, cascade coefficients, etc.; and read various parameters of the servo controller through the two parameter output channels, such as the current temperature of the servo motor, the currently configured acceleration and deceleration time, and the actual voltage and current of the motor, etc. Therefore, basically any parameter that can be found in the parameter code table of the servo controller can be read.
Through the CAN bus interface and various data channels, the servo motor can send its relevant data information to the CAN bus; at the same time, it can also receive various data information and control commands required by the servo motor from the bus.
5. CAN Communication Protocol
As a low-level network for industrial control with high real-time requirements, the CAN protocol consists of only three layers: the physical layer, the data link layer, and the application layer. The CAN communication protocol has four different frame formats: data frames, remote frames, error frames, and overload frames.
Since the CAN communication protocol only provides general requirements, practical applications require specific implementation rules. Based on the characteristics of servo motor servo controllers and following the CAN communication protocol standard, communication protocol rules for servo controllers were developed. Each information frame from the servo controller is divided into two parts: a frame header and a data field. The frame header occupies 2 bytes, with the first 11 bits being the identifier, followed by a single RTR bit, and finally a 4-bit Data Length (DLC) bit (the actual length of the transmitted data in bytes). The data field occupies 8 bytes. The 11-bit information identifier reflects the node's priority level; bus arbitration is implemented through it. The smaller the identifier of the information frame, the higher its priority. Except for special information such as bus status, the servo controller uses a specific formula to calculate the identifier of the transmitted information:
Information identifier = Base identifier + Controller node address (as set)
The node address of the servo controller can be set in the parameter code table. The servo controller has a unified specification for the reference identifier of information. For example, the reference identifier for the synchronous trigger signal is 128, the reference identifier for information from the controller's CAN-OUT1 channel is 384, the reference identifier for information sent to the controller's CAN-IN1 channel is 512, the reference identifier for information sent to the controller via parameter channel 1 is 1536, and the reference identifier for information received via parameter channel 1 is 1408.
For the 8B data field, users need to determine the usage principles to follow based on the specific information to be sent. For example, when setting parameters through the parameter channel, the first byte is the command code, the second and third bytes are the index number corresponding to the parameter, the fourth byte is the secondary index corresponding to the parameter, and the last four bytes are the size of the parameter data to be set. However, when sending information to the process data channel CAN-IN1 of a servo controller, the data information is sent directly without a command code or index number.
6. Software design of the host computer
For servo motors that communicate and are controlled via CAN bus, after configuring the internal control signal flow of the servo controller, as well as the CAN-based interface function modules and data channels according to the actual application requirements, the remaining issue to be addressed is the software design of the host computer.
Since the CAN communication adapter card connected to the host computer generally provides CAN driver functions, the communication with the CAN bus can be implemented directly using these functions during the host computer software development process. For example, the main tasks of the host computer's communication with CAN—initializing the CAN adapter card, sending CAN packets, and receiving CAN packets—all have readily available functions, facilitating CAN communication for users. Initializing the CAN communication adapter card mainly involves initializing its various registers, setting necessary parameters such as interrupt vectors, baud rate, and interrupt mask words to prepare for normal communication. Sending CAN packets requires first determining the 11-bit information identifier of the packet, filling it into the frame header, and filling the data field with the data to be sent. The packet is then sent to all CAN nodes or a specific CAN node using the send function. For CAN packets received using the receive function, their source is determined by their 11-bit information identifier. The data in the data field is processed to obtain valid information for display or storage, and control commands are sent as needed.
The host computer continuously calls the CAN drive function to send control commands or parameter setting commands to the servo controllers of each servo motor, driving the servo motors to start and stop. At the same time, it receives various data and status information from the servo controllers, such as the speed, phase, rotation direction, and torque of the servo motors, analyzes and processes it, and then sends corresponding commands to the servo controllers according to the actual control needs of the system to drive the motors, so that the operation of the servo motors always changes according to the user's requirements, thereby realizing the management and control of the servo motors.
7. Conclusion
The introduction of the Lenz servo motor CAN interface has improved the automation level of servo motors, making communication and control of servo motors in industrial control networks more convenient, flexible and reliable.
The CAN bus is being used more and more widely in modern industrial control systems, providing a broad application prospect for servo motors with CAN interfaces.