SM 1232 Sinusoidal Output: Maximum Frequency on S7-1200 PLCs
The Siemens SM 1232 analog output signal board/module is widely deployed in S7-1200 systems for proportional valve control, variable-speed drive reference signals, chart recorder emulation, and laboratory-style excitation. When the application demands a continuous sinusoidal waveform (for example, driving a pneumatic proportional valve with a 1 Hz to 50 Hz dither signal), engineers routinely ask: what is the highest frequency a SM 1232 can reproduce? The answer is bounded by three independent limits: the analog output stage's settling time, the CPU's OB3x cyclic interrupt granularity, and the resulting deterministic jitter in the time domain. This reference walks through each constraint with the formulas, parameter tables, structured-text code, and verification checks required for a production-grade implementation.
1. SM 1232 Analog Output Hardware Overview
The SM 1232 is the analog output companion to the digital SM 1223 modules. Two form factors exist:
| Variant | Order Number (MLFB) | Channels | Range | Resolution |
|---|---|---|---|---|
| SM 1232 AQ 2 x 14 bit | 6ES7232-4HB32-0XB0 | 2 | ±10 V / 0-20 mA / 4-20 mA | 14 bit (V), 13 bit (I) |
| SM 1232 AQ 4 x 14 bit | 6ES7232-4HD32-0XB0 | 4 | ±10 V / 0-20 mA / 4-20 mA | 14 bit (V), 13 bit (I) |
| SB 1232 AQ 1 x 12 bit | 6ES7232-4HA30-0XB0 | 1 | ±10 V / 0-20 mA | 12 bit |
| SB 1232 AQ 1 x 12 bit (high-speed) | 6ES7232-4HA30-0XB0 | 1 | ±10 V / 0-20 mA | 12 bit |
For sinusoidal generation, the dominant hardware constraint is the output settling time — the time required for the DAC output to reach 95 % of the programmed value after a step change. This single parameter defines the maximum useful step rate of the analog channel and therefore the upper bound on sinusoidal frequency.
2. Analog Output Settling Time Specifications
Per the S7-1200 System Manual (06/2015), the SM 1232 output stage settling time depends on the output type and the connected load:
| Output Type | Load | Settling Time (95 %) | Conversion Type |
|---|---|---|---|
| Voltage | Resistive (R) | 300 µs | DAC, 14-bit |
| Voltage | Capacitive (1 µF) | 750 µs | DAC, 14-bit |
| Current | Inductive (1 mH) | 600 µs | DAC, 13-bit |
| Current | Inductive (10 mH) | 2.0 ms | DAC, 13-bit |
From these values, derive the maximum step rate. For a 0-to-10 V output driving a resistive or lightly capacitive load (typical valve command or drive reference), each analog update must be at least:
t_step ≥ 750 µs (worst-case voltage)
t_step ≥ 2 ms (worst-case current)
Reciprocally, the maximum step frequency f_step_max equals:
f_step_max = 1 / t_step
For a voltage-output SM 1232 with a 1 µF load:
f_step_max = 1 / 750 µs = 1 333 steps/s
For a current-output SM 1232 with a 10 mH load (worst case):
f_step_max = 1 / 2 ms = 500 steps/s
3. Sine Sampling Theory and the Nyquist Limit
A continuous sinusoid is fully described by its amplitude, frequency, and phase. To reconstruct it from a staircase waveform, the staircase must contain enough samples per period so the reconstruction error is bounded. Per the Nyquist–Shannon sampling theorem:
f_s ≥ 2 · f_signal
Two samples per period only preserve the sinusoid's identity; they cannot reproduce its shape faithfully. In practice, a sinusoidal reconstruction requires 10 to 32 samples per period for < 1 % THD (total harmonic distortion) at the analog output. The number of samples per period is:
N = f_s / f_signal
Combined with the settling-time ceiling, the highest sine frequency the SM 1232 can output at N samples per period is:
f_signal_max = f_step_max / N
| Load Condition | f_step_max | N = 10 (good fidelity) | N = 20 (high fidelity) | N = 32 (instrument-grade) |
|---|---|---|---|---|
| Voltage, R load | 3 333 Hz | 333 Hz | 167 Hz | 104 Hz |
| Voltage, 1 µF load | 1 333 Hz | 133 Hz | 66 Hz | 41 Hz |
| Current, 1 mH load | 1 666 Hz | 166 Hz | 83 Hz | 52 Hz |
| Current, 10 mH load | 500 Hz | 50 Hz | 25 Hz | 15 Hz |
The practical envelope for a real-world proportional-valve or drive-reference use case (voltage output, capacitive load < 1 µF, N = 20) is roughly 50-66 Hz maximum sine frequency. Beyond that, THD rises rapidly because each staircase step exceeds the amplifier's settling-time envelope.
4. PLC Scan Cycle: Buffered I/O vs Direct (:P) Access
The S7-1200 maintains a process image of inputs (%I) and outputs (%Q). During OB1, the program reads input values from the input process image (PII) captured at the start of the cycle and writes to the output process image (PIQ) which is flushed to the physical outputs at the end of the cycle. This buffering is fundamental to deterministic ladder logic execution but introduces a one-cycle latency on every analog update.
For high-rate analog output, S7-1200 supports direct (immediate) access via the :P suffix:
-
%QW0:P— writes directly to the physical output register, bypassing the PIQ. -
%IW0:P— reads the current physical input register, bypassing the PII.
The :P qualifier forces the I/O update at the instant the instruction executes, eliminating the end-of-cycle PIQ flush delay. For sinusoidal generation, this is critical: without :P, every analog step is delayed by one full OB1 scan, smearing the waveform in time.
:P) breaks the determinism of the process image and is invisible to the S7-1200 web server's I/O view. Use :P only inside a time-triggered OB (OB3x) where the cyclic-interrupt tick provides its own determinism.5. OB3x Cyclic Interrupt Configuration
S7-1200 CPUs (firmware V4.0 and later) support eight cyclic interrupt OBs: OB30 through OB38. Each can be assigned an independent scan period (1 ms to 60 000 ms) and a phase offset. The recommended pattern for sinusoidal generation:
- Set the OB3x cycle time
T_OBequal to the desired sample interval1 / f_s. - Place the DAC-write logic inside the OB.
- Use
:Pdirect writes for the analog output to skip the PIQ. - Maintain a phase index (angle accumulator) in a static tag of an instance DB.
| Target Sine Frequency | Samples / Period (N) | Sample Interval (T_OB) | Recommended OB |
|---|---|---|---|
| 1 Hz | 100 | 10 ms | OB30 |
| 5 Hz | 100 | 2 ms | OB30 |
| 10 Hz | 50 | 2 ms | OB30 |
| 50 Hz | 20 | 1 ms | OB30 |
| 60 Hz | 16 | 1 ms | OB30 (CPU 1215C or higher) |
| 100 Hz | 10 | 1 ms | OB30 (CPU 1217C recommended) |
The 1 ms floor is dictated by the S7-1200 cyclic-interrupt granularity. CPUs in the 1211C / 1212C range may not sustain a 1 ms OB30 while servicing PROFINET, web server, and HMI polling; the 1215C and 1217C have headroom.
6. Determinism and Jitter Analysis
A PLC is not a DSP. The cyclic interrupt will be preempted by higher-priority OBs (OB82 diagnostic, OB121 programming error, OB80 timeout, OB91 startup) and delayed by:
- PROFINET / PROFIBUS I/O update (typically 0.5-2 ms).
- HMI / OPC UA polling on the PN interface.
- Web server GET requests.
- Open User Communication (TSEND/TRCV) handshakes.
The resulting jitter appears as phase noise on the sinusoid. To measure jitter in OB3x:
- Read the system clock
RD_SYS_Tat the top of the OB. - Subtract the previous sample's timestamp.
- Compare to
T_OB; deviations > 50 µs accumulate as visible jitter on the analog output.
If jitter exceeds 1 % of the period, two compensation strategies are available:
- Phase compensation: Use the measured elapsed time to advance the angle accumulator proportionally to the actual interval rather than the nominal interval.
- Phase-locked loop (PLL): Lock the OB3x phase to a hardware timer or external interrupt.
7. Structured Text Implementation (SCL)
The following SCL block generates a sinusoid on channel 0 of an SM 1232, assuming the SM is at logical slot 0 (output address %QW96 typically, depending on configuration). Place this inside OB30 with a 2 ms cycle for a 50 Hz / 100-sample signal.
FUNCTION_BLOCK FB_SineGen
VAR
Angle : REAL; // 0..2*PI accumulator
Step : REAL; // 2*PI * f_signal * T_OB
Amplitude : REAL; // peak amplitude in engineering units (e.g., 27648 = 10 V)
Offset : REAL; // DC offset for unipolar outputs
SamplesPerSec: REAL; // 1 / T_OB
END_VAR
BEGIN
// --- Step 1: advance the angle accumulator ---
Angle := Angle + Step;
IF Angle >= 6.2831853 THEN
Angle := Angle - 6.2831853;
END_IF;
// --- Step 2: compute sine value scaled to DAC range ---
// For bipolar ±10 V output:
// output = Offset + Amplitude * SIN(Angle)
// For unipolar 0-10 V output:
// output = Offset + Amplitude * (SIN(Angle) + 1) / 2
%QW96:P := REAL_TO_INT(Offset + Amplitude * SIN(Angle));
END_FUNCTION_BLOCK
Configure OB30 properties in TIA Portal:
- Cycle time:
2 ms
1 - Phase offset:
0 µs - Priority: Leave default (typically priority class 8).
- Assigned FB: instance DB of
FB_SineGen.
To change the signal frequency at runtime without restarting OB30, update the Step tag:
Step = 2π · f_signal · T_OB = 2π · f_signal / f_s
For a 50 Hz signal at 2 ms sample time:
Step = 2π · 50 · 0.002 = 0.6283 rad/sample
8. Ladder Logic Alternative
If the project standard mandates LAD/FBD, the same functionality is achievable using:
- A MOVE instruction writing the computed INT to
%QW96:P. - An ADD_R chain in the angle accumulator.
- The built-in SIN instruction from the "Extended Instructions" palette (S7-1200 firmware V4.0+).
The execution time of the SCL SIN function on a CPU 1215C is approximately 18-25 µs — well below the 2 ms OB30 budget — but if the cycle time is set to 1 ms, the sine call may consume 2-3 % of CPU time per OB30 invocation. Benchmark on the target CPU before committing to 1 ms sampling.
9. PWM and PTO as Alternative Analog Reconstruction
If the S7-1200 must drive a slow actuator and the cosine fidelity requirement is modest (< 5 % THD), consider modulating a digital high-speed output:
- PWM (Pulse Width Modulation): The CPU's onboard PWM generators (up to 4 on a CPU 1215C) produce a fixed-frequency, variable-duty-cycle square wave. Feed this through an external RC low-pass filter; the DC component reconstructs the average value. Filter cutoff must be at least 10× below the PWM carrier to suppress ripple.
- PTO (Pulse Train Output): The high-speed counters can emit a fixed number of pulses at a programmed frequency; combine with an external integrator (op-amp with C in feedback) for an analog ramp. Not directly suitable for sinusoidal reconstruction but useful as a coarse D/A.
For sinusoidal reconstruction, PWM is the most viable PLC-native approach. A 1 kHz PWM with a 100 Hz cutoff RC filter gives ~5 % ripple, which can be acceptable for dither signals but inadequate for instrumentation.
10. External Signal Generator Considerations
When the application demands > 100 Hz sine fidelity (audio excitation, ultrasonic transducer drive, vibration table control), the PLC is the wrong tool. Specify a dedicated signal source:
- Function/Arbitrary Waveform Generator: Standalone instruments (Keysight 33500B, Rigol DG1000 series, Siglent SDG1000) produce 1 µHz to 30 MHz sine with < -60 dBc THD. Control them via Modbus TCP, RS-232, or USB from the S7-1200.
- DDS (Direct Digital Synthesis) IC: A small PCB module (AD9833, AD9850) generates 0-12.5 MHz sine from a serial SPI command. Suitable for embedded excitation where the PLC orchestrates but does not generate the waveform.
- CompactDAQ / PXIe: National Instruments multifunction DAQ (myDAQ, cDAQ-9174) provides up to 200 kHz analog output update rate with hardware-timed generation. Used for laboratory-grade signal synthesis.
11. Mechanical Alternatives for Sinusoidal Motion
If the ultimate goal is sinusoidal mechanical motion rather than a sinusoidal electrical signal, a mechanical cam or crank profile driven by a servo motor may produce a more accurate result than any electrical DAC. The crank's displacement is naturally sinusoidal; a single rotation of the crank at constant angular velocity yields a perfect sine stroke. Pair the crank with a SINAMICS V90 or SIMOTION D servo drive for closed-loop positioning, then synchronize the master axis via PROFIdrive / PROFINET IRT.
This is the preferred architecture when driving pneumatic servo valves whose spool position must follow a sinusoid (for example, in active vibration damping or respiratory simulator pumps).
12. Verification and Commissioning Procedure
- Verify wiring: Connect the SM 1232 voltage output channel 0 to an oscilloscope with a 10:1 probe and a shielded twisted pair.
-
Set the engineering range: In the device configuration, choose "Voltage ±10 V" and confirm the corresponding INT range
-27648 to +27648. -
Force the OB30 frequency: Set
f_signal = 1 Hzfirst; verify the scope shows a clean sinusoid with peak-to-peak amplitude matching2 · Amplitude. -
Verify timing: Use the scope's horizontal cursors to confirm period
T = 1 / f_signal± 2 %. - Step frequency up: Sweep 1, 5, 10, 25, 50, 75, 100 Hz. At each step, measure peak-to-peak and THD.
- Watch for ripple: Visible staircase artefacts appear when the OB30 interval approaches the SM 1232 settling time. Reduce N or move to a CPU with faster interrupt.
- CPU load check: Open TIA Portal online > Diagnostics > CPU information. OB30 time must stay < 80 % of cycle time; otherwise reduce cycle time or move logic to OB1.
-
Jitter probe: Place an empty FB in OB30 that increments a tag and a second tag that captures
RD_SYS_Teach call. Diff in the watch table to measure actual interval.
13. Troubleshooting Matrix
| Symptom | Likely Cause | Remedy |
|---|---|---|
| Output is DC, no sine observed | OB30 not running, or FB not assigned | Verify OB30 is enabled in TIA Portal and an instance DB is bound |
| Output is staircase with overshoot | Load capacitance exceeds 1 µF, settling time violated | Buffer with op-amp follower or reduce f_s |
| Frequency drifts slowly | OB30 jitter from PROFINET / HMI load | Reduce HMI polling, disable web server, enable phase compensation |
| Amplitude is half of expected | Unipolar range (0-10 V) selected instead of bipolar | Change device configuration to ±10 V or add DC offset |
| CPU goes to STOP with SF LED | OB30 cycle time exceeded | Increase T_OB to 5 ms or 10 ms; remove time-consuming instructions |
| Output is noisy / random | Direct write :P missing, PIQ flushed late |
Append :P to %QW96:P
|
| Sine has DC offset | INT truncation in REAL_TO_INT
|
Apply ROUND instead of REAL_TO_INT, or center offset |
| Periodic glitches on scope | PROFINET update coinciding with OB30 | Shift phase offset or assign OB30 to dedicated PROFINET slot |
| Maximum output is 7.5 V instead of 10 V | Sin range clipped to 13-bit on current-output variant | Verify SM 1232 variant (voltage vs current) in hardware catalog |
| THD > 5 % above 50 Hz | N too low (samples per period < 16) | Increase f_s or accept lower maximum signal frequency |
14. S7-1200 CPU Model Selection for Sine Generation
| CPU | Min OB30 Cycle | Recommended f_s_max | Max f_signal at N=20 |
|---|---|---|---|
| CPU 1211C | 2 ms | 500 Hz | 25 Hz |
| CPU 1212C | 2 ms | 500 Hz | 25 Hz |
| CPU 1214C | 1 ms | 1 000 Hz | 50 Hz |
| CPU 1215C | 1 ms | 1 000 Hz | 50 Hz |
| CPU 1217C | 500 µs | 2 000 Hz | 100 Hz |
15. Frequently Asked Questions
What is the absolute maximum sinusoidal frequency the SM 1232 can generate?
For a voltage output into a 1 µF load, the analog stage settles in 750 µs, allowing roughly 1 333 steps per second. With 20 samples per period, this caps the sine frequency at about 66 Hz. Practical deployments typically run 25-50 Hz to preserve THD below 2 %.
Does the OB1 scan time directly limit the SM 1232 analog output rate?
No, not when you use a cyclic interrupt OB (OB30-OB38). OB3x interrupts OB1 at a fixed cycle independent of OB1's duration. The scan time of OB1 only matters if you place the DAC write inside OB1; doing so couples the analog output to the full program cycle, which is unsuitable for high-rate signaling.
Is the OB3x cyclic interrupt truly deterministic on an S7-1200?
Mostly. PROFINET / PROFIBUS I/O updates, HMI polling, and communication OBs can delay OB3x by tens of microseconds. For most valve and drive reference applications this jitter is negligible. For sub-millisecond precision, use phase compensation based on the system clock reading at each OB3x entry.
Why does my SM 1232 output show staircase artefacts even at 10 Hz?
Either the load impedance is heavier than the datasheet specifies (causing longer settling time) or your OB3x cycle is longer than expected because the CPU is busy with other OBs. Verify with the online CPU diagnostics that the OB30 actual run-time is < 80 % of its nominal cycle. Add a buffer op-amp if the load exceeds 1 µF or 10 mH.
Can I generate a bipolar sine wave on a unipolar 0-10 V output?
Yes, by adding a DC offset of 5 V and scaling the sine amplitude to ±5 V. The PLC writes values from 0 to 27 648 corresponding to 0-10 V. Alternatively, use the bipolar ±10 V range if your hardware variant supports it. For 4-20 mA outputs, the sine must be entirely within the 4-20 mA window, so subtract 12 mA offset and scale to ±8 mA peak.
Should I use direct peripheral write (:P) or the process image?
Always use :P direct peripheral write inside the cyclic interrupt. The process image (PIQ) is only flushed at the end of the OB1 cycle, which would add an entire OB1 scan delay (5-50 ms) to each analog step — completely ruining the waveform timing.
What firmware version of TIA Portal is required for cyclic interrupts at 1 ms?
TIA Portal V14 or later with S7-1200 CPU firmware V4.0 or later. Earlier firmware versions cap OB3x at 2 ms. Always update to the latest service pack before commissioning a high-rate analog output system.