CODESYS ยท Track 05 ยท hardware abstraction

The Device Tree

CODESYS keeps your logic and your hardware apart. The device tree describes the physical setup โ€” the target, its fieldbus, the I/O modules โ€” and an I/O mapping ties each physical channel to a variable. Your program reads the variable, never the channel. Swap the target and your logic doesn't flinch; only the mapping moves.

๐ŸŒฒ device tree๐Ÿ”— I/O mappingportable logic
01 ยท Swap the target, keep the logic

Variables in, channels out

The tree shows a target with an EtherCAT master and an 8-point input module; the table maps its channels to your variables (xStartPB, xLevelHiโ€ฆ). Press ๐Ÿ”„ Re-target to move the whole project to a different vendor's controller โ€” watch the target and channel addresses change while your variable names stay identical. That's portability in one click.

๐Ÿ”— I/O Mapping โ€” your variables โ†” physical channels

Variable (your logic)Channel (this target)

Notice what didn't change: every variable name. Your POUs, languages and logic are written against names; the device tree and mapping are the only place hardware lives. Re-target, remap, download โ€” the valuable part (your program) comes along untouched. This is the mechanism behind Track 01's "write once, run anywhere."

02 ยท The layers of the tree

From target down to a pin

๐ŸŽฏ Target / Device โ€” the controller you're running on. Swapping it re-points the whole project; CODESYS recompiles for the new runtime.

๐Ÿ”Œ Fieldbus master โ€” EtherCAT, PROFINET, Modbusโ€ฆ added under the target. Imports device descriptions (ESI/GSDML) for the slaves below it (Track 06).

๐Ÿ“Ÿ Slave / module โ€” an I/O block, drive or sensor on the bus, with its channels exposed for mapping.

๐Ÿ”— The mapping โ€” the thin layer binding a channel to a variable. The only thing that's truly hardware-specific in your project.

03 ยท Check yourself

What moves on a re-target?

You re-target a finished project from a Raspberry Pi to an industrial controller. What needs attention?