IMDHMIControls LibraryShop main store

How-to

Output 8 mA and 4 mA from an S7-200 EM232 output with MOV_W

Controllers and I/O Published 6 min read By IMDHMI controls team

Short answer

On the EM232 current output, 0 to 20 mA maps onto a 0 to 32000 data word, so the 8 mA run command is MOV_W 12800 to AQW0 and the 4 mA stop command is MOV_W 6400. Hold one sequence state that I0.0 sets and I0.1 clears, drive the motor from that state, and let it pick which word is written so two sensors never fight over the output.

On this page
  1. What the EM232 current output expects
  2. One sequence state instead of two sensor-driven rungs
  3. Worked example: calculating the run and stop words for AQW0
  4. Programming the sequence in MicroWin
  5. Commissioning checks
  6. Pitfalls that give the wrong loop current
  7. Questions asked

Your two commands are MOV_W 12800 to AQW0 for the 8 mA run command and MOV_W 6400 for the 4 mA stop command. The EM232 converts a raw word into loop current, not milliamperes, so the milliampere values must be turned into counts before the PLC writes anything. Around those two writes you need one sequence state: I0.0 starts the motor at the run current, I0.1 stops it at the stop current, and the state, not the sensors, decides which word goes out each scan. Wired that way, two photoelectric sensors high at once cannot fight over the output. Below: the module's mapping, the arithmetic for both words, the MicroWin rung order, and the checks that prove the loop.

What the EM232 current output expects #

The module never sees milliamperes. Your program writes a 16-bit word to an analog output address and the EM232 converts it to current on its own terms. For the current output, the S7-200 system manual's analog expansion module specifications list a signal range of 0 to 20 mA with a unipolar data word of 0 to 32000: zero counts commands zero current, the top word commands full scale, and the line between them is straight. Unipolar means the word never goes negative.

The module's other range, ±10 V across -32000 to +32000, is the bipolar voltage mapping; calculating a current command on it gives the wrong loop current. Current or voltage is decided at the terminals, not in the arithmetic: wire the positioner loop to the current output. AQW0 is the EM232's output word when it is the first analog expansion module on the CPU 224; an analog module mounted ahead of it shifts the address, so confirm the word against your expansion layout before you download.

One sequence state instead of two sensor-driven rungs #

What you described is a two-state sequence, not two independent output conditions. In the run state the motor is on and the positioner gets the run current; the idle state holds the motor off at the stop current until the next start. If you hang one MOV_W on each sensor, both inputs high in the same scan means two writes to one word, and the write executed last wins. The positioner then follows rung order, not machine state. That is the same trap behind why a pick-and-place rung needs sequence state, not one condition: the logic must react to the step the machine is in, not to one input's level.

Hold one state bit that remembers the step: I0.0 sets it, I0.1 clears it, and the state drives both Q0.0 and the analog write. Drive the motor from the state, never straight from I0.0, or it drops out the moment the start sensor clears.

State Entered when Motor Q0.0 Word to AQW0
Run I0.0 high on the run word
Idle I0.1 high, held until the next start off the stop word

Commit to stop priority: with both sensors high, I0.1 wins. That is the deterministic default for a machine with a motor in motion; reverse the priority only if the risk assessment says the start must win, and then swap the rung order deliberately.

Worked example: calculating the run and stop words for AQW0 #

Inputs, each with its source:

  • Run command: 8 mA, the current your sequence sends while the motor runs, from your machine description.
  • Stop command: 4 mA, the idle-state current held until the next start, from the same description.
  • Module mapping: 0 to 20 mA over a data word of 0 to 32000, linear through zero, from the EM232 current-output row of the S7-200 system manual's analog expansion specifications.
  • Destination: AQW0, the first output word, confirmed against the CPU 224 expansion layout.

The rule in words: the word for a commanded current is that current divided by the full-scale current, times the full-scale word. One straight line through zero means the counts-per-milliampere slope is constant.

Arithmetic:

  • Slope: 32000 ÷ 20 mA = 1600 counts per mA.
  • Run word: 8 mA × 1600 counts per mA = 12800.
  • Stop word: 4 mA × 1600 counts per mA = 6400.

Result: 12800 in the run state, 6400 in the idle state, both exact with no rounding.

Decision: program those two words and accept the loop only when a series milliamp meter reads each state close to nominal at commissioning. An error of 1 mA or more points at the word, the address or the wiring, not at module tolerance, so fix that first; trim only smaller residuals, at the slope above, and never by rescaling the range. Two fixed words need no scaling library. When a command must sweep the range continuously instead, convert the engineering value the way you scale a PID real output to analog output counts.

Programming the sequence in MicroWin #

Numbered by rung order, which is also scan order:

  1. Confirm the EM232's output word, AQW0 for the first analog expansion module, against the CPU 224 layout, and wire the positioner to the current output terminals.
  2. Pick a free memory bit as the run state (for example M0.0). If the sequence must survive a power cycle, place that bit in a retentive range in the CPU's memory configuration.
  3. Set rung: a normally-open I0.0 contact sets the run state.
  4. Reset rung: a normally-open I0.1 contact resets the run state. Place this rung after the set rung; when both inputs are true the later reset wins, which is your stop priority. A set-and-reset pair with a defined winner is the same pattern you use to latch two level inputs for pump start and stop control.
  5. Motor rung: a normally-open run-state contact drives Q0.0.
  6. Analog rungs: the run-state contact executes MOV_W with the run word as source and AQW0 as destination; a normally-closed run-state contact executes MOV_W with the stop word to the same address. The pair is mutually exclusive, so exactly one word is written per scan.

In scan form, with the state bit declared:

// illustrative logic, not MicroWin entry format
RunState : BOOL := 0        // example state bit, e.g. M0.0
if I0.1 then  RunState := 0          // stop priority: wins when both are high
else if I0.0 then  RunState := 1
if RunState then
    MOV_W 12800 -> AQW0              // run word
    Q0.0 := 1
else
    MOV_W 6400 -> AQW0               // stop word
    Q0.0 := 0

The commissioning checks below are the test that proves this logic.

Commissioning checks #

Run these in order:

  1. Online in MicroWin, watch AQW0: the run word while running, the stop word at idle, never alternating between scans.
  2. Raise I0.0: Q0.0 energizes and the word jumps to the run value. Clear I0.0: Q0.0 stays on, because the state holds the motor, not the sensor.
  3. Raise I0.1: Q0.0 drops out and the word falls to the stop value, then holds.
  4. Put a milliamp meter in series with the positioner loop, on its mA range: read the run current and the stop current against nominal. A meter in parallel, or set to volts, proves nothing and can blow its fuse.
  5. With the machine guarded, raise both inputs together: I0.1 wins, the motor stays off, the stop word holds, and there is no scan-to-scan chatter.

Pitfalls that give the wrong loop current #

Mistake What you see Fix
Calculating on the bipolar voltage mapping current far from the command use the current range's own word mapping
Writing the milliampere value (8 or 4) as the word 8 ÷ 1600 counts per mA = 0.005 mA, effectively zero write the calculated words
Two unconditional MOV_W rungs on AQW0 the last write in the scan wins select one word from one state
Driving Q0.0 straight from I0.0 motor stops when the start sensor clears drive Q0.0 from the run state
Meter in parallel or on a voltage range no valid reading, maybe a blown fuse series connection, mA range
No rule for both sensors high the word follows input order program stop priority and test it
Scaling with 27648 as full scale, the S7-1200 word, on the EM232 current about 14% low use this module's full-scale word

Questions asked

Do I need a scaling library for these two currents?

No. A scaler converts a continuously changing engineering value into counts; your sequence needs two fixed constants, and MOV_W with a constant is clearer and cannot drift. Reach for scaling only if you later modulate the positioner across its whole span: then map the engineering zero to the stop word and full scale to 32000, which spans 4 to 20 mA on this module, and every intermediate current follows the same line.

Is AQW0 always the EM232 output address?

No. The CPU 224 assigns analog word addresses to the analog expansion modules in their mounted order, so an analog module ahead of the EM232 pushes its output word upward, and any further analog outputs on it take the next words in turn. Check the addressing table for your actual layout in MicroWin before downloading; writing the right constant to the wrong word looks exactly like a scaling fault.

The meter reads slightly low at the run word. Do I change the constant?

Not before the loop checks out. Put the meter in series on its mA range, confirm the positioner sits on the current terminal rather than the voltage terminal, and confirm which word the program actually writes. If a small residual remains after that, trim at 1600 counts per mA: a reading 0.4 mA low means adding 0.4 × 1600 = 640 counts to the run word. The calculated words are nominal commands, not calibrated outputs.

What if the positioner should see no current at stop?

Write 0 instead of the stop word in the idle branch, because zero counts is zero current on this mapping. Keep the rest unchanged: the state still drives Q0.0 and still selects exactly one word per scan. Choose the idle current from what the positioner needs, not from the program's convenience. A live-zero loop device treats its low current as a valid command, and many positioners flag a dead-zero loop as a fault.

Keep reading

  • Troubleshooting

    Troubleshooting non-linear 4-20 mA readings on an S7-1200 analog input

    A 4-20 mA loop is linear by construction, so counts swinging between 10 and 30246 mean the current at the terminal is not what the sensor LCD shows. On the SM 1231, 27648 counts is the top of the 4-20 mA range and 30246 decodes to 21.5 mA over-range fault current. Check the loop with a series meter, split sensor from module with a calibrator, and anchor NORM_X to 0 and 27648.

    Controllers and I/O

  • Troubleshooting

    Fixing 4-20 mA scaling on a Quantum AVI030 analog input

    On the Quantum AVI030 analog input, the raw range follows the channel resolution: 12-bit reports 0-4095 counts and 16-bit maps 4-20 mA to 6400-32000 counts. Neither 0-64000 nor a mismatched 0-4095 will scale or hold; set the block's raw limits to match the configured resolution and verify with 4, 12 and 20 mA test currents.

    Controllers and I/O

  • Troubleshooting

    Why a powered 4-20 mA output reads 32767 on an analog input

    A full-scale 32767 count on an input configured for a two-wire 4-20 mA transmitter usually means the source is an active output rather than a passive transmitter. Source and receiver electronics then fight over one loop, and the module never reports a valid measurement. Move the signal to the input's four-wire transmitter connection and the raw value tracks the measured current.

    Controllers and I/O