1. Introduction
To address the problems of complex wiring, limited control options, and low reliability in remote control of servo motors, a novel method for servo motor control using the CANopen communication protocol and driver sub-protocol is proposed. The object dictionary and message format of the CANopen protocol are analyzed, and the transitions of each step in the CANopen servo control state machine are detailed, along with the message settings for implementing PP, PV, and HM servo control modes under the CANopen protocol. An experimental platform was constructed using a CAN card, a servo drive device, and a PC. Control of the servo motor in PP, PV, and HM modes based on the CANopen protocol was successfully implemented via message settings on the host computer interface. Experimental results demonstrate that controlling the motor using the protocol's message settings is simple and easy to operate, with fast and reliable communication data. Users can effectively monitor the servo motor through the host computer.
2. System Overall Architecture
The entire control system consists of a PC, a CANopen host computer, a USBCAN adapter, and servo drive devices. The CANopen communication part is implemented using the DS301 protocol, and the servo control part is implemented using the DSP402 protocol.
The servo drive device, acting as a slave node, has CANopen communication capabilities and is responsible for controlling the motor's current, speed, position, and other parameters. It connects to the bus via a communication interface and transmits information to the host computer interface. The host computer interface then controls the servo drive device through a USBCAN adapter based on the feedback information from the slave station.
The overall system architecture for servo control is shown in the figure.
3. CANopen Servo Control Principle
1) CANopen communication device model
CANopen's device model is divided into three parts: communication unit, object dictionary, and application process. Users can use this model to describe devices with completely different functions.
The core concept of CANopen is the object dictionary, which contains all the parameters describing the device and its network behavior. Both application units and communication units can query this parameter list. Parameters in the object dictionary are identified and located using a 16-bit index and bit sub-indexes.
The communication section consists of a CAN transceiver, a CAN controller, and a CANopen protocol stack. The protocol stack defines communication objects for implementation: NMT (Network Management Message), PDO (Process Data Object), and SDO (Service Data Object). Predefined messages or special function objects (including synchronization messages, emergency messages, time stamp objects, etc.) describe all communication content and functions, and all communication between devices is accomplished through these communication objects. Specifically, NMT is used for master station status management of slave stations and for slave stations to respond to their own communication status. SDO is used by the master station to configure and monitor the object dictionary of slave stations. PDO is used to transmit high-speed, small data. Special function objects are used to synchronize communication objects (usually PDOs) in the network.
The application section defines and describes the basic functions of the device. It serves as the link between the device and the host computer. Its core function is to configure parameters, control and monitor the device's status by accessing the device's object dictionary, and to transmit the device's process data information at high speed.
2) Servo control mode
The CANopen driver and motion control device sub-protocol DSP402 requires very precise descriptions of characteristics. It not only defines the driver's operating mode, but also the state machine used to control the driver.
The driver state machine is controlled by control word 6040 in the object dictionary and reads the driver's state through status word 6041. The control state machine is shown in the figure.
For remote control of servo motors, the servo control mode based on CANopen is implemented. The state machine can be divided into three parts: "PowerDisabled" (main power off), "PowerEmbedded" (main power on), and "Fault". All states enter "Fault" after an alarm occurs. After power-on, the driver completes initialization and then enters the SWUTCH_ON_DISABLED state. In this state, CAN communication is possible, and the driver can be configured. The main power is still off, and the motor is not energized. After StateTransitions 2, 3, and 4, it enters OPERATIONENABLE. At this point, the main power is on, and the driver controls the motor according to the configured operating mode. StateTransition 9 completes the shutdown of the main power circuit. Once the driver triggers an alarm, the driver state enters Fault.
PP mode (simplified position mode) is a typical positioning mode, which can control the motor to the target position through single-step setting and continuous setting. PV mode (simplified speed mode) is a speed control mode, and HM (homing mode) provides multiple methods to reach the starting position.
4. System hardware and software implementation
1) System Hardware Setup
This design uses USBCAN, servo drive devices, and a PC to build the hardware platform. The servo drive control chip is a DSP chip.
The system hardware setup is performed according to the following steps. First, configure the relevant parameters in the TI development environment and create a DS301 project, completing the debugging and running of the CANopen protocol communication program. After successful project debugging, download the program to the driver, set the messages in the host computer interface, and test communication objects such as SDO, PDO, and NMT. If the test results are correct, the system hardware setup is complete.
2) System software design
The entire servo control software design is built in CCS, mainly including two parts: the closed-loop control program of the permanent magnet synchronous motor and the implementation of the CANopen protocol.
The initialization section mainly completes the initialization of the DSP system and the CANopen communication.
The initialization process mainly involves the following tasks:
Initialize relevant variables, enable global interrupt, and use the UVW signals from the servo motor encoder Hall sensor to determine the initial electrical angle position of the motor.
The main tasks performed during communication initialization are as follows:
Set the slave node address and CAN communication baud rate, initialize each communication object, complete the predefined mapping of each channel, and finally enter the communication processing program.
3) Servo control message settings
The CANopen message structure consists of an 11-bit COB-ID and a data field of up to 8 bytes. In the host computer interface, the NMT message is used to set the slave station to enter either a pre-operation or running state. Then, the SDO message is used to set various servo control parameters (speed, position, etc.) and the various states of the state machine, allowing the motor to operate according to different control modes. Finally, by mapping the motor's current parameters to the PDO, reading the PDO message value, and comparing it with the set value, the correctness of the control result is determined. All control messages are implemented using SDO.
1. List of PP mode control messages, see table.
2. PV Mode Control Message List
Implementation of servo control mode based on CANopen for remote control of servo motors
3. HM mode message list
All three control modes involve first setting the servo control mode, then sequentially inputting the relevant target control values (such as position, speed, homing method, etc.) according to the current mode, and finally using the 6040h to control the motor start and stop according to the state machine steps.
5. System control mode verification
The host computer interface of this system consists of two parts: the USBCAN host computer interface and the motor monitoring interface. The USBCAN host computer interface serves as the CANopen message data monitoring interface, while the motor monitoring interface is developed using VB2008. In the host computer interface, the communication baud rate is set to 1Mbps, the servo motor Node-ID is set to 1, the heartbeat cycle is 1s, and the TPDO transmission cycle is 100ms. The parameters for the motor current loop, position loop, and speed loop are also set. The configured messages are sequentially input into the SDO control on the host computer interface. The motor starts and runs to the set values in the messages. The values displayed on the motor manual remote control are consistent with the set values, and the values displayed in the messages on the host computer interface are also consistent with the set values, successfully achieving servo control.
1) Position control curve in the PP mode motor monitoring interface,
After setting the message values in the host computer interface, the motor starts. The motor first accelerates, and after reaching the set target speed, it begins to run at a constant speed until it reaches the set target position value, at which point it stops changing. The process data on the host computer is consistent with the changes in the motor monitoring curve. If it is necessary to change the motor position value, new control messages are entered sequentially in the host computer interface. The motor will then rotate forward or reverse according to the set value and continue running to the new position.
2) In PV mode, the motor first accelerates to the set target speed value, and then operates at the set speed. If it is necessary to change the operating speed, a new speed value can also be entered in the host computer interface.
The changes during acceleration are as described above. During deceleration control, the motor decelerates until it reaches a certain speed and then stops. The changes in the host computer data are consistent with the changes in the motor monitoring curve, as shown in the speed control curve.
3) In HM mode, the motor first accelerates to the set speed, then searches for the origin position. After finding the origin, the motor returns to zero and decelerates until it reaches the set speed. At this point, the current position value of the motor can be checked on both the host computer interface and the motor's manual remote control servo motor. The current position indicates that the motor's zero-return operation is complete. The position curve is shown in the figure.
6. Conclusion
Practice has proven that the system operates reliably, provides accurate and easily analyzable data, exhibits good real-time performance with initial acceleration to reach the set target speed, and facilitates easy implementation of the protocol stack. This method can be extended to multi-motor control systems, and the CANopen communication protocol stack is applicable to all devices, making it widely used in engineering applications.