CANopen serves as a “common language” among industrial devices, enabling seamless “communication” between devices from different manufacturers. The S7-200 SMART, equipped with a CANopen module, acts like a proficient “translator” of this language, effortlessly commanding and coordinating various intelligent devices. This technology simplifies complex automation systems, allowing what once required intricate wiring to be connected through a single thin bus cable, akin to replacing tangled telephone wires with a modern “Industrial Internet”.
Basic Knowledge of CANopen
CANopen is a high-level communication protocol based on the CAN bus. Compared to the original CAN bus, it is like upgrading from “Morse code” to a “mail system”; it not only transmits signals but also comes with its own formats and rules. Its core concepts include:
- Node ID: The unique “identity number” for each device (1-127)
- Object Dictionary: The “attribute list” of the device, containing various parameters and functions
- PDO (Process Data Object): The “parcel” for real-time data transmission
- SDO (Service Data Object): The “registered letter” for parameter configuration
- NMT: Network Management Protocol, akin to the “traffic police” on the bus
To use CANopen with the S7-200 SMART, the CP243-1 CAN Communication Module must be installed, which acts like a “language extension pack” for the PLC, enabling it to “speak CANopen”.
Hardware Connection and Networking
A typical CANopen network connection is as follows:
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
S7-200 SMART PLC + CP243-1 CAN Module --| |Absolute Encoder (Node ID: 5) -------------| |--- 120Ω Termination Resistor Servo Drive (Node ID: 10) --------------| |Temperature Sensor Network (Node ID: 15) ----------|
On the physical layer, shielded twisted pair cables are used, typically with a 9-pin D-SUB interface:
- Pin 2: CAN_L
- Pin 7: CAN_H
- Pin 3 and 6: CAN_GND
Note: A 120-ohm termination resistor must be connected at both ends of the bus, which acts like a reflective surface for the “sound”, ensuring signal quality. I once encountered intermittent communication in a project because I forgot to install the termination resistor, and it took me a long time to identify this basic error.
Example of CANopen Communication Program
The following is an example program for the S7-200 SMART to read a CANopen absolute encoder:
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
- ounter(line
// Network 1: Initialize CANopen Module
LD SM0.1 // First scan
CALL "CAN_INIT" // Call CANopen initialization subroutine
ModuleAddr := W#16#0 // Module installed at position 0
Baudrate := 3 // Baud rate (3=250kbps)
NodeID := B#16#1 // Local node ID is 1
InitOK => M0.0 // Initialization success flag
// Network 2: Configure TPDO mapping for receiving encoder position value
LD M0.0 // After initialization success
CALL "SDO_WRITE" NodeID := B#16#5 // Encoder node ID
Index := W#16#1A00 // TPDO mapping index
Subindex := B#16#1 // Subindex
Length := B#16#4 // Data length (4 bytes)
Data := DW#16#60040020 // Mapping position value object (6004h)
Done => M1.0 // Operation completion flag
// Network 3: Start CANopen network
LD M1.0
CALL "NMT_CONTROL" Command := B#16#1 // Start command
NodeID := B#16#0 // 0 indicates all nodes
Done => M2.0 // Operation completion flag
// Network 4: Periodically read encoder position
LD SM0.0 // Main scan cycle
CALL "PDO_RECEIVE" NodeID := B#16#5 // Encoder node ID
PDO_Num := B#16#1 // PDO number (TPDO1)
Data => MD10 // Store received data
New_Data => M3.0 // New data flag
This program implements the functions of CANopen network initialization, encoder configuration, and position value reading. The execution sequence is to initialize the module → configure device parameters → start the network → cyclically read data.
Practical Application Case
In a small assembly line, I used the S7-200 SMART to control four servo motors and multiple sensors via CANopen. Compared to traditional point-to-point connections, the wiring was reduced by 70%, and debugging became simpler.
The greatest advantage is the diagnostic function; when a sensor experiences a disconnection, the system can immediately pinpoint the specific node. Once, during production, the system suddenly stopped, and through the CANopen diagnostic function, I located the loose encoder connector caused by vibration within three minutes, quickly resuming production.
Common Issues and Solutions
-
Bus Communication Interruption
- Possible Causes: Missing termination resistors, loose connections, excessive interference
- Solutions: Check the termination resistors at both ends of the bus, ensure the shielding layer is properly grounded, and keep away from interference sources like frequency converters
-
Node Not Recognized
- Possible Causes: Duplicate node IDs, mismatched baud rates, incompatible device models
- Solutions: Check the ID settings for each node, ensure all devices have the same baud rate, and consult the device EDS files for compatibility
-
Data Instability or Loss
- Possible Causes: Excessive bus load, poor cable quality, unreasonable network topology
- Solutions: Reduce high-frequency PDO communication, use high-quality shielded twisted pair cables, and ensure the network structure is linear rather than star-shaped
Configuration and Debugging Tips
In a CANopen system, the EDS file (Electronic Data Sheet) is crucial; it serves as the “user manual” for the device, containing all parameter information. Always obtain the latest EDS file from the manufacturer before configuration.
Debugging Recommendations:
- First, build the minimum system (only PLC and one node), confirm normal communication, and then add nodes one by one
- Purchase a dedicated CANopen analyzer, which can monitor all communications on the bus and quickly locate issues
- When starting the system for the first time, set a lower communication rate (e.g., 125kbps), and once stable, increase it to 250kbps or 500kbps
Try connecting a CANopen-compatible servo drive to the S7-200 SMART, configure basic control functions (such as jog, positioning, etc.), and observe the data transmission situation. By modifying the PDO communication cycle, experience how different configurations affect system responsiveness. Such hands-on practice can help master the basic skills of CANopen configuration and communication, laying the foundation for building more complex fieldbus systems.