Conveyor Speed via Proximity Pulses on Siemens S7-300

David Krause15 min read
S7-300SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Conveyor Speed via Proximity Pulses on Siemens S7-300

A single inductive proximity switch mounted on the head or tail roller of a conveyor is the cheapest possible tachometer. It emits one pulse per revolution, the PLC counts those pulses inside a fixed time window, and the line speed in m/s is reduced to one multiplication and one division. The challenge on the S7-300 platform is not the math but the choices you make around the input filter time, the cycle in which you count, and how the program copes with the motor start-up transient. This reference walks through a CPU 317F-2 PN/DP implementation with a 30 cm roller, the relevant S7-300 signal chain, the frequency limits of the standard SM 321 digital input modules, working SCL code, an optional FM 350-1 high-speed counter upgrade path, and a clean migration to IO-Link when the conveyor is rebuilt with Sirius and ET 200SP.

Read this first. The roller circumference, the pulses-per-revolution (PPR) of the target wheel, and the input filter of the DI module define the maximum line speed you can measure. Push the wrong combination and the PLC will silently drop pulses instead of giving a wrong number — verify with a hand tachometer before commissioning.

1. System Overview

Application: monitoring a driven conveyor belt (belt linear speed expected 0.3–3 m/s typical, peaks up to 5 m/s), with a 3-wire PNP inductive proximity mounted once per revolution of the drive roller. The PLC is a Siemens CPU 317F-2 PN/DP (order number 6ES7317-2EK14-0AB0, firmware V3.3) backed by a standard SM 321 6ES7321-1BH02-0AA0 16DI/24 V module. The pulse is a single 24 V rising edge per revolution, so the entire feature reduces to a counter, a 10 s sampling window, and one real multiplication.

Signal chain: roller to HMI Drive rollerD = 0.30 m Inductive proxPNP NO, 24 V, 1 PPR SM 321 DI6ES7321-1BH02 CPU 317F-2 PN/DPOB1 / OB35 / SCL HMI / SCADAWinCC / TIA mechanical 24 V pulse process image tag: belt_speed

2. Prerequisites

Item Specification Notes
CPU 6ES7317-2EK14-0AB0 (CPU 317F-2 PN/DP) Firmware V3.3; supports F-runtime, PROFINET, PROFIBUS
DI module 6ES7321-1BH02-0AA0 (16 DI 24 V, 0.5 ms typ.) Configure input filter 3 ms or 15 ms in HW config
PSU PS 307 6ES7307-1EA01-0AA0 (5 A) Supplies prox + DI inputs
Sensor SICK IME12-2BPSZW2K (PNP NO, 10–30 V, 200 mA) M12 housing, IP67, 4 mm sensing range
Target M4 stud or M6 bolt on roller face Single lobe, gives 1 PPR; multi-tooth wheel for higher resolution
Engineering STEP 7 V5.6 + SP2 or TIA Portal V17 S7-300 with CPU 317F is fully supported in both
Roller Diameter 300 mm, rubber lagged User-provided; verify by tape measure, not nameplate
Verify the diameter at the lagging surface. A rubber-lagged drive roller can measure 290 mm at the bare shell and 312 mm at the lagging OD. Speed is calculated at the lagging surface because that is what the belt contacts; a 7% error here is a 7% error in m/s.

3. Belt Speed Mathematics

Given a roller of effective diameter D and one pulse per revolution (PPR = 1), the belt linear distance travelled per pulse equals the roller circumference:

C = π · D   [m/rev]     v = (N / T) · C / PPR   [m/s]

With D = 0.30 m the roller circumference is 0.9425 m per revolution. For higher resolution you can mount a multi-tooth wheel (a sprocket or a custom disc with 4–12 ferrous targets) and use PPR = number of teeth; the formula above is unchanged. To make the engineering case to operations, the table below maps line speed to pulse frequency and the number of pulses captured inside a 10 s sampling window for PPR = 1.

Belt speed v [m/s] Pulse freq f = v/C [Hz] Period [ms] Counts in 10 s
0.25 0.265 3770 3
0.50 0.531 1885 5
1.00 1.061 943 11
2.00 2.122 471 21
3.00 3.183 314 32
5.00 5.305 189 53

For belt speeds up to 5 m/s, 53 pulses per 10 s — a pulse period of 189 ms — is comfortably above the floor imposed by any DI filter you might configure. Speed resolution is approximately 0.094 m/s per pulse in a 10 s window. If 0.1 m/s granularity is too coarse, drop the window to 1 s and live with the noise, or increase PPR to 4 and the resolution becomes 0.024 m/s for the same 10 s window.

4. Frequency Limits of Standard Digital Inputs

The SM 321 family supports selectable input filter times. On the 6ES7321-1BH02-0AA0, the HW config in TIA Portal exposes 0.1 ms, 0.5 ms, 3 ms, and 15 ms filter options. The maximum pulse frequency that the input can capture is roughly 1 / (2 · t_filter); below that figure the rising edges are passed cleanly to the process image. Above it, edges are clipped, the counter under-reads, and the computed speed is silently too low.

Filter t_filter Max countable freq Min countable period Suitable line speed (PPR=1, D=0.30 m)
0.1 ms ~5 000 Hz 0.2 ms ≤ 4 712 m/s (irrelevant upper limit)
0.5 ms ~1 000 Hz 1.0 ms ≤ 942 m/s
3 ms (default) ~166 Hz 6 ms ≤ 156 m/s
15 ms ~33 Hz 30 ms ≤ 31 m/s

For a 1 PPR roller at 5 m/s the pulse rate is barely 5.3 Hz, so even the 15 ms filter (33 Hz ceiling) is more than adequate. The reason to choose the 3 ms or 15 ms filter is noise immunity: long cable runs alongside a Sirius 3RW soft-starter or a PowerFlex/Sinamics VFD inject common-mode noise that can corrupt fast 0.1 ms edges. For a 1 PPR target with cable length ≤ 25 m, use 3 ms. For a multi-tooth wheel with PPR = 10, the pulse rate is 10× higher, so the filter must be 0.5 ms or the counter will under-read.

5. Wiring the Inductive Proximity to SM 321

Wire the PNP output of the proximity to a 24 V input channel of the SM 321, sharing the same PSU that powers the sensor. The standard 3-wire schematic uses brown (+24 V) from the PSU, blue (0 V) to PSU 0 V, and black (NO output) to the SM 321 input terminal. Use shielded cable (e.g. LiYCY 3 x 0.34 mm²) and bond the shield at the cabinet entry gland only; the SM 321 channel itself is not referenced to shield.

3-wire PNP prox to SM 321 wiring Prox (PNP NO) +24 V (brn) 0 V (blu) NO (blk) SM 321 6ES7321-1BH02-0AA0 (channel 0) terminal 1 (+24 V bus) terminal 20 (M) terminal 2 (I0.0) Shield: bonded at cabinet gland, not at sensor
Source vs sink. SM 321-1BH02 is a sourcing (PNP-type) input module. If you replace the prox with a 2-wire DC sensor or a NPN device, the input will read inverted or not at all — verify the prox datasheet and the module type before energizing.

6. Time-Window Pulse Counting in S7-300

Two implementation strategies exist. The first uses a hardware counter on the CPU or an FM 350-1, and the second uses the standard process image plus a software counter in OB1 or a cyclic interrupt OB (OB10…OB17, or OB35 at 100 ms). For a 1 PPR sensor at 5 m/s, the software counter is fully adequate because the shortest period (189 ms) is an order of magnitude longer than the typical OB1 scan of 5–15 ms. The rule of thumb is: a software counter in OB1 is safe when PPR × v / C < 1 / (4 · t_OB1). For 1 PPR and 0.3 m roller this evaluates to v < 1 / (4 · 0.015 · 0.9425) ≈ 17.7 m/s. Above that, switch to the FM 350-1.

7. Startup Delay and Latch Logic

A conveyor driven by a soft-started motor (Sirius 3RW, Sinamics V20, or PowerFlex) takes 2–8 seconds to reach speed. Counting pulses in the first 1–2 seconds would yield a low, false speed. The standard solution is a TON timer (in IEC 61131-3, the SFB 4 / IEC_TIMER_0_1) armed on the motor start command, after which pulse accumulation is enabled and the sample window is held open for 10 s. On every window expiry, the latched count is divided by window time and multiplied by the circumference, then the counter is reset and the next window begins.

Timing: motor start, gate, sample window, refresh 0 s 2 s 4 s 6 s 8 s 10 s 12 s Motor start cmd (1) Motor actual speed (ramp) Gate (start delay done, enable count) Sample window 10 s (counter latched on rising edge)

8. SCL Implementation on CPU 317F

The FB below encapsulates the gate, the counter, and the speed calculation. It can be called once per OB1 cycle or once per OB35 tick. Constants are exposed in the instance DB so they can be tuned from the HMI without re-loading the program.

FUNCTION_BLOCK FB_BeltSpeed
VAR_INPUT
    iStartCmd   : BOOL;   // 1 = motor start request
    iProxPulse  : BOOL;   // prox input (filtered process image)
END_VAR
VAR_OUTPUT
    oSpeedMs    : REAL;   // belt linear speed in m/s
    oRunning    : BOOL;   // 1 = monitoring active (after start delay)
    oCount      : INT;    // pulses in the current window (live)
    oFault      : BOOL;   // 1 = no pulse in window while command active
END_VAR
VAR
    tStartDelay : TON;    // IEC on-delay
    tSample     : TON;    // IEC 10 s window
    rCircum     : REAL;   // pi * D, in m
    cnt         : INT;
    bLatchEdge  : BOOL;
END_VAR
VAR CONSTANT
    T_START_DELAY : TIME := T#10s;
    T_SAMPLE      : TIME := T#10s;
    D_ROLLER_M    : REAL := 0.30;
    PPR           : INT  := 1;
END_VAR

BEGIN
    // roller circumference per revolution
    rCircum := 3.14159265 * D_ROLLER_M;

    // gate: arm on start command, hold 10 s
    tStartDelay(IN := iStartCmd, PT := T_START_DELAY);
    oRunning := tStartDelay.Q;

    // count edges only when running
    IF oRunning AND iProxPulse THEN
        cnt := cnt + 1;
    END_IF;
    oCount := cnt;

    // 10 s sampling window with rising-edge latch
    tSample(IN := oRunning, PT := T_SAMPLE);
    IF tSample.Q THEN
        // freq [Hz] * circumference [m] / PPR = m/s
        oSpeedMs := (INT_TO_REAL(cnt) / TIME_TO_REAL(T_SAMPLE))
                    * rCircum / INT_TO_REAL(PPR);
        cnt := 0;
        tSample(IN := FALSE);   // re-arm next cycle via oRunning
    END_IF;

    // no-pulse fault: command active, gate open, but count == 0 over 10 s
    oFault := oRunning AND (cnt = 0) AND tSample.Q;
END_FUNCTION_BLOCK
Reset of TON in SCL. Assigning IN := FALSE and leaving the call intact inside the same scan is the documented way to retrigger a TON in STEP 7 / TIA. To be defensive, wrap the latch in a one-shot using a static edge memory bit rather than the IN := FALSE trick, which is legal but easy to misread.

9. High-Speed Counter Alternative (FM 350-1, ET 200S 1Count)

When the application grows — a multi-tooth encoder, a VFD that needs an actual speed feedback channel, or a 5 m/s line with PPR = 60 — the FM 350-1 counter module (6ES7350-1AH03-0AE0) reads up to 500 kHz per channel and exposes the count as well as a hardware-calculated frequency via the CTRL1 block. The ET 200S 1Count 24 V module (6ES7138-4AA01-0AB0) is the distributed alternative on PROFIBUS or PROFINET. Both eliminate the cycle-time dependence of the OB1 counter and report directly in Hz, which the S7-300 then converts to m/s with a single multiplication by the circumference.

Module Order number Max input freq Reports Use case
FM 350-1 6ES7350-1AH03-0AE0 500 kHz count, frequency, period Centralised, fast encoder
ET 200S 1Count 24 V 6ES7138-4AA01-0AB0 100 kHz count, frequency Distributed cabinet, 1 channel
ET 200SP TM Count 1x24 V 6ES7138-6AA00-0BA0 200 kHz count, frequency, position PROFINET to S7-300 via IE/PB

10. IO-Link Migration Path

The user’s note about renewing the system with “Sirius and I/O Link” points to the modern replacement. Inductive sensors with IO-Link output (SICK IME12, IFM IG5, Balluff BES M12) report not just the bit but also diagnostic data (count overflow, target visibility, supply voltage). On the S7-300 side, an ET 200SP station with interface module 6ES7155-6AU00-0BN0 plus a CM 4xIO-Link communication module 6ES7557-0AA00-0AB0 brings the data into the CPU via PROFINET. The pulse stream is then delivered as a 32-bit process value with no DI filter in the path, and the SCL in section 8 can be reused without modification — only the source of iProxPulse changes.

11. Verification and Commissioning Procedure

  1. Mechanically confirm roller diameter at the lagging surface with a tape measure. Compare to the nameplate; the lagging thickness often adds 5–15 mm to the bare OD.
  2. With the motor stopped and the prox energised, place a ferrous target by hand under the prox. Verify the SM 321 input LED toggles and the process image in the online view reflects the change.
  3. In the FB instance DB, set a temporary D_ROLLER_M = 0.30 and force iStartCmd = TRUE. Watch oCount increment on each pulse and oSpeedMs update every 10 s.
  4. Compare the calculated speed against a hand tachometer on the roller (rev/s × C). Tolerate ± 5% for belt slip on the roller; ± 1% if the roller is directly geared to the motor.
  5. Run the conveyor at the maximum design speed (5 m/s in this example). At the 10 s window refresh, verify oCount ≈ 53 and oSpeedMs ≈ 5.0.
  6. Stop the conveyor with the command still asserted. Verify oFault rises to TRUE within one window and is logged to the HMI alarm view.
  7. Open the Web server of the CPU 317F-2 PN/DP (http://<cpu-ip>) and confirm the oSpeedMs tag is visible in the diagnostics buffer, in case the HMI is unavailable.

12. Troubleshooting Matrix

Symptom Likely cause Diagnostic Remediation
oSpeedMs always 0.0 even though prox LED toggles Wrong process image address or counter disabled by oRunning Online view of FB instance DB; check tStartDelay.Q Confirm motor start command reaches iStartCmd; if prox is mapped to I0.0, verify the channel is enabled in HW config
oSpeedMs consistently ~30% low Belt slip on roller, or PPR mismatch (multi-tooth wheel but PPR=1 in code) Hand tachometer on the roller vs. m/s on the belt Set PPR to the actual tooth count, or compensate for slip with a scaling factor
oSpeedMs reads correctly at low speed, drops to 0 above ~2 m/s DI input filter too long for pulse period Compare pulse rate (1/T) to the filter selection in HW config Reduce filter to 0.5 ms; if still dropping pulses, switch to FM 350-1 or ET 200S 1Count
Random extra counts when VFD starts Common-mode noise from Sirius soft-starter or VFD coupling into the prox line Oscilloscope on the DI terminal; check shielded cable termination Increase filter to 3 ms, bond shield at cabinet gland only, route prox cable away from motor cables by ≥ 200 mm
oFault never asserts even when belt is stopped iStartCmd not held high during the test, or oRunning is FALSE Force iStartCmd TRUE in watch table and re-test Use the actual start signal in the code; add a watchdog timer that asserts oFault if oRunning AND (cnt = 0) for > 1 window
Speed value jitters by ± 0.1 m/s on the HMI Window too short, integer count resolution Count vs. time; 1 pulse = 0.094 m/s at 10 s window Use a 30 s window, or install a 4-tooth target (PPR=4) for 0.024 m/s per pulse
Edge case: belt is not slipping but the roller is. Some conveyors use a crowned or rubber-lagged roller that flexes under load. A speed check at no-load may read 5.0 m/s while loaded it reads 4.7 m/s even with the same motor speed. The prox — mounted on the shaft, not on the belt — is the correct reference; trust the prox and accept the slip on the belt as a separate maintenance item.

13. Field-Proven Caveats

  • Mount the prox at the drive roller (motor side) rather than the tail roller. The drive roller has no belt slip relative to the shaft; the tail roller can slip on a worn take-up.
  • A single 4×4×4 mm cube of mild steel stuck on the roller face is a sufficient target for a typical 4 mm-sniff prox. Bigger targets mean more sensing margin and less missed pulses on a dirty or wet roller.
  • If the conveyor is inverted or vertical, add a software debounce of 20–50 ms after the rising edge; gravity-driven chains can chatter the prox at zero speed.
  • Route the prox cable in a separate conduit from the Sirius 3RW soft-starter power cables. The 3RW generates sharp edges at 4 kHz typical that capacitively couple into nearby low-voltage cables.
  • The CPU 317F-2 PN/DP web server is enabled by default in TIA Portal ≥ V15. Use it for first-line diagnostics even before the HMI is in place.

FAQ

How many pulses per revolution do I need for accurate speed on a 0.3 m roller?

One pulse per revolution is enough to read 0.1 m/s granularity in a 10 s window. For 0.02 m/s granularity on the same window, use a 4-tooth target (PPR = 4). Anything above 10 PPR pushes the pulse rate past what a stock 3 ms-filtered SM 321 can resolve at 5 m/s; switch to an FM 350-1 or ET 200S 1Count in that case.

Can I use a standard digital input on the CPU 317F directly without an SM 321?

The CPU 317F-2 PN/DP has 16 onboard DI on the front connector, but those are intended for F-signals (e.g. E-stop, guard door) and are configured for fail-safe processing. Using them for a pulse train works mechanically but is poor practice and increases the F-runtime load. Use a 6ES7321 SM 321 channel instead and keep the onboard F-DI for the safety chain.

Why does my speed read low only above 2 m/s?

The SM 321 input filter is almost certainly set to 3 ms or 15 ms. At 2 m/s the pulse period is 471 ms, so a 3 ms filter is harmless. At higher speeds the period shrinks and the filter starts to swallow edges. Lower the filter to 0.5 ms in HW config, or use a counter module, and the value will track the tachometer.

How do I detect “belt stopped but command active” (broken belt)?

Hold a watchdog: if oRunning is TRUE (the gate is open) and the pulse counter has not incremented for one full sample window, raise oFault. The FB in section 8 implements this. Route oFault to a Sirius 3RN thermistor-style alarm relay or directly to a HMI alarm for operator notification.

What is the best modern replacement for this prox wiring?

Replace the prox with an IO-Link inductive sensor (SICK IME12, IFM IG5 or Balluff BES M12) and add an ET 200SP station with a CM 4xIO-Link module on PROFINET. The IO-Link master delivers the count as a 32-bit process value with no DI filter, full diagnostics, and the option to monitor target visibility — useful for predictive maintenance on the roller bearing.

Back to blog