IMDHMIControls LibraryShop main store

How-to

How to configure and scale analog inputs on a Modicon M340

Controllers and I/O Published 7 min read

Short answer

Configure the channel's electrical range and user range in the module configuration first; the program then reads the channel as %IW rack.slot.channel and scales with one linear formula against the configured count endpoints. A 0-10 V channel configured 0-10000 counts reads 5000 at 5 V. The converter's 16-bit resolution never enters the arithmetic.

On this page
  1. Configure the channel before you write code
  2. The address is %IW rack.slot.channel
  3. Scale configured counts, not the converter resolution
  4. Test the logic before the module arrives
  5. Wiring decisions the scaling depends on
  6. Commission on three points
  7. The decision for each case
  8. Questions asked

Configure the module first; the code is the easy part. In Unity Pro (now EcoStruxure Control Expert) you declare the analog module in the rack, set each channel's electrical range, and set the user range that fixes how many counts the channel reports. The program reads the channel as %IW rack.slot.channel and applies one linear formula. A 0-10 V channel with a user range of 0-10000 counts reads 5000 at 5 V — the converter's 16-bit resolution never enters your arithmetic. This guide walks the whole path: configuration, addressing, scaling with the arithmetic shown, simulation when you have no module yet, and the transmitter wiring decisions that decide whether the numbers mean anything. If you came from Allen-Bradley, the ladder transfers; the project structure is the real jump, and reworking Modicon M340 logic as an Allen-Bradley programmer covers that side.

Configure the channel before you write code #

Analog I/O on the M340 is configuration-driven: the module decides what the %IW word contains before any logic runs. Work in this order:

  1. List every signal by channel: voltage, 4-20 mA current, Pt100, PTC or NTC. Get each device's output from its datasheet, not from the tag name.
  2. Pick the module against that list. The BMX AMI 0410 is the four-channel, high-speed analog input module; the BMXAMI0410H is its current-loop version, and the BMX AMO 0410 is the matching output module. Check each module's instruction sheet for the ranges it actually supports per channel.
  3. Insert the module in the project at the slot it occupies in the physical rack. An M340 processor such as the BMXP342020 addresses up to 256 analog I/O points (and 1024 discrete), so channel count is rarely your constraint — matching the configured layout to the real rack is.
  4. Open the channel configuration and set the electrical range for each channel: 0-10 V, 4-20 mA, or the temperature input type.
  5. Set the user range — the User scale — to min = 0 and max = 10000 counts. You can accept a default scale instead; whatever you choose, those endpoints become the CountMin and CountMax of your formula.
  6. Confirm the configuration so the channel addresses exist in the project.

If the range a sensor needs is not on the module's list, change the hardware or add a signal conditioner — software cannot stretch a channel past what it measures.

The address is %IW rack.slot.channel #

For the 0410-series modules, an analog input channel maps to %IW rack.slot.channel and an output to %QW rack.slot.channel. Two example layouts:

Rack layout First analog input First analog output First digital input
AI in slot 4, AQ in slot 5 %IW0.4.0 %QW0.5.0 —
DI in slot 1, AI in slot 3, AQ in slot 4 %IW0.3.0 %QW0.4.0 %I0.1.0

The address is positional: %IW0.4.0 means rack 0, slot 4, channel 0. Read the address out of your own project configuration — an address copied from an example points at whatever sits in that slot in your rack. Pick one layout and keep it for the whole project.

Scale configured counts, not the converter resolution #

A 16-bit converter sets the hardware resolution, not the numbers in your program: the user range you configured defines the count endpoints, and those are the only numbers in the formula.

Engineering value = EngMin + (count − CountMin) × (EngMax − EngMin) ÷ (CountMax − CountMin), with the count span non-zero.

In structured text:

rWeight : REAL := 0.0;  (* illustrative application variable *)
rWeight := INT_TO_REAL(%IW0.3.0) * 1000.0 / 10000.0;

Worked example A: 0-10 V as 0-1000 kg #

Channel range 0-10 V, user range 0-10000 counts, representing 0-1000 kg.

  • At 5 V the channel reads 5000 counts: 0 kg + (5000 − 0) × (1000 kg − 0 kg) ÷ (10000 − 0) = 5,000,000 ÷ 10,000 = 500 kg.
  • Endpoints: 0 V → 0 counts → 0 kg; 10 V → 10000 counts → 1000 kg.
  • Test: with %IW0.3.0 forced to 5000, rWeight evaluates to 500.0.

The quick integer form %MW0 := %IW0.3.0 / 10 that appears in many M340 examples gives the same result at 5 V but truncates: with this span the error stays under 1 kg, fine for whole kilograms, wrong for fractional units. Use REAL arithmetic when fractions matter.

The general method is converting 0-10000 counts to engineering units. The same endpoint method is what you follow when fixing 4-20 mA scaling on a Quantum AVI030 analog input on the larger Modicon platform.

Worked example B: 4-20 mA as 0-10 bar #

Configure the channel for the current range with the same 0-10000 user range, so 4 mA = 0 counts, 12 mA = 5000 counts and the full-scale loop current = 10000 counts. A 0-10 bar transmitter at 12 mA gives: 0 bar + (5000 − 0) × (10 bar − 0 bar) ÷ (10000 − 0) = 5.0 bar.

A broken loop sits at 0 mA, below the configured range. The module's channel diagnostics exist for exactly that condition: read them and treat the signal as invalid, not as a zero process value — the pattern in detect a failed analog input channel and report it to SCADA.

Test the logic before the module arrives #

You can develop without hardware. Build the project with the module declared, switch to simulation mode, and write the input image directly: Unity Pro provides the Write _Input_Int block for forcing an analog input word, documented in Schneider's FAQ on simulating analog inputs. Write 0, 5000 and 10000 to %IW0.3.0 and watch the computed values land on 0, 500 and 1000.

Commit to what this proves: the simulator verifies addressing and arithmetic only. Loop power, wiring, terminal assignment and the real channel configuration are proven at commissioning, on hardware, with the three-point check below.

Wiring decisions the scaling depends on #

The numbers mean nothing until the electrical interface is right. Decide per channel:

Signal Decision Commissioning check
0-10 V Channel must support the range; mind polarity and common reference Measure terminal voltage, compare with online count
Current loop, two-wire Loop-powered: supply and signal share the two conductors; the channel or an external supply feeds the loop Measure loop current at known process points
Current loop, four-wire Separately powered; confirm whether its output is active or passive before connecting Never put two powered sources in one loop
Pt100 Module must document RTD support and the 2-, 3- or 4-wire scheme Compare displayed temperature with a reference
PTC / NTC Module must document the characteristic; otherwise fit a conditioner with a current output Check resistance against the sensor curve

A channel configured for current cannot measure resistance, and selecting a temperature label in software does not add that capability — for PTC or NTC on a module that does not list them, the conditioner path is the answer.

One safety note: isolate the machine and the loop supply before opening transmitter terminals; analog loops often share a cabinet with much higher-energy circuits.

Commission on three points #

Hold the process at three known conditions and confirm all three numbers agree at each:

  1. Measure at the terminals with a meter — voltage or loop current.
  2. Read the online %IW word against the configured count.
  3. Read the computed engineering value.

Accept the channel when 5.00 V measured → 5000 counts read → 500.0 kg displayed, and the same agreement holds at zero and full scale. A channel that agrees at mid-scale but not at the ends has the wrong endpoints — go back to the user range, not the sensor.

The decision for each case #

  • No module in hand yet: build and prove the logic in simulation with Write _Input_Int; commission later on hardware with the three-point check.
  • Needed range absent from the module: change the module or add a signal conditioner; never absorb the gap in the scaling arithmetic.
  • Whole units sufficient: the integer divide by 10 is acceptable (error under 1 kg in this span); fractional units: use REAL.
  • Two-wire transmitter: power the loop from the channel or a dedicated supply per the documentation; four-wire: separate supply, verified active or passive output. Swapping two-wire for four-wire keeps the scaling while the channel still sees the same loop current over the same range.
  • PTC or NTC without documented module support: conditioner with a current output, then the same linear formula.
  • Counts outside the configured range: channel fault — diagnose and report it, do not publish a process value.

Questions asked

Can I test the M340 analog scaling before the module arrives?

Yes. Run the project in simulation mode and write the input image with the Write _Input_Int block that Unity Pro provides for forcing analog inputs. Write 0, 5000 and 10000 to the input word and check the computed 0, 500 and 1000, and hold a mid-range value while you test alarm thresholds. The simulator proves addressing and arithmetic only; wiring, loop power and the real channel still need the online three-point check at commissioning.

We are replacing a two-wire level transmitter with a four-wire one. Does the M340 program change?

No, as long as the new transmitter outputs the same current over the same process range: the channel sees the same counts for the same level, so the scaling stands. What changes is electrical: the four-wire unit takes its own supply, so confirm whether its output is active or passive, wire power and signal separately, and do not let two powered sources share one loop. Change the program only if the range or the engineering units change.

%IW0.3.0 stopped reading after I moved the module one slot. Why?

Because the address is positional: %IW rack.slot.channel. A module moved from slot 3 to slot 4 puts its first input at %IW0.4.0, and the old %IW0.3.0 now points at an unconfigured location or at whatever occupies slot 3. Update the rack configuration and every %IW reference after the move, then re-run the three-point check rather than trusting a word that once worked.

Can I read a PTC or NTC sensor on the same module as my 4-20 mA transmitters?

Only if the module's documentation lists that sensor characteristic for the channel. A current or voltage input measures milliamps or volts; a temperature selection in the configuration cannot add resistance measurement. Where the module does not support PTC or NTC, fit a signal conditioner that converts the sensor to a current signal and scale that channel with the same linear formula and a fresh set of endpoints.

Keep reading

  • How-to

    Scale MicroLogix analog inputs to Pascals over DF1 reads

    Stage the analog word into an N7 integer with a MOV and read that register over DF1; the driver does not serve the physical input word. Scale counts to volts linearly, apply the gauge exponent in one place, and check two injected points, because 10 mV of voltage error moves the reading 2 to 4 percent.

    Controllers and I/O

  • How-to

    Configure a CP1H high-speed counter for an encoder input

    The CP1H gives you four built-in high-speed counter inputs: single-phase counting to 100 kHz and differential-phase 4x counting to 50 kHz input frequency, with a 32-bit range in linear or ring mode. Wire the encoder's phase outputs to the counter input terminals, set the mode and range in CX-Programmer, and prove the count on a known rotation before you use it for control.

    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