How-to
S7-200 analog output: one pulse adds 3200 counts per volt
Short answer
An S7-200 analog output word runs 0 to 32000 counts over 0 to 10 V, so one volt, one pulse, is 3200 counts. Keep a step counter clamped 0 to 10, move it by one on each detected edge of the increase or decrease input, multiply by the step size and write the result to the AQ word every scan. Verify each level with a meter; a held or bouncing input must count exactly once.

On this page
On an S7-200 analog output channel the word runs 0 to 32000 counts across 0 to 10 V, so the 1 V step the machine asks for is 3200 counts: keep a step counter clamped between 0 and 10, add one on each detected edge of the increase input, subtract one on each edge of the decrease input, multiply by the step size and write the result to the AQ word every scan. The two failures to design out are a held or bouncing input counting more than once per press, and a counter that wanders past its limits. Below: the rule, the logic in order, one worked example and the meter check that proves it.
The count-per-volt rule #
The channel takes a 16-bit word: 0 counts commands 0 V, and 32000 counts commands the top of the voltage range, the data-word format the S7-200 system manual gives for the analog outputs. One tenth of that span is one volt, so the step size is 3200 counts and ten steps cover the whole command. A step is a jump, not a ramp: each accepted edge rewrites the word once and the channel settles at the new level. Everything else in the program exists to make one press equal exactly one step.
Program the pulse-to-step logic #
The whole job is six decisions, in this order.
-
Declare the counter and the command word.
StepCountis a 16-bit signed integer, initial value 0, allowed 0 through 10.AqCmdis the same type, initial value 0, and holds what the channel receives. The full-scale product fits that type with room to spare, so no double word is needed. -
Edge-detect both inputs. Generate one rising-edge event per press per input. A counter fed from the raw input level increments every scan the button is held, which turns one press into a run to the limit, the classic failure on this circuit.
-
Gate the increment and the decrement. On an up edge, add one only while the count is below ten; on a down edge, subtract one only while it is above zero. At either limit an edge changes nothing. A count up/down counter instruction works here, and so do plain add and subtract rungs; what matters is that the edge bit, not the input level, drives it.
-
Fix the same-scan rule. If an up edge and a down edge land in one scan, leave the count unchanged, because the moves cancel, and write that rule where the next technician will find it.
-
Suppress contact bounce before the edge detector sees it. A mechanical pushbutton makes several transitions per press and each one is an edge. Set the CPU's digital input filter, the per-input delay in the controller configuration, to cover the contact's bounce time, chosen from the device rather than an arbitrary long delay that would merge quick legitimate pulses. Watch the status display: one press must produce one edge.
-
Scale and write every scan. Multiply the clamped counter by the step size and write the product to the AQ word unconditionally each scan, so the word can never go stale after an edge. The names here are mine; use your own addresses.
// illustrative names for this example, not vendor identifiers
StepCount : Int := 0; // pulses held, clamped 0..10
AqCmd : Int := 0; // value for the channel's AQ word
// every scan, after the edge logic has updated StepCount:
AqCmd := StepCount * 3200; // ten steps give the full-scale word
If the machine needs fixed levels instead of steps, outputting 8 mA and 4 mA from an S7-200 EM232 output with MOV_W covers writing set values with a move instruction. One commissioning check belongs with the steps: the driven device sees a full one-volt jump at every level, so confirm the machine tolerates that jump before handover.
Worked example: ten up pulses, then one down pulse, on the pulse-stepped channel #
Inputs, and where each comes from
- Command span and step: 0-10 V, moved one step per pulse on each input, the requirement in the case you brought.
- Word format: the analog output data word stated above, from the S7-200 system manual.
- Presses: ten single up pulses from the bottom, then one down pulse, an illustrative walk, since the case fixes the step, not the number of presses.
Rule in words. The command in counts equals the pulses held, the clamped counter, times the step size, and the step size is the full-scale word divided by the full-scale volts.
Arithmetic.
- Step size: 32000 counts ÷ 10 V = 3200 counts per step.
- After ten up pulses: 10 steps × 3200 counts per step = 32000 counts written.
- After one down pulse: the counter sits at 9, so 9 × the step size = 28800 counts written, one step below the top.
Result. The status display shows the word climb to full scale and drop one step; a meter on the channel terminals reads about 10 V after the tenth up pulse and about 9 V after the down pulse.
Decision. The counter's ceiling is ten steps: an eleventh up edge must leave the word untouched, and any count outside 0 through 10 is a fault to trap, because its scaled command leaves the range you just verified.
Prove it with a meter #
Program state proves intent; the meter proves the channel. Run this sequence at commissioning and after any module or wiring change.
-
With the counter at 0, meter about 0 V at the channel terminals.
-
Feed ten single up pulses, metering after each: the level rises one step per pulse, the status display shows the word moving by exactly the step size each time, and the tenth lands at full scale.
-
Hold each button for a few seconds: the level changes once and then holds, once per press, never once per scan.
-
Pulse back down to the bottom; there, further down edges change nothing.
-
If a level is off, isolate in order: the channel's configured range, the output address written versus the terminals metered, and what the channel is driving. The isolation sequence in testing PLC analog output scaling in three layers applies unchanged.
Questions asked
What happens if the counter runs past ten steps?
Eleven steps scale to 35200 counts, past the 32767 ceiling of a 16-bit signed word, so the multiply overflows: the CPU sets its overflow flag and the word that reaches the channel is no longer the level you chose. It can go negative and the channel falls to the bottom of the range instead of holding the top. That is why the increment is gated at ten and the decrement at zero, and a count outside those limits is worth trapping as a program fault.
How fast can the pulses arrive and still be counted?
A pulse must stay on longer than the input filter plus one scan, and stay off about as long before the next arrives, or the edge detector never sees it. For example, with a 10 ms filter and a 10 ms scan, keep pulses at least 20 ms wide and 20 ms apart. Hand presses are far slower than that; a sensor feeding the same inputs may not be, and then the filter setting, not the counter, sets the pulse-rate limit.
Does the output ramp between the levels?
No. Each accepted edge rewrites the word once, so the channel jumps a full step and a drive speed reference moves in one-volt bumps. If the machine cannot take the jump, generate the intermediate levels in the program: a timed ramp that advances the command by a smaller increment every interval until it reaches the target step, still clamped inside the verified range.
Can each pulse move a smaller step?
Yes, the method is unchanged, only the step size. Halve it to 1600 counts and widen the clamped counter to 0 through 20, and each pulse moves the command 0.5 V while twenty pulses still reach full scale. Any step that divides the word evenly works the same way; one that does not leaves the last pulse short of the top.

