Troubleshooting
Why a CODESYS analog input stays at zero on one channel
Short answer
A CODESYS analog input stuck at zero on one channel while the other channels respond is a channel fault, not a scaling problem: no formula recovers a value that never arrives. Measure the voltage at the channel's terminals and reference, watch the mapped input word online with the scaling untouched, then move the same signal to a second channel to prove which part is dead.
On this page
- What should you measure before opening the CODESYS project?
- How do you watch the channel's raw value online?
- Is a raw zero a fault or just zero volts applied?
- Is the (10 / 65536) × raw formula correct?
- How do you prove the channel itself is dead?
- What do you change once the channel is confirmed dead?
- Questions asked
A CODESYS analog input that sits at zero on one channel while the other channels on the same module respond is a channel fault, not a scaling error: the raw value never arrives, so no formula can recover it. Measure the voltage at the channel's input terminals and its reference first, then watch the mapped word online with the scaling untouched, then move the same signal to a second channel. In the installation this article works through — a RevPi AIO expansion module on a Revolution Pi controller, one voltage input configured for 0 to 10 V and mapped to %IW36 — exactly that sequence found one dead channel among working ones.
What should you measure before opening the CODESYS project? #
Take three DC voltage readings with a meter: directly across the battery, between the channel's voltage-input terminal and its designated measurement reference, and between that module reference and the source's reference; the software range setting does not limit what the terminals accept.
A voltage input measures a potential difference between two specified connections. A signal wire that is live at the terminal converts to zero when the reference path is missing, and that looks exactly like a dead channel from inside the application. The module's wiring diagram names the reference terminal; a nearby ground terminal is not automatically interchangeable with it.
- Source voltage, across the battery: the value the source actually delivers, read before anything is connected to it.
- Channel voltage, input terminal to its designated reference: must equal the source voltage or the divided value your interface produces.
- Reference continuity, module reference back to the source reference: a missing or high-resistance bond here zeroes the reading while the signal wire stays live.
One safety note belongs here: selecting a 0 to 10 V range in CODESYS scales the reported number, it does not protect the input. A nominal 12 V battery rests near 12.6 V and rises higher on charge, above the top of the selected range, so connect it directly only within the module's documented maximum input voltage, and otherwise use the divider or measurement interface the documentation specifies.
A signal that is simply too small for the chosen range also converts to a reading of zero, which is a different fault with the same symptom — see why a millivolt sensor reads zero on a 0-10 V PLC input.
Decision for this step: voltage present at the terminals with a sound reference moves you to the online check; no voltage at the terminals means wiring, and no software change will help yet.
How do you watch the channel's raw value online? #
Log in online with the application in run, open the module's device configuration, find the channel's I/O mapping, and watch the variable or address it actually writes — in the installation here that was the input word %IW36, an address that belongs to that project, not to every module.
In IEC 61131-3 addressing, %IW is a 16-bit input word in the process image; the number after it comes from your own device mapping, so read it from the configuration instead of assuming it. Work through the checks in order:
- Confirm the application is running and the module shows no device or bus diagnostic fault; a module-wide fault would take every channel down, not one.
- Confirm the channel's process-data mapping points at the address or variable you are watching.
- Vary the applied voltage within the configured range and watch the raw value move with it.
If the mapped value changes while your displayed voltage stays zero, the fault is downstream in the calculation or display binding, not in the channel. If the mapped value stays at zero, display formatting is not the next useful check. A zero in an application variable proves nothing until you trace it back to the mapped input: it can be an unused address, a stale copy, or a value overwritten elsewhere in the logic.
Is a raw zero a fault or just zero volts applied? #
Zero is ambiguous, because a healthy channel with zero volts applied also reports zero; settle it by applying a known voltage inside the range — for example 5.0 V — and expecting a working channel to show roughly mid-scale in whatever unit it reports.
With the meter confirming that known voltage at the terminals, a raw value that stays exactly zero means no conversion result is arriving at all. Platforms differ in how they announce a dead input: on an S7-1200 a broken wire drives the value to 32767 instead of zero, as covered in why an S7-1200 analog input shows 32767 on wire break. A channel without such diagnostics simply imitates a legitimate zero, which is why the applied-voltage test, not the value alone, decides it.
Is the (10 / 65536) × raw formula correct? #
Only if the channel's documented process data is unsigned counts from 0 to 65535 spanning 0.0 to 10.0 V; the converter being 16 bits does not define what CODESYS receives, and in this case the question was moot because a dead channel delivers nothing to scale.
The device description, not the ADC's bit count, defines the delivered value: it may be raw counts, a signed representation, or an already scaled engineering value in volts. Read its units, data type, valid range and fault-value handling first. For a documented linear map, convert with the documented endpoints, called rawLow, rawHigh, Vlow and Vhigh here:
V = Vlow + (raw − rawLow) × (Vhigh − Vlow) / (rawHigh − rawLow)
Worked example with hypothetical endpoints, not this module's documented map: if the description gives counts 0 to 32767 for 0.0 to 10.0 V, then V = raw × 10.0 V / 32767. At raw = 16384: 16384 × 10.0 = 163840, and 163840 / 32767 = 5.000 V. The guessed constant gives 163840 / 65536 = 2.500 V for the same healthy count — wrong by half.
Decision: take the endpoints from the documentation, use a value that already arrives in volts directly, and trap any documented fault value before converting.
How do you prove the channel itself is dead? #
Swap the same signal onto another input with the identical configuration: a channel that responds while the suspect stays at zero, with the meter confirming the same voltage at both terminal pairs, proves a channel-specific fault.
Place the equipment in a safe condition before moving conductors, then keep the comparison controlled:
- Record the suspect channel's mode, range, mapped address, terminal voltage and live value.
- Wire the same source to another input and configure the identical measurement mode and range.
- Watch the second channel's own mapped value, and measure the voltage at its terminals too.
- Repeat the suspect-channel check once afterwards to rule out an intermittent connection.
| Observation | Decision |
|---|---|
| No voltage at either channel's terminals | Signal wiring or reference: fix that first; the software is innocent. |
| Correct voltage at both, neither raw value responds | Shared cause: module configuration, mapping, diagnostics, or a source outside the configured mode. |
| Second channel responds, suspect stays at zero | Channel-specific hardware fault, once its settings and terminals check out. |
| Both raw values respond, displayed voltage stays zero | Application arithmetic or display binding. |
The comparison isolates the fault faster than any sequence of software changes, and the recorded conditions keep a later wiring correction from being mistaken for a hardware recovery.
What do you change once the channel is confirmed dead? #
Change the hardware path, not the formula: return or replace the module through its vendor's process, or move the signal to a proven channel and update the mapping, and leave the conversion exactly as the documentation defines it.
Reinstalling the runtime, rebuilding the application, or repeatedly editing the conversion factor wastes an afternoon when one channel fails a controlled comparison. Re-map, verify the new channel with the same known voltage, and update every reference to the old address in the application. Because a dead channel imitates a legitimate zero, add channel fault detection so the next failure reports itself instead of quietly reading as a process value — the approach in detect a failed analog input channel and report it to SCADA applies directly.
Questions asked
Why can the (10 / 65536) formula return zero even on a healthy channel?
IEC languages divide two integers with integer arithmetic: 10 divided by 65536 truncates to 0 before the count is ever multiplied, so the expression yields zero even when the raw value is healthy; write both constants with decimal points, 10.0 and 65536.0, so the division runs as real arithmetic, or convert the count to REAL first. Prove it with a known mid-scale count: the result must land near half the span, not at zero.
Why does a broken wire read 32767 on other modules but zero on this one?
Modules with wire-break diagnostics replace the process value with an overrange code when the signal falls outside the measurable band; that substitution is documented behavior of those specific modules, not something CODESYS adds. A channel without such diagnostics delivers whatever its converter produces, so a dead channel imitates a perfectly legitimate zero, and only the known-voltage test with a meter tells the two apart.
How do you stop a dead channel from reading as a real zero in SCADA?
Separate instrument failure from a process zero with a plausibility check: a battery-voltage input that reports exactly zero while the machine is energized is not physical, so hold that condition for a delay you choose, for example 5 seconds, then raise a channel-fault alarm. Keep that alarm out of the process alarm list so an operator reads instrument failure, not a machine condition, and log the channel address with the event so the next failure is found quickly.
Does the module have spare channels for the moved signal?
The RevPi AIO provides 4 analog inputs, 2 analog outputs and 2 RTD channels, so one dead voltage input leaves three analog inputs available for re-mapping, provided they are free and set to the same measurement mode. Verify the new channel with the same known voltage before trusting it, and update every reference to the old mapped address in the application so nothing keeps reading the dead input.