IMDHMIControls LibraryShop main store

Explainer

Where the PID belongs in S7-1200 speed control of a G120

Drives and motion Published 8 min read By IMDHMI controls team

Short answer

Put the PID in the S7-1200. The only true measured feedback is the photocell feeding the PLC high-speed counter; the G120's speed without a motor encoder is an estimate from its motor model, so run the drive over PROFINET standard telegram 1 with the SINA_SPEED block for enable and setpoint, and close the loop in the PLC.

On this page
  1. Is my drive a G120C or a modular G120?
  2. Can the G120 know shaft RPM during braking without an encoder?
  3. Where should the PID run, in the drive or in the S7-1200?
  4. How do I turn photocell pulses into RPM on the high-speed counter?
  5. How does the S7-1200 command the G120 over PROFINET?
  6. Which PID block do I use and how do I tune it?
  7. How do I prove the loop holds speed under braking?
  8. Questions asked

Put the PID in the S7-1200. The only speed measurement in this rig is the photocell counting holes on the shaft disc, and that pulse train lands in the PLC's high-speed counter, so the controller belongs beside its measured value. The G120's own speed figure without a motor encoder is an estimate from its motor model, good enough to run the motor but not the proof a braked-shaft test needs. Command the drive over PROFINET with standard telegram 1 and the DriveLib SINA_SPEED block: the PLC sends enable and speed setpoint, and the PID_Compact technology object closes the loop on the counted RPM.

Is my drive a G120C or a modular G120? #

A combined control-and-power unit marked G120C cannot host a CU250S-2 control unit; a PM240-2 power module bolted to a CU250S-2 PN is the modular SINAMICS G120, so identify the hardware from the ordering numbers on the rating plates before you open any drive documentation.

A G120C is one cast housing: control unit and power module share it, and nothing bolts on. The modular G120 is a family of separate parts, and a power module plus a CU250S-2 PN is a valid pairing inside that family — a training rig built from those two parts is a modular G120 no matter what the course materials call it. Read the ordering numbers on the rating plates and name the machine accordingly. The distinction decides which operating instructions, which Startdrive device configuration and which parameter set apply, and a G120C manual answers questions this hardware cannot, beginning with whether a motor encoder can be attached at all.

Can the G120 know shaft RPM during braking without an encoder? #

No — without a motor encoder the drive reports an estimated speed from its internal motor model, so a commanded 1300 RPM does not prove the braked shaft holds 1300 RPM; the photocell is the only device in this rig that measures the shaft.

Sensorless vector control derives shaft speed from measured currents and the motor model, and in steady state the estimate tracks closely, which is why the motor runs well on it. A brake load is the worst case for that estimate: the model sees a torque disturbance it did not command, and its slip estimate carries the error until the currents settle. The estimate is a calculated value with no connection to the shaft. You can read it into the PLC — that direction is covered in reading motor actual speed from a SINAMICS drive into an S7-1200 — but reading a calculated value over the bus does not turn it into a measurement. The photocell sees the shaft itself. Decision: treat the drive's speed figure as a diagnostic, never as the controlled variable of this test.

Where should the PID run, in the drive or in the S7-1200? #

Run the PID in the S7-1200, because the controller belongs where the measured value already is; the photocell pulses are counted by the PLC's high-speed counter, so putting the loop in the drive would add a PROFINET round trip inside every correction.

Dead time is what limits how much gain a loop tolerates, and the path is already long: photocell pulse, counter gate, PID call, telegram update, drive ramp, motor, disc, back to the photocell. A drive-side loop would haul every process value and every correction across PROFINET twice; a drive-internal loop is the right answer only when the feedback lives in the drive, which is the encoder case this rig does not have. The working architecture stays short: the high-speed counter feeds the process value, PID_Compact computes the correction, its output becomes the speed setpoint that SINA_SPEED sends, and the drive stays in sensorless vector mode so it produces torque correctly at whatever trimmed setpoint it receives. Decision: PID in the PLC, drive executes the setpoint.

How do I turn photocell pulses into RPM on the high-speed counter? #

Divide the counted pulse frequency into revolutions with RPM = f × 60 / n, where f is the pulse frequency in hertz and n is the number of holes per revolution; with an example disc of 12 holes, 260 Hz on the counter equals 1300 RPM.

Configure the high-speed counter on the digital input the photocell feeds, and gate it: count pulses over a fixed window, then divide. Sampled between window comparison events the counter reading jumps at every boundary crossing, the effect described in why a high-speed counter position jumps between PLC window comparisons, so a fixed gate is the honest way to read a rate.

The worked example, with the arithmetic shown: at 260 Hz, a 0.1 s gate collects 26 counts, and 26 × 60 / (12 × 0.1 s) = 1560 / 1.2 = 1300 RPM. Every count in that window is worth 60 / (12 × 0.1) = 50 RPM, so the process value moves in 50 RPM steps; a 0.5 s gate drops the step to 10 RPM and a 1.0 s gate to 5 RPM. The example uses 12 holes because it makes the arithmetic clean — count the holes on your disc and substitute the real number.

Start the gate at 0.1 s. It updates the loop fast enough to catch a brake dip, and the 50 RPM quantization makes it obvious when the gate needs lengthening; lengthen it only when the required holding tolerance is tighter than the per-count step. The pulse rate stays at a few hundred hertz, far below any S7-1200 high-speed counter input limit, so the counter is never the bottleneck in this rig.

How does the S7-1200 command the G120 over PROFINET? #

Use standard telegram 1 over PROFINET and the SINA_SPEED block from the DriveLib library: one block input enables the drive, another carries the speed setpoint, and the block maps both into the telegram's control word and setpoint word for you.

Telegram 1 is the smallest speed telegram — a control word, one speed setpoint word, a status word and one actual speed word — which is exactly the payload a single speed loop needs. DriveLib installs with the Startdrive package; where the engineering station lacks it, the library downloads from the Siemens support portal. Configure the drive in Startdrive for telegram 1, give it a device name and address on the PLC's PROFINET subnet, and load the configuration to the drive.

Then call SINA_SPEED in a cyclic OB with the drive's hardware identifier: its enable input builds the control word, and its speed input takes the setpoint as a real engineering value while the block handles the telegram's integer encoding. Scale the PID output linearly onto the drive's speed range and clamp it at the drive's permitted maximum before it reaches that input. No drive digital inputs are needed in this scheme — the enable rides in the control word. When the exchange misbehaves, you are debugging ordinary cyclic data, the same exchange described in control a PROFINET servo drive with cyclic telegram data.

Which PID block do I use and how do I tune it? #

Use the PID_Compact technology object, called from a fixed-rate cyclic interrupt OB, and let its commissioning tuning produce the first set of P, I and D values; treat that set as a starting point for this motor and brake only.

PID_Compact is a continuous PID controller with integrated tuning for exactly this kind of proportional actuator; its V2 version covers the S7-1200, the S7-1500 and the S7-1200 G2. Feed it the gated RPM as process value and the HMI setpoint as setpoint, call it in the same cyclic interrupt OB every scan, and run its tuning once at a speed the rig tolerates. The cycle time is part of the tune: the tuner measures it and the gains assume it, so moving the call to a different OB or changing its period invalidates the gains — the same reason ControlLogix programs run Logix 5000 PID loops in a periodic task.

Gains are machine-specific: a set tuned on one brake rig does not transfer to the next, which is the machine dependence behind why the KV factor varies with axis loop tuning. Decision: PID_Compact in a fixed cyclic OB, tuned once, retuned after any hardware change.

How do I prove the loop holds speed under braking? #

Brake from the setpoint speed with the loop closed and log three signals together — measured RPM, PID output and the drive's reported speed — and accept the loop only when the measured RPM returns to setpoint within the tolerance your assignment defines.

Run the sequence in automatic: reach the setpoint, apply the brake in small steps, and watch the traces separate. The drive's reported speed stays near its command while the counted RPM dips, then the PID output climbs until the counted RPM returns — that separation is the argument of the whole project, captured as a plot. Release the brake and check the loop settles without overshoot beyond the tolerance. Pull the three signals from the PLC as a trace or an HMI trend so the plot, not a memory of the screen, supports the result. Guard the rotating disc before the first brake test: a brake grabbing at speed turns drive torque into heat and debris at a small disc, so apply it gradually behind a guard.

The decision, case by case: the machine is a modular G120, not a G120C; the drive's speed is an estimate and the photocell is the measurement; the PID runs in the S7-1200 on the counted RPM; enable and setpoint cross PROFINET on telegram 1 through SINA_SPEED; and the loop is accepted when measured RPM holds under brake, not when the drive says so.

Questions asked

Which documentation should I open first?

Three documents cover the whole loop: the Siemens support example that drives a G120 from an S7-1200 with the SINA_SPEED block over telegram 1, the CU250S-2 PN operating instructions for the sensorless vector configuration, and the PID_Compact pages in the TIA Portal information system. Read the SINA_SPEED example first; it wires enable, setpoint and telegram selection together in one project.

What changes if a motor encoder is added later?

A motor encoder gives the drive a true measured speed, so its internal speed controller can close a real loop and the PLC PID becomes a supervisory trim or can be retired. Telegram 1 and SINA_SPEED stay unchanged; the improvement happens inside the drive, not in the PLC program.

How do I show RPM, setpoint and the gain values on the HMI?

Read them from the PLC, not from the drive: expose the gated RPM tag, the active setpoint tag and the gain values as HMI tags on the network the HMI already uses. PID_Compact keeps its P, I and D gains in its instance data block, so one trend of measured and commanded speed plus three numeric fields covers the display requirement.

When is telegram 1 no longer enough?

Telegram 1 carries one setpoint and one actual value, which is exactly one speed loop. It stops being enough when the task adds torque control, further setpoints or cyclic diagnostics; those need a larger telegram selected in the drive configuration and a matching way to write the extra words. For enable plus speed setpoint, telegram 1 is the right size.

Keep reading

  • Troubleshooting

    Troubleshooting S7-1200 PROFINET servo motion control issues

    Fix an S7-1200 PROFINET servo project in order: compile the motion calls in FB1 first, set drive and TIA Portal to the same telegram — Telegram 3 on this pairing — then prove one axis holds enable and velocity through repeated scans. A first-generation CPU 1214C executes independent single-axis motion only; the flying shear's deterministic master-slave cut belongs in the drives or in a motion-class controller, and no telegram adds it.

    Drives and motion

  • Explainer

    Why Telegram 750 torque control on an S7-1200 G2 needs its own example

    Yes: an S7-1200 G2 runs torque control over Telegram 750 to a SINAMICS S200 PN drive, but from the dedicated G2 application example, not from default integration. The note restricts what the engineering environment ships, not what the controller and drive can exchange. A clean compile of TorqueFB_TEL750 proves program structure only; the G2 package supplies the hardware configuration and cyclic process-data mapping to verify against.

    Drives and motion

  • Explainer

    Reading motor actual speed from a SINAMICS drive into an S7-1200

    The rpm entry field is a setpoint, so the actual-speed display must read the drive's speed actual value — the second word of PROFIdrive telegram 1 — scaled once in the PLC and shown as its own tag. The 'error in subordinate component' behind the red LED is a separate diagnostic: the diagnostic buffer names the faulty device, and the motor turning proves nothing about it.

    Drives and motion