Converting Pulses to Liters on Siemens LOGO! 12/24RCE

David Krause12 min read
HMI ProgrammingSiemensTutorial / 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

Converting Pulses to Liters on Siemens LOGO! 12/24RCE

This reference explains how to build a complete pulse-to-volume conversion on the Siemens LOGO! 12/24RCE (LOGO! 8 generation). It covers the K-factor math, selection of fast input I3, configuration of the Up/Down Counter block in LOGO!Soft Comfort, scaling into liters, and displaying two magnitudes plus a configurable K-factor on the LOGO! TDE or onboard display. The procedure assumes a PNP/NPN flow sensor with a known pulse-to-volume ratio (for example 24 pulses = 3 L, equivalent to 0.125 L per pulse).

Before you start. Confirm the exact K-factor of your flow sensor from its datasheet. The K-factor is the only thing that converts a pulse count into a physical volume. If the datasheet only quotes pulses per gallon, convert to pulses per liter before entering it into the LOGO! parameter.

1. Pulse-Based Flow Measurement Overview

Most low-cost flow meters used in OEM skid and water-treatment applications output a discrete pulse for every fraction of a liter that passes through the meter body. Internally these meters contain a Hall-effect sensor, a reed switch, or an optical encoder that closes (or opens) a contact once per unit volume. The controller therefore never needs to know the actual flow rate - it counts edges and multiplies by the K-factor.

The two numbers you must extract from the sensor datasheet are:

  • K-factor (pulses per unit volume) - commonly quoted as pulses per liter (PPL) or pulses per gallon (PPG). Example: 8 pulses/L.
  • Volume per pulse - the reciprocal. Example: 0.125 L/pulse (= 125 mL/pulse).

If the sensor body is bidirectional (rare in cheap meters), the K-factor is the same in both directions and the LOGO! direction input simply decides whether to increment or decrement the count.

2. K-Factor Math: From Pulses to Volume

The relationship between pulse count and volume is linear:

V [L] = N [pulses] × k [L/pulse] = N / K [pulses/L]

Common K-factor conversions
Sensor rating Pulses per liter (PPL) Volume per pulse Liters for 24 pulses
1 pulse = 1000 mL 1 1.000 L 24.000 L
1 pulse = 100 mL 10 0.100 L 2.400 L
1 pulse = 25 mL 40 0.025 L 0.600 L
24 pulses = 3 L (example) 8 0.125 L 3.000 L
1 pulse = 1 mL 1000 0.001 L 0.024 L

Resolution and rounding are important. If 1 pulse = 125 mL, the smallest representable volume step is exactly 125 mL. The LOGO! can display fractional milliliters using its analog math blocks, but only with rounding - it never has sub-pulse resolution. Pick a sensor whose K-factor matches the smallest volume increment your process needs to record.

Unit conversion when the datasheet quotes pulses per gallon (US gallon = 3.785 L):

PPL = PPG / 3.785

k [L/pulse] = 3.785 / PPG

3. LOGO! 12/24RCE Hardware: Fast Input Capabilities

The LOGO! 12/24RCE is a 12/24 V DC powered logic module with eight digital inputs (I1 through I8) and four relay outputs (Q1 through Q4). The RCE suffix denotes the Ethernet variant with an integrated display and Web server. See the Siemens LOGO! product page for the full catalog.

Digital input specifications (LOGO! 12/24RCE, LOGO! 8)
Input Type Max frequency (counter) Typical use
I1, I2 Standard digital 4 Hz Pushbuttons, level switches
I3, I4, I5, I6 Fast digital 5 kHz Flow meters, encoders, fast sensors
I7, I8 Standard digital (analog-capable on 12/24 V variants) 4 Hz Pushbuttons or 0-10 V analog (I7 = AI1, I8 = AI2)
Max pulse rate. A typical industrial PNP flow sensor operates between 1 Hz and 200 Hz, well below the 5 kHz ceiling of the fast inputs. Use I3 only when you need high-frequency counting or when the LOGO!Soft Comfort tool has already been configured to wire the Up/Down Counter block to a fast input.

Wiring a 3-wire PNP flow sensor to I3:

  • Sensor brown wire (+V) to LOGO! +24 V terminal (or external 24 V supply if sensor draws > 200 mA).
  • Sensor blue wire (0 V) to LOGO! 0 V terminal.
  • Sensor black wire (signal) to terminal I3.
  • If the sensor is NPN, add a 4.7 kΩ pull-up resistor between I3 and +24 V.

For the LOGO! 12/24RCE the on-board supply is rated for limited current. Refer to the LOGO! 8 System Manual for the exact budget (typically 200 mA continuous across all sensors).

4. Counter Block Selection in LOGO!Soft Comfort

Open your project in LOGO!Soft Comfort (V8.x is compatible with the 12/24RCE). From the function block library drag the Up/Down Counter (sometimes labeled Counter in older builds) onto the FBD sheet. The block exposes:

Up/Down Counter block parameters
Terminal / Field Function Recommended setting
Cnt Count pulse - connect to I3 I3 (fast input)
Dir Direction control: 0 = up, 1 = down Constant 0 (or wire to a digital flag if bidirectional)
Rst Reset to zero (level-triggered) Wire to a digital input or message-text bit
St Gate: 0 = count, 1 = hold Constant 1 (counting always enabled) unless you want to gate flow during pump-off
SV (Set Value) Threshold for output Q Set in pulses, not liters. Used for "batch complete" logic.
Cnt (parameter) Current count value Enable Retention if you want totalized volume to survive a power cycle.
Q (output) TRUE while Cnt ≥ SV Feed into "batch done" lamp or coil.

The Cnt parameter is the live pulse count. This is the value you scale into liters downstream. The SV is purely a comparator threshold - it does not define the conversion factor.

Retention. In block properties, open the parameter tab and tick Retentive on the Cnt parameter. Without retention, the counter returns to 0 every time the LOGO! restarts, losing totalized volume. With retention the count survives power-down but still resets if the program is re-downloaded.

5. Program Logic: Counter, Scaling, and Math

The K-factor multiplication is performed with a basic analog math block. The simplest structure is shown below.

PNP Sensor 24 pulses = 3 L black wire LOGO! I3 fast input (5 kHz max) Up/Down Counter Cnt → N SV optional × k Math block V = N × k Liters output ↓ TDE display

FBD implementation (LOGO!Soft Comfort):

  1. Place Up/Down Counter block B001.
  2. Wire B001.Cnt input to I3.
  3. Wire B001.Dir input to constant 0 (count up only).
  4. Wire B001.Rst input to a digital marker (e.g. M1) controlled by a TDE reset button.
  5. Add an Analog Amplifier block B002 with Gain = K-factor (L/pulse) and Offset = 0.
  6. Connect B001 parameter Cnt to the input of B002.
  7. B002 output is the live volume in liters, referenced as AM01 (or whatever free analog marker is available).
  8. Display B001.Cnt (pulses) and B002 output (liters) on the LOGO! TDE.

If you prefer to enter the K-factor in pulses per liter rather than liters per pulse, swap the amplifier for a Division block:

V [L] = Cnt [pulses] / K-factor [pulses/L]

For the worked example (24 pulses = 3 L → K = 8 pulses/L), if the counter shows 192 pulses, the math block returns 192 / 8 = 24.000 L.

6. Display Configuration: TDE and Onboard Fields

The LOGO! 12/24RCE has a six-line, 16-character-per-line onboard display. The optional LOGO! TDE (Text Display with Ethernet) provides a larger, multi-line screen with the same menu structure. Both support message texts with embedded variables, which is the recommended way to show the three magnitudes the user requested.

Configure three message texts:

Recommended TDE message layout
Message text Line 1 Line 2 Line 3
Msg 1 (default) Pulses: %Cnt001 K-Factor: %AM02 PPL Volume: %AM01 L
Msg 2 (set K) Set pulses/L > %AM02 < OK=ESC
Msg 3 (reset) Reset total? OK=Cnt=0 ESC=cancel

The %AMxx and %Cnt001 tokens pull live values from the math and counter blocks. Editing %AM02 from the TDE changes the K-factor in real time without re-downloading the program. To allow operator editing, set the parameter Protection to Operator in the LOGO!Soft Comfort project properties.

Two magnitudes & one editable K-factor. The three fields the user requested map to (1) live pulse count, (2) editable K-factor in pulses per liter, and (3) computed volume in liters. Use the LOGO! TDE arrow keys and OK button to navigate; the editable field is the K-factor.

7. Edge Cases: Debounce, Direction, Overflow, Retention

7.1 Maximum pulse rate

Fast inputs I3-I6 are rated for 5 kHz. If the sensor can exceed this (large meters with paddle wheels at high flow), add an external hardware divider or downsample in software by counting every Nth pulse with a Pulse Generator block in divide mode.

7.2 Sensor bounce (reed-switch sensors)

Hall-effect and solid-state sensors are bounce-free. Mechanical reed switches can chatter at low flow. Add the LOGO! On-Delay block on the I3 input with a value of 5-10 ms to debounce. The trade-off is that pulse rates above 100 Hz can be missed - verify that the debounce time is shorter than the minimum pulse period of your sensor.

7.3 Counter overflow

LOGO! 8 counters use a 32-bit signed range. The Up/Down Counter parameter can reach ±999 999 before the analog representation saturates. For totalized volume across long campaigns, multiply the counter by the K-factor in floating-point math or use a second counter that bumps when the first reaches 999 999.

7.4 Bidirectional flow

If the meter can run backward, wire the direction signal from the sensor (or from a flow-direction flag) to B001.Dir. The math block still works because the counter goes negative. Display the absolute value if the application only cares about net forward volume.

7.5 Retention across power cycles

Open the Up/Down Counter properties, switch to the parameter tab, and tick Retentive on the Cnt value. Without this flag the totalizer resets to zero on every power-up, which usually destroys batch records.

7.6 Decimal display

LOGO!Soft Comfort allows fixed-point display on the TDE. To show liters with three decimal places (e.g. 24.000 L), set the message text token to %AM01:3.3f if supported by your LOGO!Soft Comfort build, otherwise format in the math block by amplifying by 1000, displaying as an integer, and re-scaling in the operator's head. Newer V8.4 builds support direct floating-point token formatting.

8. Commissioning and Verification

Before connecting the flow sensor, validate the program on the bench.

  1. Bench pulse source. Drive I3 with a function generator or a PLC-simulated pulse train at a known frequency (start at 1 Hz, ramp to 50 Hz). Confirm that B001.Cnt increments at exactly the source frequency.
  2. K-factor check. With K = 8 PPL, push 192 pulses into I3. Verify that the math block output shows 24.000 L within ±1 pulse of resolution.
  3. Reset path. Trigger the TDE reset button. Confirm Cnt returns to 0 and the math block output drops to 0.000 L.
  4. Retention check. Power-cycle the LOGO!. Confirm Cnt and the math output survive the cycle.
  5. Direction (if used). Toggle the Dir input while counting. Verify that Cnt decrements without going below -999 999.
  6. Field comparison. Run a known quantity of water (e.g. a 25 L bucket) through the meter. Compare the LOGO! display against the bucket volume. Allow ± one pulse of tolerance.
  7. Max-rate stress. Drive the sensor at its published maximum frequency for 60 seconds. Confirm no pulses are dropped and the LOGO! scan time does not exceed 100 ms (visible in the diagnostic menu).

9. Troubleshooting Matrix

Common faults on LOGO! pulse-to-volume conversions
Symptom Likely cause Diagnostic Fix
Cnt stays at 0 even with flow Sensor wired to a standard input (I1/I2) instead of I3 Toggle LOGO! status display to I3 - LED should blink at flow Re-wire sensor to I3, or change counter block input selection
Cnt increments, liters show 0 Math block Gain = 0, or K-factor not entered Monitor %AM01 in LOGO!Soft Comfort online mode Enter the correct K-factor in the Analog Amplifier Gain field
Liters value is 10× too high K-factor entered in pulses/L but math block expects L/pulse (or vice versa) Compare displayed value against (N / K) and (N × k) Switch between Amplifier and Division blocks, or invert K-factor
Cnt resets on every power-up Retention not enabled Block properties → parameter tab Tick Retentive on Cnt
Pulses missed at high flow Sensor on I1/I2 (4 Hz limit) or scan time too long Check input LED activity versus meter LED activity Re-wire to I3-I6, or reduce program complexity to shorten scan time
Extra pulses when flow stops Reed-switch bounce Count pulses with no flow - should be zero Add 5-10 ms on-delay debounce on I3
Liters drift slowly negative Bidirectional meter with Dir floating Toggle Dir input manually and observe Wire Dir to a defined constant or to the meter's direction output
Display shows ----- Math overflow (counter value outside amplifier range) Check Cnt value against -999 999 to +999 999 Pre-scale Cnt with a divide-by-N block, or split totalizer into two counters
TDE cannot edit K-factor Parameter protection set to "None" LOGO!Soft Comfort → Tools → Parameter Protection Set protection to Operator for the K-factor parameter

10. Frequently Asked Questions

How do I find the K-factor of my flow sensor?

Read it from the sensor datasheet. It is published as pulses per liter (PPL) or pulses per gallon (PPG). If the datasheet only states a volume per pulse, take the reciprocal to get PPL. For example, "1 pulse = 125 mL" is the same as 8 pulses per liter.

Why does my LOGO! count miss pulses at high flow?

Either the sensor is wired to a standard input (I1, I2, I7, I8 - limited to 4 Hz) or the LOGO! scan time is too long to service the fast input. Move the signal to I3, I4, I5, or I6 and verify in LOGO!Soft Comfort that the Up/Down Counter block is bound to that fast input.

What is the maximum pulse rate of input I3 on the 12/24RCE?

I3 through I6 are fast inputs rated at 5 kHz. This is well above the output of any PNP flow meter in the 1-200 Hz range. Confirm with the LOGO! 8 System Manual that the firmware on your module supports fast-counter mode on the input you have chosen.

Can the totalizer survive a power cycle?

Yes. Open the Up/Down Counter block in LOGO!Soft Comfort, switch to the parameter tab, and tick Retentive for the Cnt value. The count is then stored in non-volatile memory and restored on the next power-up.

How do I show two magnitudes and a configurable K-factor on the LOGO! display?

Use three message texts. The first shows live pulse count and computed volume in liters. The second puts the K-factor (pulses per liter) in operator-editable mode. The third is the reset confirmation. Set parameter protection to Operator so the K-factor can be changed from the LOGO! TDE keypad without a program download.

Back to blog