AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

How-to

Calculate Belt Speed From a Proximity Sensor in an S7-1200

Sensors, encoders and machine vision on the machine Published 7 min read By AutomateDirectUSA engineering team

Short answer

Measure the sensor's pulses with a hardware high-speed counter in frequency mode, then divide the reading by pulses per pulley revolution and multiply by the pulley circumference. Counting edges in the cyclic program gives scan-dependent jitter, and the default input filter can clip short pulses.

On this page
  1. Why scan-by-scan edge counting gives the wrong speed
  2. Match the sensor and the input to the pulse frequency
  3. Configure the counter, the filter and the gate time
  4. Worked example: six targets on a 200 mm pulley
  5. Verify the reading on the machine
  6. Pitfalls that make the speed read wrong
  7. Questions asked

Belt speed from a proximity sensor is one division and one multiplication: measure the sensor's pulse frequency in hertz, divide by the number of pulses the pulley produces in one revolution, and multiply by the pulley's circumference. With the pulley's effective diameter D in metres, the belt speed is v = (f / PPR) × π × D in metres per second. The measurement itself must come from a hardware high-speed counter, not from edge detection in the cyclic program: on an S7-1200 you enable a counter in the CPU properties, set the counting type to Frequency, and read the value in OB1 as an ordinary process-image tag. This article shows the wiring choice, the exact configuration steps, the scaling arithmetic worked through for a real pulley, and the checks that prove the reading.

Why scan-by-scan edge counting gives the wrong speed #

A pulse is only seen if the program samples the input while it is high. OB1 samples once per scan, and the sampled state is further delayed by the input filter and the process-image update. Scan time changes with program load and communication, so the interval between two detected edges carries a random error that lands directly in the speed value. Worse, pulses shorter than one scan are missed entirely, so the speed reads low exactly when the belt runs fast.

A hardware high-speed counter counts edges in the input electronics, independent of the program cycle. In frequency mode it counts edges over a fixed gate time and reports the result in hertz, so the reading is tied to a known window instead of a variable scan time. That is the whole reason this measurement belongs in the counter and not in OB1 logic.

Match the sensor and the input to the pulse frequency #

Before configuring anything, check that the sensor survives the fastest pulse rate the target wheel can produce:

  • Maximum pulse frequency: f_max = (v_max / (π × D)) × PPR, with v_max in m/s, D in m and PPR as pulses per pulley revolution (one per sensing target).
  • Choose a sensor whose output switching time is well below the shortest pulse width at that frequency. A standard inductive sensor is fine at conveyor speeds; if the targets are fine or the shaft is fast, a fast optical sensor is the alternative. Either output type works, as long as its 24 V DC level and sinking or sourcing behaviour match the input group wiring.
  • Wire the sensor to an input that can be assigned to a high-speed counter. On many S7-1200 CPUs the counter-capable channels are the first four onboard inputs, I1 through I4; confirm the mapping and maximum input frequency for your exact CPU in its system manual before committing the wiring.

If the sensor watches the motor shaft instead of the pulley, note the gearbox ratio: the shaft turns faster than the pulley by that factor, and the scaling in the worked example must divide by it first.

Configure the counter, the filter and the gate time #

Everything below happens in TIA Portal, in the CPU's device configuration, followed by one block in OB1. Isolate and lock out the panel before touching the sensor wiring.

  1. In the device view, select the CPU and open its properties. Under High speed counters, enable one counter (for example HSC1) and set its counting type to Frequency.
  2. Choose the gate time, the measurement window the dialog offers. One second is a workable start: it updates once per second and resolves single hertz steps.
  3. Assign the counter to the wired input and note the process-image address it exposes. HSC1's current value is available by default at %ID1000 as a DInt; the frequency measurement reports through the same tag on CPUs configured for that counting type.
  4. Open the digital input properties for the channel you wired and shorten the input filter. The default is 6.4 ms, and Siemens' own documentation warns this may be too slow for fast process signals; a filter longer than the pulse width deletes pulses before any counter sees them, the same mechanism that makes a PLC miss short input pulses. Set it clearly below the shortest pulse width, for example 0.2 ms.
  5. In the program, keep the counter enabled: the frequency measurement runs only while the counter's enable input (EnHSC on the frequency function) is true.
  6. In OB1, read the tag from step 3 every scan, convert the DInt to Real once, and scale it: belt speed = (frequency value / PPR) × π × D, all in metres and seconds.
  7. Add a standstill timeout: if the frequency value has stayed at its last reading for longer than the slowest pulse interval you expect while running, force the speed value to zero. The last gate window is never updated at standstill, so without this the display freezes at the final running speed.

Worked example: six targets on a 200 mm pulley #

Inputs, and where each comes from: the pulley's effective diameter D = 0.200 m, measured across the pulley and including the belt thickness (example values for this case); six bolt heads evenly spaced on the pulley face, so PPR = 6; the counter reads f = 4.8 Hz with the 1 s gate from the configuration above.

The rule in words: hertz divided by pulses per revolution gives pulley revolutions per second; revolutions per second times circumference gives surface speed, which for a non-slipping belt equals belt speed.

Arithmetic:

  • Pulley speed: 4.8 Hz / 6 pulses per revolution = 0.8 rev/s, which is 0.8 × 60 = 48 rpm.
  • Circumference: π × 0.200 m = 0.6283 m.
  • Belt speed: 0.8 rev/s × 0.6283 m = 0.503 m/s.

Resolution check: with a 1 s gate, one counted edge changes the reading by 1 Hz, and 1 Hz / 6 × 0.6283 m = 0.105 m/s. At 0.5 m/s that is roughly a fifth of the reading, so if you need better resolution, add evenly spaced targets or lengthen the gate time.

Headroom check: at a maximum belt speed of 1.0 m/s the same pulley produces (1.0 / 0.6283) × 6 = 9.55 Hz, with a pulse period near 105 ms. That sits far below any HSC input limit, and a 0.2 ms filter passes those pulses without touching them. The decision: this target count, pulley and gate time are a sound combination for conveyor speeds up to 1 m/s; finer speed resolution comes from more targets, not from a longer gate alone.

Verify the reading on the machine #

  • Stop the belt: the frequency tag must return to the standstill timeout's zero. If it holds the last speed, the timeout in step 7 is missing or set longer than you think.
  • Run steady and watch the value in a watch table: it should sit within one gate-time step of a constant, with no scan-linked jitter.
  • Mark the belt, time a known length with a stopwatch, and compare against the calculated metres per second; they should agree within the stopwatch error.
  • Step the drive speed up and down: the calculated speed must follow proportionally, and at maximum speed the reading must keep tracking, confirming the pulse rate stays under the counter and filter limits.

Pitfalls that make the speed read wrong #

  • One target per revolution at low belt speed gives a pulse rate of well under one hertz, so the reading updates slowly and in coarse steps. Add targets or lengthen the gate. This is a resolution problem, closely related to why an RPM reading from a proximity switch steps coarsely at low speed.
  • Unevenly spaced targets produce a ripple at the pulley rotation frequency on top of the true speed; make the spacing equal.
  • Belt slip means the pulley-mounted sensor reports pulley speed, not true belt speed. If the true belt speed matters, sense a non-driven roller instead.
  • Averaging a scan-timed edge count in the program smooths the display but does not remove the scan error; the fix is the hardware counter, not a filter in the logic.
  • Leaving the input filter at its 6.4 ms default clips pulses with no diagnostic anywhere in the system; check it whenever a counter that was working reads low after a sensor or target-wheel change.

Commit to the order above and the reading is trustworthy: hardware counting for the frequency, the arithmetic from the worked example for the scaling, and the standstill timeout so the value tells the truth when the belt is not moving.

Questions asked

What gate time should the frequency measurement use?

The gate time sets the resolution and the update rate. A 1 s gate resolves about 1 Hz, which on the worked example's six targets and 200 mm pulley is roughly 0.10 m/s of speed resolution. Lengthen the gate for finer resolution at a slow belt, or add targets so the same gate resolves more pulses per revolution.

Why does the speed reading hold its last value when the belt stops?

The counter reports the frequency measured over its last gate window. When the belt stops, no new edges arrive, so nothing updates the value and it stays at the last running speed. Add a standstill timer in the program: if the reading has not changed within a timeout longer than the slowest pulse interval, force the speed value to zero.

Can I wire the proximity sensor to a normal digital input instead?

A standard input goes through the process image once per scan, so pulses shorter than the scan time or the input filter never reach the program. Even when every pulse is caught, the interval between edges is timed against a variable scan time. A hardware high-speed counter counts every edge independent of the program, which is what the frequency value needs.

Does belt slip affect the speed calculated this way?

Yes. A sensor looking at the drive pulley reports pulley speed, not true belt speed, and any slip between belt and pulley makes the real belt slower than the calculated value. Mount the sensor on a non-driven roller or idler that the belt cannot slip on if the true belt speed matters for cut-to-length or registration.

Keep reading

  • How-to

    Measuring RPM With a Proximity Switch on a Pulley

    One bolt pass per revolution at 6,000 RPM is a 100 Hz signal any standard inductive proximity switch can produce and a scanned PLC input cannot reliably count, so route it to a high-speed input and verify the ON pulse clears the input's documented minimum — 100 µs on the DL05's X0–X2 inputs — with a scope at full speed.

    Sensors, encoders and machine vision on the machine

  • Explainer

    Why a proximity switch RPM reading steps by 60 at low speed

    With one target and a one-second frequency gate, the counter sees whole pulses only: at 190 to 200 RPM that is 3.2 to 3.3 pulses per second, so the display shows 3 or 4 counts times 60, giving 180 or 240 RPM. Add targets to cut the step to 60/P RPM, lengthen the window to 6 RPM per count over 10 s, or time the gap between pulses.

    Sensors, encoders and machine vision on the machine

  • How-to

    Counting Encoder Pulses on a PLC Without Losing Position

    Count encoder pulses with a hardware high-speed counter input wired for quadrature, never with a count instruction in the scan. At 214 rpm and 75 pulses per revolution the encoder delivers 267.5 pulses per second, one every 3.7 ms, while a 10 ms scan cannot guarantee seeing even one in three. Zero the counter at a reference switch and treat every target as counts from that switch.

    Sensors, encoders and machine vision on the machine