Create one function block, FB_VFD, whose inputs are the 16 STW1 bits, Set_RPM, SW_01 and SW_02, and whose outputs are CW_01, CW_02, the 16 ZSW1 bits and Act_RPM. Inside, 34 Ladder networks map the bits and scale the speed. Call it in OB1 with an instance DB per drive, then connect CW_01 → %QW256, CW_02 → %QW258, %IW256 → SW_01 and %IW258 → SW_02, using the addresses from the G120's Device overview.
- One FB, one instance DB per drive. A second drive needs a new call and new addresses — no new code.
- Give the "held at 1" bits a default of TRUE, so OB1 only wires what actually changes.
- Take the I and Q addresses from the Device overview of the G120, never from memory.
- Read "running" from
Oper_En(ZSW1 bit 2), never from theON_OFF1command.
Try it first: the Live PLC–VFD Simulator runs the same telegram this block writes, so you can see the control word before you build the FB.
Why One Standard FB for Every G120
A plant with ten G120 drives can have ten copies of the same bit mapping scattered through OB1 — or one tested function block called ten times. The second approach is what "standard FB" means: the drive logic is written and verified once, and each drive only differs in its instance DB and its I/Q addresses.
This guide builds that block for Standard Telegram 1 (PZD-2/2) on an S7-1200 or S7-1500, in four steps: create the interface, write the networks, call it in OB1, and map it to the telegram's I and Q addresses. The meaning of every individual bit is covered in SINAMICS G120 STW1 and ZSW1: Every Control and Status Bit; this page focuses on the block itself.
Block Diagram: OB1, FB, I/Q Addresses and Drive
Data passes through four stages. OB1 supplies machine tags to the FB; the FB packs them into words; the words sit in the PLC's process image at the telegram's addresses; and PROFINET carries them to and from the drive every cycle.
Step 1 — Create the FB Interface
In the project tree open Program blocks → Add new block, choose Function block, name it FB_VFD, set the language to LAD and click OK. Then fill in the block interface as below. The seven bits marked TRUE must be held at 1 for the drive to run, so they get TRUE as their default value — the OB1 call can then leave them unconnected.
| Section | Name | Data type | Default value | Comment |
|---|---|---|---|---|
| Input | ON_OFF1 | Bool | FALSE | STW1 bit 0 — ON / OFF1 |
| Input | OFF2 | Bool | TRUE | STW1 bit 1 — No coast stop |
| Input | OFF3 | Bool | TRUE | STW1 bit 2 — No quick stop |
| Input | En_Oper | Bool | TRUE | STW1 bit 3 — Enable operation |
| Input | En_RFG | Bool | TRUE | STW1 bit 4 — Enable ramp generator |
| Input | Cont_RFG | Bool | TRUE | STW1 bit 5 — Continue ramp generator |
| Input | En_SP | Bool | TRUE | STW1 bit 6 — Enable setpoint |
| Input | Ack_Flt | Bool | FALSE | STW1 bit 7 — Fault acknowledge - pulse only |
| Input | Res_08 | Bool | FALSE | STW1 bit 8 — Reserved |
| Input | Res_09 | Bool | FALSE | STW1 bit 9 — Reserved |
| Input | Ctrl_PLC | Bool | TRUE | STW1 bit 10 — Control by PLC |
| Input | Rev | Bool | FALSE | STW1 bit 11 — Reverse |
| Input | Res_12 | Bool | FALSE | STW1 bit 12 — Reserved |
| Input | MOP_Up | Bool | FALSE | STW1 bit 13 — MOP raise |
| Input | MOP_Dn | Bool | FALSE | STW1 bit 14 — MOP lower |
| Input | CDS | Bool | FALSE | STW1 bit 15 — CDS select |
| Input | Set_RPM | Real | 0.0 | Speed setpoint in rpm |
| Input | SW_01 | Word | 16#0 | ZSW1 status word from drive |
| Input | SW_02 | Word | 16#0 | NIST_A actual speed from drive |
| Output | CW_01 | Word | 16#0 | STW1 control word to drive |
| Output | CW_02 | Word | 16#0 | NSOLL_A speed setpoint to drive |
| Output | Rdy_SwOn | Bool | FALSE | ZSW1 bit 0 — Ready to switch on |
| Output | Rdy_Oper | Bool | FALSE | ZSW1 bit 1 — Ready to operate |
| Output | Oper_En | Bool | FALSE | ZSW1 bit 2 — Operation enabled - real running signal |
| Output | Fault | Bool | FALSE | ZSW1 bit 3 — Fault active |
| Output | No_OFF2 | Bool | FALSE | ZSW1 bit 4 — No coast stop active |
| Output | No_OFF3 | Bool | FALSE | ZSW1 bit 5 — No quick stop active |
| Output | SwOn_Inh | Bool | FALSE | ZSW1 bit 6 — Switching on inhibited |
| Output | Warning | Bool | FALSE | ZSW1 bit 7 — Warning active |
| Output | Spd_OK | Bool | FALSE | ZSW1 bit 8 — Speed within tolerance |
| Output | Ctrl_Req | Bool | FALSE | ZSW1 bit 9 — Control requested |
| Output | Spd_Cmp | Bool | FALSE | ZSW1 bit 10 — Comparison speed reached |
| Output | No_Limit | Bool | FALSE | ZSW1 bit 11 — Setpoint reached |
| Output | App_12 | Bool | FALSE | ZSW1 bit 12 — Application specific |
| Output | App_13 | Bool | FALSE | ZSW1 bit 13 — Application specific |
| Output | App_14 | Bool | FALSE | ZSW1 bit 14 — Application specific |
| Output | App_15 | Bool | FALSE | ZSW1 bit 15 — Application specific |
| Output | Act_RPM | Real | 0.0 | Actual speed in rpm |
| Temp | Norm_SP | Real | — | Normalised setpoint, network 33 |
| Temp | Norm_Act | Real | — | Normalised actual speed, network 34 |
With these defaults and ON_OFF1 at FALSE, the FB writes 16#047E to CW_01 from the first scan — the ready state. Setting ON_OFF1 changes it to 16#047F and the drive starts.
Step 2 — Write the FB Networks
The FB body is 34 Ladder networks: 16 for the control word, 16 for the status word and 2 for speed scaling. The operand names match the interface above.
Control word — Networks 1 to 16
Status word — Networks 17 to 32
Speed scaling — Networks 33 and 34
16#4000 (16384) equals 100 % of p2000. Replace 1500.0 with your drive's p2000 reference speed in rpm.
Build this block on real SINAMICS hardware
Create the FB, call it in OB1 and run a G120 over PROFINET in a guided session. Pune classroom or live online.
Step 3 — Call the FB in OB1
Open Main [OB1] and drag FB_VFD from the project tree into network 1. TIA Portal asks for an instance data block: name it DB_VFD_01 and click OK. Then connect the pins as shown. Pins showing ... are left unconnected and use their default value from the interface.
Motor1_Ack_Pulse must be a short pulse of around 200 ms — for example from a TP timer triggered by the reset button — never a held signal, because fault acknowledge works on the rising edge.
Step 4 — Map to I and Q Addresses
The addresses come from the hardware configuration, not from the program. In Devices & networks, double-click the G120, open the Device view and look at the Device overview table. The row Standard telegram 1, PZD-2/2 shows an I address range and a Q address range — for example 256…259 for both.
| FB pin | PLC tag | Address | Bytes | Drive word |
|---|---|---|---|---|
CW_01 | G120_1_CW_01 | %QW256 | %QB256 (bits 8–15), %QB257 (bits 0–7) | PZD1 out — STW1 |
CW_02 | G120_1_CW_02 | %QW258 | %QB258, %QB259 | PZD2 out — NSOLL_A |
SW_01 | G120_1_SW_01 | %IW256 | %IB256 (bits 8–15), %IB257 (bits 0–7) | PZD1 in — ZSW1 |
SW_02 | G120_1_SW_02 | %IW258 | %IB258, %IB259 | PZD2 in — NIST_A |
Create the tags in a PLC tag table with these names, types and addresses. The list below includes the machine tags used in the OB1 call.
// PLC tag table - drive 1 (addresses from the G120 Device overview)
G120_1_CW_01 Word %QW256 // PZD1 out - STW1 control word
G120_1_CW_02 Word %QW258 // PZD2 out - NSOLL_A speed setpoint
G120_1_SW_01 Word %IW256 // PZD1 in - ZSW1 status word
G120_1_SW_02 Word %IW258 // PZD2 in - NIST_A actual speed
// Machine tags used in the OB1 call
Motor1_Run Bool %M10.0 // Run command to ON_OFF1
Motor1_Ack_Pulse Bool %M10.1 // 200 ms reset pulse to Ack_Flt
Motor1_Running Bool %M10.2 // From Oper_En - HMI lamp and interlocks
Motor1_Fault Bool %M10.3 // From Fault
Motor1_Warning Bool %M10.4 // From Warning
HMI_Set_RPM Real %MD20 // Speed setpoint in rpm to Set_RPM
HMI_Act_RPM Real %MD24 // Actual speed in rpm from Act_RPM
If the hardware address ever changes, edit only the four G120_1_ tags. The FB and the OB1 call stay untouched.
Adding a Second Drive
Add a second network in OB1, drag in FB_VFD again and create a new instance DB, DB_VFD_02. Connect it to the second drive's telegram addresses and its own machine tags. The FB code is not copied or changed.
| Drive | Instance DB | CW_01 | CW_02 | SW_01 | SW_02 |
|---|---|---|---|---|---|
| Conveyor 1 | DB_VFD_01 | %QW256 | %QW258 | %IW256 | %IW258 |
| Conveyor 2 | DB_VFD_02 | %QW260 | %QW262 | %IW260 | %IW262 |
The second drive's addresses above are examples. TIA Portal assigns them when the drive is added, so always read them from that drive's own Device overview.
OFF2 or OFF3 gives an operational stop sent over the network. It is not a safety function. Emergency stop must be implemented through the drive's STO input or a safety-rated PLC and drive configuration, never through the control word alone.Step-by-Step Lab: Standard FB on Live Hardware
Hands-on- An S7-1200 or S7-1500 and a G120 with a PROFINET control unit, both in the same TIA Portal project, with Standard Telegram 1 selected and device names assigned.
- A motor on a test bench or uncoupled, and p2000 known (this lab assumes 1500 rpm).
- Estimated time: 60 minutes.
Read the telegram addresses
Open the G120 Device overview and note the I and Q address ranges of Standard telegram 1, PZD-2/2.
Create FB_VFD and its interface
Add a new LAD function block and enter the interface from Step 1, including the TRUE defaults.
Enter the 34 networks and compile
Build networks 1–34 and compile the block.
Call the FB in OB1 and create the tags
Drag FB_VFD into OB1, create DB_VFD_01, add the PLC tags and connect the pins.
Download and check the ready state
Download, go online and put G120_1_CW_01 and G120_1_SW_01 in a watch table in hexadecimal.
Run the motor
Set HMI_Set_RPM to 750.0, then set Motor1_Run to TRUE.
You have a working standard FB if the drive reaches 16#047E on its own after download, runs on one command bit, and reports its real speed in rpm. Adding a second drive should now take one new OB1 network, one instance DB and four tags.
This block is the PROFINET route. For the other options in Siemens PLC and VFD networking, including USS, Modbus and hardwired control, see the overview.
Frequently asked questions
What is a standard FB for a SINAMICS G120?
It is one function block that holds all the logic for a G120 on Standard Telegram 1: mapping the 16 control word bits into CW_01, splitting the 16 status word bits out of SW_01, and scaling the speed in CW_02 and SW_02. Every drive in the project uses the same FB with its own instance DB.
Why does every drive need its own instance DB?
The instance DB stores the FB's inputs, outputs and defaults for one drive. Calling FB_VFD twice with the same instance DB would make two drives share one set of data. Create DB_VFD_01 for drive 1, DB_VFD_02 for drive 2, and so on.
Where do I find the I and Q addresses of the G120 telegram?
Open the G120 in the Device view and look at the Device overview. The row for Standard telegram 1, PZD-2/2 shows the I address and Q address ranges, for example 256…259. The first word is STW1 or ZSW1, the second is the speed.
Why are OFF2, OFF3, En_Oper, En_RFG, Cont_RFG, En_SP and Ctrl_PLC defaulted to TRUE?
These bits must be held at 1 for the drive to run. With TRUE as the default value in the FB interface, the OB1 call can leave them unconnected and the control word still starts from 16#047E. Only ON_OFF1, Ack_Flt and the speed need wiring.
Can I wire %IW256 and %QW256 directly to the FB pins?
Yes, TIA Portal accepts absolute addresses on FB pins. Using named PLC tags such as G120_1_SW_01 on those addresses is better: the OB1 call reads clearly, and if the hardware address changes you edit only the tag table.
Why does Act_RPM show the wrong speed?
The value 1500.0 in networks 33 and 34 must equal the drive's reference speed p2000. If p2000 is 3000 rpm and the FB still uses 1500.0, both the setpoint and the actual speed are scaled by a factor of two.