Troubleshooting Analog Input Scaling and Halt Logic

Mark Townsend5 min read
Other ManufacturerSensor IntegrationTroubleshooting
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

The panel shows an out-of-range popup and the program stops as soon as the analog check executes. Start here: the input function returns amperes, while the limits 8 and 9 are milliampere values. A valid milliamp signal therefore looks one thousand times smaller to unscaled logic.

Stop trying the wrong fixes

Changing the thresholds, moving the halt, or repeatedly testing the sensor will not correct a unit mismatch. Separate the display problem from the stop condition before editing more logic.

Symptom Cause to check
The program halts immediately The current is in amperes but is compared directly with milliampere limits.
No popup appears before the stop The halt executes before the popup, or the popup is outside the active conditional path.
The displayed value is near 0.008 rather than 8 That is not the fault. The value is expressed in amperes.
The condition appears false, but execution still stops Trace the actual branch and check for another halt or unconditional fall-through.
The result changes near a limit Input noise or normal conversion variation is crossing a boundary with no filtering or persistence check.

Do not start by changing hardware. Read the raw value, calculate the scaled value, and observe the Boolean result first. Replacing a sensor or input channel wastes time when the program is comparing different units.

Find the unit mismatch

get_analog_in(0) returns the analog value in amperes. If the process limits are 8 mA and 9 mA, comparing the raw result directly with those numbers makes the lower-limit test true for normal milliamp-level currents.

For example, 8 mA equals 0.008 A. The raw comparison 0.008 < 8 is true because the program interprets both numbers as plain numeric values; it does not infer that one represents amperes and the other represents milliamperes.

Use one unit throughout the comparison:

  • Convert the measured amperes to milliamperes: mA = A × 1000.
  • Or express both limits in amperes: 0.008 A and 0.009 A.

The first method usually makes troubleshooting easier because the variable and limits match the units engineers expect to see on the panel.

Check the actual execution path

A unit correction explains an immediate out-of-range decision, but it does not prove which halt instruction ran. If the displayed condition appears false, inspect program flow before altering the limits.

  1. Display or log the raw result from get_analog_in(0).
  2. Display the calculated Analog_in_mA value.
  3. Display the results of the lower and upper comparisons separately.
  4. Confirm the popup and halt are both inside the same conditional block.
  5. Search the active routine for any other halt that can execute during the same cycle.

The out-of-range expression uses OR logic:

(Analog_in_mA < 8) or (Analog_in_mA > 9)

That expression stops the program below 8 mA or above 9 mA. Values equal to either boundary are accepted because the operators are < and >, not inclusive comparisons.

Apply the working sequence

Scale once, test the scaled variable, issue the message, and then halt. Keep the diagnostic action before the stop instruction so the operator can see why execution ended.

Analog_in_mA = 1000 * get_analog_in(0)
if (Analog_in_mA < 8) or (Analog_in_mA > 9):
    popup message
    halt
end
  1. Read channel 0 with get_analog_in(0).
  2. Multiply the returned ampere value by 1000.
  3. Store the result in Analog_in_mA so its unit is explicit.
  4. Compare that variable with the 8 mA lower limit and 9 mA upper limit.
  5. Execute the popup while the program is still running.
  6. Execute the halt immediately afterward in the same branch.

Do not scale the input more than once. If another routine already converts the value to milliamperes, multiplying it again produces a value one thousand times too large.

Verify all three decision regions

Test below, inside, and above the permitted band. Watch the raw input, scaled input, comparison results, popup, and program state during each test.

  • Below 8 mA: the lower comparison must become true, the popup must appear, and the halt must follow.
  • From 8 through 9 mA: neither comparison should be true, and execution should continue.
  • Above 9 mA: the upper comparison must become true, followed by the popup and halt.

Test the exact boundary values as well. With the shown operators, exactly 8 mA and exactly 9 mA remain valid. If the intended policy excludes either endpoint, change the applicable operator deliberately and repeat the boundary tests.

When the input is stable but the scaled value is wrong, compare the panel reading with an independent current measurement and the controller’s channel configuration. Confirm that the program reads the intended channel and that the configured signal mode matches the connected transmitter.

Prevent repeat halts and nuisance trips

Name variables with their engineering units. Analog_in_mA is safer than a generic analog variable because later edits can preserve the unit contract.

A real input may fluctuate near a threshold. If the process can legitimately sit near 8 or 9 mA, decide whether the machine requires an immediate trip, hysteresis, filtering, or an out-of-range persistence check. Read any filter or timing value from the application requirements and controller documentation; do not guess it.

Keep diagnostic messages specific enough to distinguish low current, high current, and program-flow faults. A generic halt message hides whether the raw signal, scaling calculation, or comparison caused the stop.

FAQ

Why does the analog input halt the program immediately?

get_analog_in(0) returns amperes. Comparing a value such as 0.008 A directly with a lower limit of 8 makes the lower-limit expression true; multiply the input by 1000 before using milliampere limits.

Why does the controller show 0.008 instead of 8 mA?

The displayed value is in amperes: 0.008 A equals 8 mA. Store 1000 * get_analog_in(0) in Analog_in_mA when the limits and operator display use milliamperes.

Why does the program halt without showing the popup?

Place the popup before the halt and keep both instructions inside the out-of-range branch. If the popup still does not appear, trace the branch results and search for another halt on the active execution path.

When should I stop troubleshooting and contact official support?

Escalate when the observed raw value disagrees with an independent current measurement, the configured channel cannot be verified, or execution halts with every conditional result false. Record the raw and scaled values, channel configuration, active program path, and a minimal reproducing routine before contacting the controller manufacturer through its official support channel.

Back to blog