Control Sinamics Drive with Codesys

sonle
Posts: 1
Joined: 22 Jan 2026, 03:27

Control Sinamics Drive with Codesys

Post by sonle »

Hi everyone,

Does anyone know how to control a Siemens SINAMICS D425 drive (via PROFIBUS) using a Revolution Pi Connect 5 programmed with CODESYS?
I am looking for any available documentation, configuration examples, or guidance on how to set up communication and control between these devices.
Any help or pointers to relevant resources would be greatly appreciated.

Thanks in advance!
User avatar
Amar
KUNBUS
Posts: 200
Joined: 15 Jul 2019, 10:58

Re: Control Sinamics Drive with Codesys

Post by Amar »

Yes, this is certainly possible! Since the RevPi Connect 5 doesn't have native PROFIBUS hardware, you'll need a PROFINET-to-PROFIBUS gateway. The PROFINET support in CODESYS is very good.

Solution Architecture

RevPi Connect 5 (CODESYS - PROFINET Controller)
↓ Ethernet/PROFINET
Gateway (PROFINET IO-Device / PROFIBUS DP Master)
↓ PROFIBUS DP
SINAMICS D425 (PROFIBUS Slave)

The gateway acts as a transparent bridge - CODESYS sees it as a standard PROFINET device, and the D425 sees standard PROFIBUS communication.

Recommended Gateway Options
Option 1: HMS Anybus AB7646 X-Gateway
Option 2: Hilscher NT 100-RE-DP (netTAP 100)


Project Structure
Device Tree:
├── CODESYS Control for Linux ARM64 SL
└── Ethernet (eth0)
└── PN_Controller (PROFINET IO-Controller)
└── Gateway_Device (AB7646 or NT100-RE-DP)
├── Output Module: 4 bytes (to D425)
└── Input Module: 4 bytes (from D425)

Resources:
Additional examples from CODESYS Store: https://store.codesys.com
Sample projects from CODESYS Forge: https://forge.codesys.com

Video Tutorials:
HMS Networks YouTube: https://www.youtube.com/user/HMSNetworks
CODESYS YouTube: https://www.youtube.com/user/CODESYSGmbH
Revolution Pi YouTube: https://www.youtube.com/c/RevolutionPi

Training:
PROFINET University: https://www.profibus.com/support/profinet-university/
CODESYS Training: https://www.codesys.com/training.html
HMS Academy: Check https://www.anybus.com for training webinars

Community Support:
PLCTalk Forum: https://www.plctalk.net
Reddit: r/PLC (https://www.reddit.com/r/PLC/) and r/automation (https://www.reddit.com/r/automation/)
Stack Exchange Electrical Engineering: https://electronics.stackexchange.com

Here is a sample I/O Mapping draft:

Code: Select all

PROGRAM DriveControl
VAR
    // Output to SINAMICS D425
    D425_ControlWord AT %QW0 : WORD;      // Control word (STW1)
    D425_SpeedSetpoint AT %QW2 : INT;      // Speed setpoint (NSOLL_A)
    
    // Input from SINAMICS D425
    D425_StatusWord AT %IW0 : WORD;        // Status word (ZSW1)
    D425_ActualSpeed AT %IW2 : INT;        // Actual speed value
    
    // User control
    bStartDrive : BOOL := FALSE;
    rSpeedPercent : REAL := 0.0;           // Speed 0-100%
    
    // Drive status
    bDriveReady : BOOL;
    bDriveRunning : BOOL;
    bDriveFault : BOOL;
END_VAR

// Extract status information
bDriveReady := D425_StatusWord.1;      // Bit 1: Ready
bDriveRunning := D425_StatusWord.2;    // Bit 2: Operation enabled
bDriveFault := D425_StatusWord.3;      // Bit 3: Fault present

// Simple control logic
IF bStartDrive AND bDriveReady AND NOT bDriveFault THEN
    // Enable drive operation
    // Bits: ON/OFF1, No coast stop, No quick stop, Enable operation,
    //       Ramp enable, Setpoint enable, Control by PLC
    D425_ControlWord := 16#047F;
    
    // Convert percentage to drive setpoint (100% = 16384 = 0x4000)
    D425_SpeedSetpoint := REAL_TO_INT(rSpeedPercent * 163.84);
ELSE
    // Stop drive (controlled ramp-down)
    D425_ControlWord := 16#047E;       // Disable operation bit
    D425_SpeedSetpoint := 0;
END_IF

// Fault acknowledgment
IF bDriveFault THEN
    D425_ControlWord.7 := TRUE;        // Set fault acknowledge bit
END_IF
```

**Reference for CODESYS Program Structure:**
- CODESYS programming examples: Available in IDE under **File → Open → Examples**
- Online help for I/O mapping: https://help.codesys.com/webapp/_cds_io_mapping
- Structured Text programming guide: https://help.codesys.com/webapp/_cds_struct_text

---

## SINAMICS D425 Parameter Configuration

You need to configure the drive to accept PROFIBUS control. Use the drive's keypad or SINAMICS STARTER software:

**Essential Parameters:**

| Parameter | Value | Description |
|-----------|-------|-------------|
| **P0918** | 2 (example) | PROFIBUS address - must match gateway config |
| **P0700** | 5 | Command source = PROFIBUS |
| **P1000** | 5 | Frequency setpoint source = PROFIBUS |
| **P2000** | 50 Hz (typical) | Reference frequency for scaling |
| **P1080** | 0 Hz | Minimum speed |
| **P1082** | 50 Hz | Maximum speed |

**Telegram Selection:**
- **Telegram 1** (Standard: PZD-2/2) - Most common for basic speed control
  - 2 words output: Control word + Speed setpoint
  - 2 words input: Status word + Actual value

**SIEMENS Documentation:**
- Industry Online Support: https://support.industry.siemens.com
- Search for: "SINAMICS D425 Operating Instructions"
- Search for: "SINAMICS D425 Parameter Manual"
- Search for: "SINAMICS PROFIBUS Communication Manual"
- Download SINAMICS STARTER: https://support.industry.siemens.com

---

## Control Word and Status Word Reference

### Control Word (STW1) - Main Bits
```
Bit 0:  ON/OFF1 (1 = ON)
Bit 1:  No coast stop / OFF2 (1 = no coast stop)
Bit 2:  No quick stop / OFF3 (1 = no quick stop)
Bit 3:  Enable operation (1 = enable)
Bit 4:  Ramp generator enable (1 = enable ramp)
Bit 6:  Setpoint enable (1 = enable setpoint)
Bit 7:  Fault acknowledge (0→1 transition)
Bit 10: Control by PLC (1 = PLC control)
```

**Common control word values:**
- `0x047F` (1151) = Full enable, all control bits active
- `0x047E` (1150) = Stop (disable operation bit)
- `0x0080` (128) = Fault acknowledge

### Status Word (ZSW1) - Main Bits
```
Bit 0:  Ready to switch on
Bit 1:  Ready to operate
Bit 2:  Operation enabled
Bit 3:  Fault present
Bit 7:  Warning present
Bit 10: Control requested (confirms PLC control)

Step-by-Step Setup Procedure
1. Gateway Configuration

Connect gateway to power and Ethernet
Access configuration interface (web or SYCON.net)
Set PROFINET parameters (device name, IP)
Configure PROFIBUS baud rate (match D425 setting)
Add SINAMICS D425 as slave with correct address
Select appropriate telegram type (Telegram 1 recommended)

2. Drive Configuration

Set PROFIBUS address on D425 (parameter P0918)
Configure command and setpoint sources (P0700, P1000)
Set speed limits and reference frequency
Verify drive is in PROFIBUS mode

3. CODESYS Project Setup

Install gateway GSDML file
Create PROFINET IO-Controller device
Add gateway as PROFINET device
Configure device name (must match gateway exactly)
Map I/O variables to process data

4. Testing

Download CODESYS program to RevPi Connect 5
Verify PROFINET communication (check device status)
Test drive enable sequence
Verify speed control and feedback

Regards,
Amar
KUNBUS