Configuring PLC and HMI Bend Angle Control on Hydraulic Tube Benders
Overview
Hydraulic rotary-draw tube benders require precise angular position control to produce repeatable bends in metal tubing, typically within ±1° to ±2° accuracy. This reference documents the complete architecture, hardware selection, PLC programming, HMI configuration, and tuning procedures required to implement closed-loop bend angle control using a rotary encoder, hydraulic directional or proportional control valves, a SIMATIC S7-1200 PLC, and a SIMATIC HMI panel. The dominant engineering problem in this application class is position overshoot caused by accumulated system delays between the PLC detecting the target position and the hydraulic actuator physically responding. This document describes both the entry-level on/off solenoid approach and the upgraded proportional-valve / motion-controller approach.
Mechanical and Hydraulic System Definition
The reference machine is a rotary-draw tube bender. The principal mechanical chain is:
- Bend head rotated by a hydraulic cylinder pulling on a triplex roller chain
- Chain connected via a sprocket keyed to the bend head shaft
- Tube clamped in the bend die, pressured against the wiper shoe, and wrapped around the bend die as the head rotates
Two solenoid-operated directional valves control the cylinder. One solenoid extends the cylinder (bend direction); the other retracts. Spring centering or a pilot-operated check holds the cylinder in position when both solenoids are de-energized. For ±1° to ±2° accuracy, on/off solenoid control is sufficient only if the cycle is slowed and the stopping position is anticipated. A proportional valve or a two-stage on/off arrangement (fast approach plus slow finish) is required for higher speed at the same accuracy.
System Delay Budget
The total latency from "PLC issues stop command" to "shaft stops rotating" determines the minimum controllable overshoot. The principal contributors are tabulated below.
| Delay Source | Typical Value | Notes |
|---|---|---|
| PLC scan time | 1–10 ms | S7-1200 typical scan 1–3 ms with simple logic |
| Digital output module update | 0.5–2 ms | SM 1223 DQ sourcing response |
| Relay coil pull-in / drop-out | 8–15 ms | Phoenix Contact PLC-RSC or equivalent |
| Solenoid valve shift | 15–40 ms | Direct-acting; pilot-operated 25–60 ms |
| Hydraulic spool deadband | Variable | ±2–5% of command |
| Cylinder compressibility | Material-dependent | Steel tube springback dominates |
| Encoder filter / HSC update | 1–4 ms | HSC input filter 0.6 µs to 20 ms selectable |
| Chain backlash | 0.5–3° | Compensated by software offset |
| Tube springback | 1–8° per bend | Function of material, radius, wall, mandrel |
At a 30°/s bend speed, a 100 ms total latency corresponds to 3° of overshoot at the hydraulic spool before springback correction. The control algorithm must command the stop well before the encoder reading reaches the target.
Rotary Encoder Selection
The encoder is the only position feedback in this system; its resolution and noise rejection set the absolute accuracy floor.
Encoder Type and Output
For a 0–180° bend range and ±1° target, an incremental encoder with 1024 pulses per revolution (PPR) provides 0.088° per pulse before quadrature, 0.044° per edge with x4 decoding. An encoder with HTL push-pull outputs (10–30 V) is recommended for industrial environments; TTL 5 V signals should be avoided beyond 5 m cable runs. A 360 PPR encoder yields 0.25° per edge in x4, marginal for ±1° work.
| Parameter | Minimum Recommended | Preferred |
|---|---|---|
| PPR | 1024 | 2500 or 5000 |
| Output | HTL push-pull | HTL push-pull, short-circuit protected |
| Supply | 10–30 VDC | 24 VDC ±10% |
| Max frequency | 50 kHz | 100 kHz |
| Shaft / hollow bore | Hollow bore with tether | Both acceptable |
| IP rating | IP65 | IP67 |
| Connector | M12 8-pin | M12 8-pin |
Encoder output A, /A, B, /B connects to the S7-1200 high-speed counter inputs. The Z (index) pulse is not required for this application but is recommended for home-position verification at power-up. Refer to the SIMATIC S7-1200 Programmable Controller System Manual for HSC wiring details.
HSC Configuration on S7-1200
The S7-1200 CPU provides up to 6 high-speed counters. The HSC supports two-phase quadrature counting (x1, x2, or x4), frequency measurement, and period measurement. For a bender, configure:
- Operating mode: Two phase (quadrature)
- Counting direction: User program (count up = positive bend direction)
- Initial count value: 0
- High / low limit: Defined by bend angle range and PPR
In TIA Portal, configure the HSC under CPU properties → High-speed counters (HSC). For an S7-1214C DC/DC/DC (6ES7214-1AG40-0XB0), the supported HSC inputs are I0.0–I0.5. The function block CTRL_HSC provides the user interface. See the S7-1200 Motion Control Function Overview for HSC function-block reference.
PLC Hardware Selection
For a bender with 2–4 solenoid outputs, 1–2 limit switch inputs, 1 encoder, and HMI, the minimum S7-1200 selection is listed below.
| Module | Catalog Number | Function |
|---|---|---|
| CPU 1214C DC/DC/DC | 6ES7214-1AG40-0XB0 | 14 DI / 10 DO / 2 AI onboard |
| SM 1223 DQ 8 x 24V | 6ES7223-1BH32-0XB0 | 8 DO if not on CPU |
| KTP700 Basic PN | 6AV2123-2GB03-0AX0 | 7" HMI for setpoint, actual, manual mode |
| PM 1207 | 6EP1332-1SH71 | 24 V / 2.5 A power supply |
| CSM 1277 | 6GK7277-1AA10-0AA0 | 4-port unmanaged switch |
If the application is upgraded to a proportional valve (4–20 mA or ±10 V), add an SM 1232 AQ 4 x 14-bit module (6ES7232-4HD32-0XB0). For higher performance, the S7-1500 platform (CPU 1511-1 PN, 6ES7511-1AK02-0AB0) with the TO_PositioningAxis technology object provides a direct path to 0.1° accuracy closed-loop control. Refer to the SIMATIC S7-1500 Motion Control Function Manual.
HMI Panel and Tag Configuration
A SIMATIC Basic HMI (KTP700 Basic PN, 6AV2123-2GB03-0AX0) is sufficient for the entry-level implementation. A Comfort Panel (TP700 Comfort) is recommended for diagnostics, trends, and recipe management. The HMI design guidance is in the WinCC Engineering Manual.
The minimum HMI tag list:
| Tag | PLC Address | Data Type | Function |
|---|---|---|---|
| hmi_SetAngleDeg | DB1.DBD0 | Real | Operator entry 0.0–180.0 |
| hmi_ActualAngleDeg | DB1.DBD4 | Real | Encoder-derived position |
| hmi_CommandStart | DB1.DBX8.0 | Bool | Bend cycle start |
| hmi_CommandReset | DB1.DBX8.1 | Bool | Fault reset |
| hmi_ManualMode | DB1.DBX8.2 | Bool | Manual jog enable |
| hmi_SpringbackOffset | DB1.DBD12 | Real | Per-recipe springback compensation |
| hmi_SlowZoneTrigger | DB1.DBD16 | Real | Angle at which bend slows down |
| hmi_StatusWord | DB1.DBW20 | Word | PLC status flags |
| hmi_FaultWord | DB1.DBW22 | Word | Active fault bits |
| hmi_RecipeNumber | DB1.DBW24 | Int | Recipe selection 0–15 |
HMI screen layout:
- Main screen: Numeric input for setpoint (0.0–180.0, 1 decimal), I/O field for actual position, two pushbuttons START and RESET, status bar showing Ready / Running / Complete / Fault, fault text list
- Calibration screen: Encoder home, zero offset, PPR multiplier
- Recipe screen: 16 recipes storing setpoint, springback, slow-down trigger angle, approach speed
- Diagnostics screen: Status word, fault word, HSC count, last cycle time, overshoot trend
Enable the HMI audit trail if the bent part must be traceable to a recipe. Use the HMI recipe view to write structured data from the panel to a recipe DB on the PLC.
PLC Program Structure
The PLC program is organized into the following organization blocks and function blocks:
- OB1 Main: Cyclic scan, calls FB_HmiControl, FB_BendSequence, FB_Encoder
- OB35 (or OB30–OB38 cyclic interrupt): Position loop execution at 10 ms, calls FB_PositionController
- OB82 / OB121: Fault and time-error handling
- FB_Encoder: HSC configuration and conversion of raw counts to degrees
- FB_PositionController: Closed-loop control with two-stage velocity profile
- FB_BendSequence: State machine driving outputs based on operator commands
- FB_HmiControl: HMI tag exchange and recipe handling
- DB_HMI: HMI interface tags
- DB_Recipes: 16-recipe array, each record 16 bytes
Encoder to Degrees Conversion
For a 1024 PPR encoder with x4 decoding mounted directly to the bend shaft:
Counts_per_degree = (1024 * 4) / 360 = 11.378 counts/°
Allow for sprocket ratio if the encoder is not on the bend shaft. A common configuration is a 2:1 reduction; the formula becomes:
Counts_per_degree = (PPR * 4 * GearRatio) / 360
The conversion in Structured Text:
IF b_EncoderValid THEN
i_EncoderCounts := HSC1_Count;
r_AngleDeg := INT_TO_REAL(i_EncoderCounts) / r_CountsPerDeg;
END_IF;
At every power-up, the program must force the home position. Because the bender has no absolute reference, the home procedure retracts the cylinder to a mechanical end-stop, then sets HSC1_Count := 0 after a debounce delay (typically 500 ms). Alternatively, an absolute single-turn encoder (SSI or CANopen) removes the home routine.
Two-Stage Velocity Profile and Stop Anticipation
The dominant technique for ±1° accuracy on a hydraulic system is a two-stage approach:
- Fast bend from 0° to (setpoint − 5°), full valve command, ~30°/s
- Slow approach from (setpoint − 5°) to (setpoint − springback), partial valve command or single-solenoid PWM, ~5°/s
- Coasting zone from (setpoint − springback) to setpoint, all valves de-energized, allow cylinder to coast and lock
The 5° slow-zone trigger is a tunable parameter in the recipe. The transition from fast to slow is triggered when the actual angle enters the slow-zone window. Springback compensation is material-specific: 304 stainless bends 2–4° back after load release; mild steel A513 typically 1–2°; aluminum 6061-T6 typically 1–3°.
The bend state machine implemented in OB35 (simplified SCL):
IF "DB_HMI".hmi_CommandStart AND NOT "DB_HMI".b_Running THEN
"DB_HMI".b_Running := TRUE;
"DB_HMI".r_TargetDeg := "DB_HMI".hmi_SetAngleDeg;
"DB_HMI".r_SlowZoneDeg := "DB_HMI".hmi_SetAngleDeg - "DB_HMI".hmi_SlowZoneTrigger;
"DB_HMI".r_FinalDeg := "DB_HMI".hmi_SetAngleDeg - "DB_HMI".hmi_SpringbackOffset;
END_IF;
IF "DB_HMI".b_Running THEN
IF "DB_HMI".r_AngleDeg < "DB_HMI".r_SlowZoneDeg THEN
"Q_BendForward" := TRUE; // fast extend
"Q_BendReverse" := FALSE;
ELSIF "DB_HMI".r_AngleDeg < "DB_HMI".r_FinalDeg THEN
"Q_BendForward" := TRUE; // slow extend via PWM
"Q_BendReverse" := FALSE;
ELSE
"Q_BendForward" := FALSE; // coast and stop
"Q_BendReverse" := FALSE;
"DB_HMI".b_Running := FALSE;
"DB_HMI".b_Complete := TRUE;
END_IF;
END_IF;
PWM on the S7-1200 is generated by the PTO/PWM generator of the onboard outputs Q0.0–Q0.3. PWM frequency 50–200 Hz, duty cycle set to 30% for slow approach. This is a coarse but effective speed control on a direct-acting solenoid valve. For higher precision, replace the on/off solenoid pair with a single proportional valve (4-way, 4–20 mA command) and use the PID_Compact block to control actual angle to setpoint with an aggressive derivative term to anticipate overshoot.
PID Position Controller (Proportional Valve Alternative)
If the system is upgraded with a proportional valve, use the technology object PID_Compact (firmware V4.0 and later on S7-1200) configured as position control:
- Input (process value): r_AngleDeg
- Setpoint: r_TargetDeg
- Output: 4–20 mA proportional valve command
- Sampling time: 100 ms (matches hydraulic response)
- Derivative action: enabled, smoothing time 1 s
- Proportional gain: tune manually with Ziegler-Nichols step test
- Output limits: 0%–100% of valve range
The PID_Compact self-tuning can be used at first commissioning; the resulting gain is conservative. Manually trim by increasing GainValue until the system shows a single overshoot of 0.5°–1°, then back off 20%. Refer to the PID Control with PID_Compact Function Manual.
Tuning Formula
The effective steady-state gain of a hydraulic position system can be estimated by:
K_plant = Δθ / (Q_valve × t)
Where Δθ is the angle change in degrees over time t at a constant valve command Q_valve (% of 4–20 mA span). For a representative bender: K_plant ≈ 0.6 °/s per % valve. The closed-loop bandwidth is:
ω_c ≈ Kp × K_plant
For 1 s response with no overshoot, ω_c ≈ 3 rad/s, giving Kp ≈ 5.0.
Wiring and Electrical Design
Encoder wiring must use twisted-pair shielded cable. Ground the shield at the panel end only; the encoder end is isolated by the bearing. Encoder 24 V supply must be sourced from the same 24 VDC bus as the PLC inputs to avoid ground-loop noise.
Solenoid outputs on the S7-1200 DC outputs are rated 0.5 A per channel. A typical hydraulic solenoid draws 1.0–1.5 A inrush, 0.3–0.5 A holding. Use an interposing relay (Phoenix PLC-RSC-24UC/21, 2966171) or a solid-state relay (Phoenix PLC-OSC-24DC/24DC/2, 2966634) sized to the inrush. If the solenoid is 110 VAC or 230 VAC, a 24 VDC coil relay is required; never switch AC directly from a transistor output.
Safety Considerations
A tube bender presents several hazards: high hydraulic pressure (typically 1500–3000 PSI), rotating mass, and pinch points at the bend die. Functional safety must be addressed even if the basic implementation does not use a safety PLC.
Mandatory safety functions:
- Emergency stop wired through a safety relay (Pilz PNOZ s4, 750104) or a fail-safe S7-1200F CPU (CPU 1214FC, 6ES7214-1AF40-0XB0)
- Two-hand control for cycle start, or light curtain on operator side
- Hydraulic pressure relief valve set 10% above operating pressure
- Mechanical crash stops in case of hydraulic runaway
- Light curtain or area scanner on operator side per ANSI B11.19 / ISO 13849 PL d
Wire the E-stop as a hardwired circuit, not a software flag. The PLC's safety input is supplemental. Refer to the SIMATIC Safety Integrated for S7-1200/1500 Manual for fail-safe wiring patterns.
Commissioning Procedure
- Verify wiring against schematic. Check 24 VDC polarity on every terminal. Megger insulation on the encoder cable if installed in a tray with VFD cables.
- Power up PLC. Connect TIA Portal. Download hardware configuration. Confirm no diagnostic LEDs on CPU or SM modules.
- Open the HSC configuration screen. Manually rotate the encoder. Confirm HSC1_Count increments in the correct direction. Reverse the A and B leads if direction is wrong.
- Wire the home limit switch. Force the cylinder to retract to the home stop. Verify HSC1_Count = 0 at home.
- Configure HMI tags. Set up the screens in WinCC within TIA Portal.
- Test outputs in manual mode from the HMI. Confirm extend/retract solenoid actuation.
- Run a 10° bend with springback compensation disabled. Record actual final angle. Compute springback as target minus actual.
- Enter springback into recipe. Run 30°, 60°, 90°, 120°, 150° at slow speed. Plot actual vs. target.
- Tune the slow-zone trigger angle and the slow approach speed to achieve target accuracy.
- Lock the cabinet. Perform the operator acceptance test with full production tubes.
Verification and Acceptance
Acceptance criteria for ±1° accuracy on production tubes, post springback correction:
- All bends within ±1.0° of programmed setpoint, verified with a digital protractor
- 95% of bends within ±0.5° after recipe tuning
- Cycle time not more than 110% of pre-PLC retrofit cycle
- No nuisance faults over 1000 cycles
Troubleshooting Matrix
| Symptom | Likely Cause | Verification | Action |
|---|---|---|---|
| Position reading jumps at high speed | Encoder frequency exceeds HSC input | Check HSC count stability at full speed; set HSC input filter to 0.6 µs | Reduce bend speed; replace encoder with higher PPR |
| Reading is correct direction reversed | A and B swapped | Jog bend and observe count sign | Swap A and B at the terminal block |
| Overshoot of 3°–10° | Springback not compensated; slow zone too late | Record actual vs. setpoint curve | Increase springback offset, reduce slow zone trigger angle |
| Cycle stops short of setpoint | Slow zone trigger angle too aggressive; encoder lost counts | Compare HSC count to expected | Recalibrate encoder; widen slow zone |
| E-stop does not stop motion | E-stop wired to standard DI not F-DI | Inspect wiring | Re-wire to safety input or safety relay |
| Hydraulic chatters in slow zone | PWM frequency too high for valve; valve hysteresis | Listen for chatter; reduce PWM freq | Lower PWM to 30–50 Hz; use proportional valve |
| HMI shows "Encoder Fault" | Wire break or short; HSC diagnostic | Check SF LED on CPU; HSC input status | Inspect cable; replace encoder |
| Position drift after power cycle | No absolute reference; home procedure skipped | Verify home routine execution | Add home routine on every power-up |
| Reading noisy in noisy plant | Encoder cable routed with VFD cable; ground loop | Inspect cable routing; measure noise with scope | Reroute cable; ground shield at panel only |
Advanced Motion Control
If ±1° is not achievable at the required cycle time with a hydraulic on/off valve, upgrade the control loop:
- Use a SIMOTION D425-2 (6AU1425-2AD00-0AA0) or a SIMATIC S7-1500T (CPU 1511T-1 PN, 6ES7511-1TK02-0AB0) motion controller
- Use a servo-driven rotary actuator (Siemens 1FK7 with HIPERFACE DSL) or a closed-loop hydraulic servo valve
- Use the TO_PositioningAxis technology object
- Position loop update 1 ms
- Override the on/off valve with a closed-loop proportional or servo valve
A Siemens SINAMICS V90 servo drive (6SL3210-5FB10-1UF0) with a 1FK7 motor replacing the hydraulic cylinder delivers ±0.1° accuracy, eliminates springback as a control variable, and removes the hydraulic power pack. The trade-off is reduced peak torque compared to a 2000 PSI hydraulic cylinder. See the SIMATIC S7-1500T Motion Controller Manual for commissioning details.
FAQ
What is the minimum PLC configuration to control a hydraulic bender with ±1° accuracy?
A SIMATIC S7-1200 CPU 1214C DC/DC/DC with a single SM 1223 digital output module and a KTP700 Basic PN panel. The HSC inputs on the CPU handle the encoder directly. The on/off solenoid valves require interposing relays. This is the entry-level configuration; higher accuracy requires a proportional valve and PID_Compact or a motion controller.
How do I eliminate position overshoot from hydraulic system delays?
Use a two-stage velocity profile. Bend at full speed to a trigger angle 5° before the setpoint, then switch to a slow approach using PWM on the solenoid or a proportional valve. Add a recipe-stored springback offset equal to the measured overshoot at release. Tune the trigger angle and the slow approach speed empirically.
Can the bender be controlled with an absolute encoder and skip the home routine?
Yes. A single-turn absolute encoder with SSI or CANopen output reports the shaft angle directly, eliminating the need for a home procedure at power-up. The S7-1200 supports SSI absolute encoders via the SSC configuration on a free high-speed input, or CANopen via a CM CANopen module.
What is the best approach to achieve ±0.5° accuracy on stainless steel tube?
Stainless has higher springback (3–5° for thin-wall). Replace the on/off solenoid with a proportional valve, add PID_Compact in TIA Portal, and store a springback table indexed by tube diameter and wall thickness. The PID loop must be tuned with the actual material in place. Expect 4–8 hours of tuning per material per diameter.
How is the encoder connected to the S7-1200 HSC?
Wire encoder 24 V supply, GND, A, /A, B, /B to the CPU terminals. For a CPU 1214C DC/DC/DC, HSC1 uses I0.0 (A), I0.1 (B), I0.2 (Z). Configure the HSC as Two phase in TIA Portal, enable quadrature x4. The HSC count is accessed by the CTRL_HSC function block or directly from the HSC_Count system tag.
Why does the HMI show position drift between bends?
Two common causes: (1) the encoder is slipping on the shaft — check the coupling, key, or tether arm; (2) backlash in the triplex chain allows the sprocket to rock under load. The chain should be pre-tensioned per the manufacturer specification. Software compensation for backlash is possible but adds complexity.
Can the S7-1200 directly drive a proportional valve?
Yes, with an SM 1232 AQ 4 x 14-bit analog output module. The proportional valve accepts ±10 V or 4–20 mA. The PID_Compact block computes the output from the position error. Do not drive a 24 V proportional valve coil directly from a digital output; the valve will not respond proportionally.
What firmware version of the S7-1200 CPU is required for PID_Compact?
PID_Compact is available in S7-1200 firmware V4.0 and later. The current firmware at the time of this writing is V4.6. Update the CPU firmware in TIA Portal under Online → Accessible Devices. The Technology Objects for motion control require the same firmware level.