IMDHMIControls LibraryShop main store

How-to

Map physical I/O channels in CODESYS V3.5

PLC programming Published 7 min read

Short answer

Add the device description for the controller and every I/O module, insert each module under the bus interface it physically hangs on, and bind channel to variable in the device's I/O Mapping tab. Match the variable's type to the channel's exposed type, convert raw values in code, and treat a successful login as proof of nothing about the I/O.

On this page
  1. Which device descriptions does CODESYS need before any I/O shows up?
  2. Where in the device tree do the analog and digital modules go?
  3. How do you assign a variable to a channel in the I/O Mapping tab?
  4. Which data type does a mapped analog channel variable need?
  5. Why does a successful login prove nothing about the I/O?
  6. How do you test each mapped channel before trusting it?
  7. Questions asked

Map a channel by inserting the right device description under the interface it physically hangs on, then binding that channel to an application variable in the device's I/O Mapping tab. Nothing else in CODESYS V3.5 assigns a terminal for you: module selection, channel type, and variable binding are all device-configuration work that a successful login will never do on its own. This walkthrough uses an ifm AC14-series controller with two analog modules and one digital module, but the order holds for any CODESYS V3.5 target: install descriptions, place devices, map channels, match types, then prove each channel live before the machine runs.

Which device descriptions does CODESYS need before any I/O shows up? #

CODESYS shows I/O only after the device description for the installed controller and each module is present in the tool's device repository, so step one is the controller vendor's CODESYS package, not the programming system alone.

A V3.5 project targets one controller through its device description, and a generic target exposes a different set of interfaces that will not stand in for the real hardware. Before touching the device tree, record the controller's full designation and firmware identification, each I/O module's order code, and the connection path between controller and modules. For the AC14 case that means the vendor's CODESYS package for the controller together with its programming documentation, with the required CODESYS version checked before anything is installed. Proceed once every physically present module matches a page of documentation; the module count alone never tells you which devices to insert.

Where in the device tree do the analog and digital modules go? #

Add each module beneath the interface it actually talks through in the device tree — a wrong parent filters the module out of the selection list or puts its process data on a bus it does not use.

Open the controller's device tree beside the physical installation and read the topology before adding anything: modules on the controller's own connectors are children of the controller, and modules on a fieldbus are children of that bus master. Add each device from the parent's selection dialog, matching the module's designation and its applicable revision or configuration variant. When an installed module never appears in that list, suspect the parent first, because an incompatible interface hides an otherwise installed description.

Where the interface assigns addresses, node numbers or station positions, read them from the installed system and its documentation rather than deriving them from the order you happened to add devices, then confirm the configured population matches the panel: two analog modules and one digital module in their physical arrangement. Choosing the master and device set for a bus is its own decision, and how to select a CODESYS fieldbus master for industrial Ethernet covers the master side of that choice.

How do you assign a variable to a channel in the I/O Mapping tab? #

Open the device's editor, switch to the tab named <device name> I/O Mapping, click the variable cell of the channel, and type or pick the application variable that should own that channel's data.

  1. Double-click the device object in the device tree to open its editor, and select the tab whose title ends in I/O Mapping.
  2. Find the channel row: inputs and outputs are listed with their direction and their data type exactly as the device exposes them.
  3. Click the variable cell on that row, and type the path of a declared variable or pick one from the input helper that opens in the cell.
  4. Repeat for every channel the program uses, and leave channels you do not use unmapped.
  5. Build the project: the compiler reports a type mismatch or a variable assigned to two channels as an error, and a clean build is the gate to any download.

Mapped variables are ordinary application variables, which your logic reads and writes like any other declared name. Give every output exactly one writer, and never write to a mapped input in the program — the process image overwrites it every cycle and hides the fault. Keep the physical terminal number and the software channel number apart in a written schedule: the tab owns the software side, and declaring a variable never assigns a terminal.

Which data type does a mapped analog channel variable need? #

The mapped variable must match the data type the channel exposes in the mapping table, because the runtime copies process data bit-for-bit and will not turn a 16-bit integer count into a floating-point voltage for you.

Read the type from the channel's own row — most analog channels carry a 16-bit integer and a few expose floating point directly — and declare the variable exactly that type. Conversion to engineering units belongs in application code, one function away from the mapping, so the raw value and the scaled value never share a name.

Worked example, using the spans of an illustrative module manual — take the real spans from your module's own documentation, because they differ by module and by configured range. A channel exposes 0 to 32767 counts for 0 to 10 V, mapped to an INT variable iRawUs, feeding a transmitter scaled at 0–10 V = 0–200 °C:

  • Resolution: 10 V ÷ 32767 counts = 0.000305 V per count.
  • Raw reading of 16384 counts: 16384 × 10 V ÷ 32767 = 5.000 V.
  • Engineering value: 5.000 V × 20 °C/V = 100.0 °C.
  • Output command of 50.0 °C, converted the other way: 50.0 ÷ 20 = 2.500 V, and 2.500 V ÷ 10 V × 32767 = 8191.75, rounded to 8192 counts on the output channel.

The test that proves it: apply a known 5.000 V at the terminal, watch iRawUs settle near 16384 in the tab online, and read 100.0 °C out of the scaling function. Decisions by channel class:

  • Digital input: map the channel's Boolean — or its bit inside a packed input word — to a named BOOL signal.
  • Digital output: map one command BOOL to the output channel and give it exactly one writer.
  • Analog input: map the raw type, then convert in code.
  • Analog output: convert engineering units to the documented raw format in code, then map that raw variable to the channel.

Why does a successful login prove nothing about the I/O? #

A login that succeeds tells you the engineering station reached the runtime, nothing more: the programming connection and the I/O process-data path are separate checks, and a downloaded project can still have every module dark.

Signing in proves the tool can talk to the controller; it says nothing about whether a module is powered, configured, or exchanging valid process data. Run them as two commissioning checks with separate evidence — the login for the toolchain, live channel values for the I/O. A fieldbus deepens the trap, because a status flag can sit quietly while a wire is gone: why the CODESYS EtherCAT master xError stays false on cable pull documents exactly that lull. The decision: sign off a mapping only after every channel's live value has moved under a signal you applied, never after a download alone.

How do you test each mapped channel before trusting it? #

Prove every channel with a physical or forced signal at the terminal while you watch the mapped variable live, and give outputs a controlled test with people clear of the driven equipment before you trust the mapping.

For an input, make one change at a time — trip the prox, inject the mid-scale voltage, break the loop — and watch the channel cell in the tab follow it. For an output, command the channel from the program with the drive disabled, watch the channel cell follow the command, then allow one controlled stroke with the area clear. One change per test so the result names its cause; the method in Industrial Troubleshooting Improves When Each Test Proves a Cause keeps that discipline honest.

A variable that sits in the mapping table but is referenced nowhere in the program will not update on its own; enable the Always update variables option on that device's PLC Settings tab when you need to monitor such channels. And when a mapped value refuses to move, split the question before touching logic: watch the channel's value in the tab online to tell a dead channel from a program that overwrites the variable.

Questions asked

Can one assignment cover several channels at once?

Yes. The mapping table accepts a structured variable on a device whose channels are grouped, and you can then assign individual bit-channel entries inside that structure to their terminals. Channel-by-channel assignment stays easier to read at the hardware level and in the program, so most panels are better served by one named variable per channel, with grouped mapping reserved for packed status or command words.

Why does a mapped input variable stay at zero while the terminal is wired hot?

First look for a second writer: mapped input variables belong to the process image, and any assignment your logic makes to the same name overwrites it every scan. Then check the device itself, because a module that has dropped off its bus stops cycling process data while the project still looks healthy. Watch the channel's value in the mapping table online to separate a wiring problem from a program problem.

Does the mapping survive a module swap or a device description update?

Treat any change to the device configuration as a change that can void channel assignments. The mapping binds a variable to a channel of the configured device, so a different module order code or revision can shift channel names, counts, or data types. After any swap, rebuild the project, reopen the I/O Mapping tab, and confirm every assignment and type before the machine runs again.

Where do the terminal numbers come from?

From the module's wiring diagram, never from the software. A connector on an I/O module carries signal, supply, return, and shield terminals, so terminal numbering does not follow process-data numbering. Keep a written schedule that pairs each physical terminal with its channel and mapped variable, and fill the schedule in from the module documentation during design, before any wire is landed.

Keep reading

  • Explainer

    Editing a CODESYS Raspberry Pi PROFINET controller project

    A Raspberry Pi running CODESYS Control executes the compiled application you download to it; it cannot import GSDML, rebuild the project, or safely change I/O or OPC UA mappings on its own. Keep the CODESYS Development System on Windows as the editing tool, deploy builds to the Pi, and reserve the runtime on the controller for execution.

    PLC programming

  • Troubleshooting

    PLC-5/80E loses scan list on remote I/O after power cycle

    Auto-negotiate selected on Ethernet Channel 2 of a Series F Revision A PLC-5 clears the chassis scan list on the remote I/O scanner channels whenever the processor power cycles. Disable auto-negotiate and hard-set 100 Mbps full duplex, or flash Revision A.1 or newer; Auto-Config only rebuilds the list after each event.

    PLC programming

  • How-to

    Port a PLC-5 filter routine to ControlLogix structured text

    The filter is a first-order lag whose only state is the previous filtered value. Give every filtered signal its own instance of one filter UDT that also holds the exponent and coefficient, translate the rungs to ordered assignments in a periodic task, and preload the state on the first pass. Prove the port with a step: 63.2% of the change after one time constant, about 95% after three.

    PLC programming