Module 03 · PLC foundations

Data types & addressing

Everything in a PLC is stored as bits. This module shows how bits become numbers, which data type to pick for each signal, and how each PLC brand names its inputs, outputs and memory.

≈ 35 min6 lessons1 hands-on labQuiz · pass 80 %Free

By the end of this module you can

  • Convert between binary, decimal and hexadecimal
  • Choose BOOL, INT, DINT, REAL, TIME or STRING for a signal, and know their ranges
  • Explain overflow, and why INT 32767 + 1 is −32768
  • Read addresses on Siemens, Rockwell, Mitsubishi and IEC PLCs
  • Prefer symbolic tag names, and name tags consistently

A bit is 0 or 1. Eight bits make a byte, 16 bits a word, 32 bits a double word. Each bit position has a weight: 1, 2, 4, 8… so 0000 0000 0000 1101 is 8 + 4 + 1 = 13. Hexadecimal groups four bits into one digit 0–F, which is why engineers like it: 1101 = D.

Try it

A 16-bit word

Click bits to switch them. Bit 15 is the sign bit when the word is read as a signed INT.

Unsigned (WORD / UINT)0
Signed (INT)0
Hexadecimal16#0000
IEC typeSizeRangeUse it for
BOOL1 bitFALSE / TRUEInputs, outputs, flags, status bits
INT16 bit−32 768 … 32 767Raw analog values, small counts, Modbus registers
DINT32 bit±2 147 483 647Counters, totals, step numbers: the safe default for whole numbers
REAL32 bit float±3.4·1038, about 7 significant digitsEngineering values: bar, °C, m/s, setpoints
TIME32 bite.g. T#2m30sTimer presets and elapsed times
STRINGvariable'Batch OK'Batch IDs, barcodes, messages
OverflowAdding 1 to an INT holding 32 767 does not give 32 768: it wraps to −32 768 (or raises an overflow flag, depending on the PLC). A production counter in an INT goes negative after 32 767 parts. Use DINT for counts.
REALNever compare REALs for exact equality: 0.1 + 0.2 = 0.3 can be FALSE. Compare with >= / <= or a tolerance band.

Older PLCs addressed everything by location: "input byte 0, bit 3". Modern ones are symbolic: you name a tag and the software finds the memory. Most still let you see or use the absolute address.

IEC 61131-3 direct addresses start with %, then I (input), Q (output) or M (memory), then the size: X bit, B byte, W word, D double word. Examples: %IX0.3, %QX1.0, %MW10, %ID4. In practice you declare named variables and map them to these addresses once.

Logivyx is fully symbolic: every value is a tag (Conveyor.Start_PB). For the Soft-PLC, tags live in Logivyx memory; physical I/O arrives through Data Exchange devices (Modbus, EtherNet/IP remote I/O) mapped onto tags.

AreaBitByte / Word / DWord
Inputs%I0.0 … %I0.7, %I1.0…%IB0, %IW64, %ID4
Outputs%Q0.0%QB0, %QW80
Bit memory%M10.0%MB10, %MW10, %MD20
Data blocks"Motor_DB".Running (optimized DB, symbolic only)

Byte addresses overlap: %MW10 is bytes 10 and 11, so %MW10 and %MW11 share byte 11. Use even addresses for words and steps of 4 for double words (%MD20, %MD24) to avoid corrupting data. Bits count 0–7 inside each byte.

ControlLogix and CompactLogix are tag-based. There is no %M area: you create tags of type BOOL, DINT, REAL, TIMER… at controller or program scope. I/O modules create structured tags automatically:

Local:1:I.Data.0Input module in slot 1, point 0
Local:2:O.Data.5Output module in slot 2, point 5
Remote_IO:3:I.Ch0DataAnalog channel 0 of a module in a remote rack

Good practice: create an alias tag such as Start_PB pointing to Local:1:I.Data.0 and use the alias in logic. Older SLC 500/MicroLogix use file addresses like I:1/0, O:2/5, B3:0/0, N7:0.

DeviceMeaningExample
XInputX0, X17 (iQ-F octal) · X1F (iQ-R hex)
YOutputY0, Y10
M / LInternal relay / latch relay (retentive)M100, L10
DData register, 16 bitD100; 32-bit uses the pair D100–D101
T / CTimer / counterT0, C5
SM / SDSpecial relay / registerSM400 always ON, SD520 scan time

iQ-F (FX5) numbers X and Y in octal: X0–X7, then X10. Q, L and iQ-R use hexadecimal: X0–XF, then X10. GX Works3 also supports labels (symbolic names) mapped to devices.

Programs are read far more often than they are written, usually by a maintenance engineer at 3 a.m. Good names make the logic explain itself:

  • Say what the signal means, not where it is wired: Conveyor1_Run, not Q4_3.
  • Make the TRUE state obvious: Door_Closed, Air_Pressure_OK, Stop_PB_OK, never just Door.
  • Use a consistent pattern: Area_Device_Signal, and suffixes such as _PB (push button), _LS (limit switch), _FB (feedback), _SP (setpoint).
  • Group related tags in structures (UDTs): Pump1.Run_Cmd, Pump1.Running, Pump1.Fault. You'll build these in Level 8.

Take the conveyor I/O list from module 02 and give each signal an address on the PLC you use. Then check against the model answer.

Lab

Conveyor addresses

  1. Choose a brand tab above. Assume the digital inputs are on the first input card, the outputs on the first output card and the analog input on the first analog channel.
  2. Write the address for each of the five digital inputs and three outputs.
  3. Write the analog input address and the data type of its raw value.
  4. Pick a data type for: the carton weight in kg, the cartons-per-shift count, and the "running" status.
  5. Compare with the model answer.
Model answer
TagSiemens S7-1200Rockwell CompactLogixMitsubishi iQ-F
Start_PB%I0.0Local:1:I.Data.0X0
Stop_PB_OK%I0.1Local:1:I.Data.1X1
Motor_MPCB_OK%I0.2Local:1:I.Data.2X2
Motor_Running_FB%I0.3Local:1:I.Data.3X3
Carton_PE%I0.4Local:1:I.Data.4X4
Motor_Contactor%Q0.0Local:2:O.Data.0Y0
Lamp_Running%Q0.1Local:2:O.Data.1Y1
Lamp_Fault%Q0.2Local:2:O.Data.2Y2
Weight_Raw%IW64 (Int)Local:3:I.Ch0Dataa D register set in the module parameters

Weight in kg: REAL. Cartons per shift: DINT. Running: BOOL. Slot numbers and the analog address depend on your hardware configuration.