IMDHMIControls LibraryShop main store

How-to

Scaling a PLC-5 FLEX analog output from PID 0-4095 to 0-30840

PLC programming Published 7 min read

Short answer

A PLC-5 PID drives its control variable from 0 to 4095, while a FLEX analog output channel configured for the current loop expects output data from 0 to 30840, so a raw CV gives 6.125 mA at 100 percent. Leave the PID limits at 0 and 100 percent, scale the control variable times 30840 divided by 4095 into a separate integer word, and point the BTW at that word. The CV word and the BTW data word must be different addresses.

On this page
  1. Two count scales: the PID and the module
  2. Set the PID limits back to percent
  3. Worked example: CV 4095 into the FLEX current channel
  4. Rung by rung
  5. Keep the PV conversion out of the output path
  6. If the scaled word is right and the meter is still wrong
  7. Questions asked

Your PID reads 100 percent, the output word carries 4095, and the FLEX output terminal measures about 6.125 mA. The PLC-5 PID and the 1794 FLEX 4-20 mA output channel are running on two different count scales, and no configuration bit in the module fixes that: you convert between them in ladder. Leave the PID's output limits at 0 and 100 percent, add one scaling rung after the PID that multiplies the control variable by the module's full-scale count and divides by the PID's own span, and point the BTW at that scaled word. One rule does the most damage when missed: the PID's CV word and the BTW's output data word must be different addresses, because both instructions write their words every scan.

Two count scales: the PID and the module #

A PLC-5 PID drives its control variable across 0-4095 between 0 and 100 percent output, the 12-bit scale the older 1771 analog family used, which is why the CV word read exactly that value at a 100 percent display. The 1794-IE4XOE2's current-loop output channel has a different data format. The FLEX I/O analog modules user manual (publication 1794-UM002) defines 30840 counts as full scale for that range, 7878 hex in its data-format table on page C-2, and the same manual includes a PLC-5 family sample program for this module showing the block-transfer structure around it.

A raw word at the PID's full scale is therefore about 13 percent of the module's span, and the channel drives 6.125 mA. The channel's configuration bits are not wrong at that point; the number handed to it is on the wrong scale. Two notes that save time: the PID's input-range fields scale the process variable only, so the maximum entered there belongs to the PV path and does not move the CV span, and the count-to-current behavior itself is the ordinary analog output conversion covered in how PLC analog input and output modules convert signals.

Set the PID limits back to percent #

The attempted fix on the reported machine raised the output high limit to 753.112 percent. That number is the module-to-PID ratio wearing a percent sign, and it did drive the output word to full scale, but the status display showed output limiting: high. With the limit sitting at 753 percent, the loop spends normal operation pinned at its own ceiling: a setpoint change that calls for less output cannot pull the word down, which is exactly the setpoint-has-no-effect symptom that was reported.

Decision: put the high limit back to 100 and the low limit to 0, and never move a PID limit to absorb a module's data format. Limits belong in percent; the conversion belongs in a rung after the PID, where you can trend it, force it and bypass it.

Worked example: CV 4095 into the FLEX current channel #

Inputs, and where each comes from:

  • CV at 100 percent: 4095 counts, the value the reported program's CV word held when the PID display read 100 percent.
  • Output-data span: 0-30840 counts for the configured current range, from the 1794-UM002 data-format table.
  • Current mapping for that range: 0 counts gives the 4 mA live zero and 30840 counts gives 20 mA, so output current = 4 mA + (raw word / 30840) * 16 mA.

Rule in words: current equals the live zero plus the raw word's fraction of the module span times the 16 mA span width; the conversion the PID needs is CV times the module span divided by the PID span.

The word as the machine wrote it, the reported symptom: 4095 / 30840 = 0.1328; 0.1328 * 16 mA = 2.125 mA; 4 mA + 2.125 mA = 6.125 mA.

The word it should carry, the fix: 4095 * 30840 = 126,289,800; 126,289,800 / 4095 = 30840; 4 mA + (30840 / 30840) * 16 mA = 20 mA.

Mid-span check: a CV of 2048 scales to 2048 * 30840 / 4095 = 15,423.8, stored as 15,423 in the integer destination, and 4 mA + (15,423 / 30840) * 16 mA = 12.0 mA. The conversion factor is 30840 / 4095 = 7.5311.

Decision: judge the scaling by the BTW word, and at 100 percent output it must read the module's full-scale count. If it still reads 4095, the scaling rung is missing or aimed at the wrong word; if the word is right but the meter disagrees, the fault is downstream of the arithmetic.

Rung by rung #

  1. Set the PID's output high limit back to 100 and the low limit to 0. Leave the input-range fields as they are; they belong to the PV path.
  2. Find the control-variable address in your PID instruction and leave that word owned by the PID. The reported program used control block PD22:7, process variable N29:2 and control variable N29:20; those are that machine's addresses, not a standard layout.
  3. Add one CPT rung after the PID, with a fresh integer destination, for example N29:21, the word after the reported CV, and the expression N29:20 * 30840 / 4095. Keep the multiply ahead of the divide: the order of a scaling computation decides which decimals survive, the trap behind lost decimals in ControlLogix scaling blocks, for which CPT fix for scaling blocks that lose decimal places is written up separately. An integer destination drops the fraction, an error of less than one count.
  4. Point the BTW's data file at the scaled word, never at the CV word. The BTR/BTW pair moves the module's whole data image as one block, and how PLC-5 BTR and BTW block transfers work covers that mechanics. Data returned by the BTR is the module's input image, so never aim the scaling destination at an input word.
  5. Check scan order: the CPT must run before the BTW rung, and nothing later in the scan may MOV over the scaled word or the module's output image.
  6. Force-test before you close the loop: put it in manual and park the actuator in a safe state first, because a forced full-scale output on a live valve is a process move, not a bench test. Then confirm the worked example's checkpoints: zero CV gives a zero word and the live-zero current, mid-span CV gives about half, and a full-scale CV gives the full-scale word and the module's full-scale current at the terminals.

Keep the PV conversion out of the output path #

The PID runs two conversions, and they answer different questions. The PV path turns transmitter counts into process units such as pressure or temperature and feeds the input-range fields. The CV path turns the loop's percent demand into module counts. The alternate fix tried on the reported machine, a CPT into N7:49 built from the pressure transmitter's configured endpoints, entered there as 362.4 and 14.4, with the PID's process variable re-aimed at that word, is a PV conversion. It produced a working loop, but it changed the PV the PID sees and forced a rework of the HMI tags that displayed the value, all to solve a problem one CV rung solves without touching anything else.

Keep your PV scaling as it is; scaling MicroLogix analog inputs to Pascals over DF1 reads walks that side of the house on another controller family. Add exactly one new conversion: CV to module counts. And check for duplicates first, because if the CV is already multiplied somewhere upstream, two scalings stack and the channel receives a nonsense word.

If the scaled word is right and the meter is still wrong #

Once the BTW word tracks the CV times the conversion factor and the measured current still disagrees, the arithmetic is finished; walk downstream in order. First, channel configuration: the reported machine had its configuration bits set correctly for the current range in both directions, and its two working input channels already proved the module, the adapter and the block transfers were alive. Second, word position: the scaled value must land in the exact word of the BTW data file that this channel reads, because one word off writes the neighboring channel instead. Third, the field circuit: loop power, polarity, the meter itself. Trend the CV, the scaled word, the BTW data and the measured current in one view; the first point where the numbers stop matching is where the fault lives.

On the reported machine none of this was needed. Inputs and transfers were healthy and the configuration was correct; the missing piece was the CV-to-counts conversion with the limits back at percent, the fix in the worked example above.

Questions asked

Where did the 753.112 percent output limit come from?

It is the module-to-PID ratio expressed in percent: 7.5311 x 100 gives 753.11, so a high limit of 753.112 forces the control-variable word to the module's full-scale count and the channel to full-scale current. The status display then shows output limiting high, the loop rides its own ceiling, and a setpoint change cannot move the output until the unsaturated demand falls back below the limit. Limits belong at 0 and 100 percent, and the range conversion belongs in a rung after the PID.

Will the scaled value fit in a PLC-5 integer word?

Yes. An N-file word holds a signed 16-bit integer from -32768 to 32767, and the module's full-scale output data sits inside that span, so a plain integer destination works. The intermediate does not: the multiply alone peaks at 126,289,800, so never split the math into a multiply rung that stores a 16-bit result before the divide. Compute the whole expression in one CPT, or use a floating-point destination and round once, so the intermediate value never lands in an integer word.

Is multiplying the control variable by 7.53 close enough?

The exact factor is 7.5311, and 7.53 lands about five counts short at 100 percent, roughly 0.003 mA on the 16 mA span, which most valves will never notice. Even so, write the rung as CV times the module's span divided by the PID's span and let the processor do the division, so the endpoints land exactly and nobody maintains a rounded constant. Keep the shortcut for desk checks and the exact expression in the program.

Do the loop tuning or the HMI need changes after adding the scaling rung?

No. The PID still computes its control variable on its own internal span, so gains, reset time and the PV conversion behave exactly as before; the new rung only maps the finished demand into module counts, downstream of the loop. The display side is untouched too, because neither the CV address nor the PV address moves. If the process response changes after the edit, suspect a second, forgotten scaling of the same word before you touch tuning.

Keep reading

  • How-to

    Set up a CLICK PLC 4-20 mA pressure trip with a relay output

    Wire the two-wire loop into channel 1 of a C0-04AD-1, set that channel to 4-20 mA with 4 mA scaled to 0 PSI and 20 mA to 300 PSI in DF1, and drive relay output Y1 from Set and Rst coils that trip above 250 PSI and release below 230 PSI, with a loop-fault test below -10 PSI.

    PLC programming

  • How-to

    S7-300 PID control for a modulating burner motor

    Run one FB41 CONT_C loop on the hottest hood's PT100, scale all five probes to °C, and turn the 0-100% output into open/close pulses that follow the M941B's 0-10 V pot feedback to a 2% deadband, through 24 VAC interposing relays. The gas management system keeps the burner start sequence and its permissives; the PID never touches them.

    PLC programming

  • Troubleshooting

    Why an S7-1200 analog output reads 3 mA at any command

    A 0-20 mA output that reads 3 mA at every command is not scaling wrong — the meter and the drive are in the circuit incorrectly, or the output stage has lost its 24 V DC supply. Confirm the channel is set to current mode and 20.4-28.8 V DC at L+, then command 0 and 27000 from a watch table with the drive disconnected and the meter in series. A healthy channel tracks both writes; a flat reading with the supply verified means a failed output stage.

    PLC programming