Learn OMRON-CX-PROGRAMMER with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Simple Output Control (ST)
IF CIO100 THEN
CIO000 := TRUE;
ELSE
CIO000 := FALSE;
END_IF;
Turns output CIO 0.00 ON when input CIO 1.00 is TRUE.
2
TON On-Delay Timer (TIMX Equivalent)
TIMX_1(IN := CIO101, PT := T#5s);
IF TIMX_1.Q THEN
CIO001 := TRUE;
END_IF;
Starts a 5-second timer and turns ON an output when done.
3
CTU Up Counter (CNT)
CTU_1(CU := CIO102, PV := 10);
IF CTU_1.CV >= 10 THEN
CIO002 := TRUE;
END_IF;
Counts rising edges on CIO 1.02. Turns ON CIO 0.02 at 10 counts.
5
Analog Scaling (0–4000 -> 0–100%)
Scaled := (REAL(D300) * 100.0) / 4000.0;
Omron analog input scaling example.
6
Motor Start/Stop Seal Circuit (ST)
IF CIO103 THEN
M_Start := TRUE;
END_IF;
IF CIO104 THEN
M_Start := FALSE;
END_IF;
CIO003 := M_Start;
Start button CIO 1.03, Stop button CIO 1.04, output latch at CIO 0.03.
7
Rising Edge Detection (Differentiation UP)
R_TRIG_1(CLK := CIO105);
IF R_TRIG_1.Q THEN
CIO004 := TRUE;
END_IF;
Detects positive edge on CIO 1.05.
8
FOR Loop Summing Registers
Sum := 0;
FOR i := 0 TO 9 DO
Sum := Sum + D[i];
END_FOR;
D50 := Sum;
Sum values from D0 to D9 into D50.
9
PIDAT Block Example (Omron PID)
PIDAT_1(
PV := D600,
SP := D610,
KP := 1.0,
TI := 2.0,
TD := 0.0,
OUT => D620
);
Basic PID instruction block for Omron PLC.
10
Simple PWM Output (ST Logic)
IF Ramp >= 100 THEN
Ramp := 0;
END_IF;
IF Ramp < Duty THEN
CIO005 := TRUE;
ELSE
CIO005 := FALSE;
END_IF;
Ramp := Ramp + 1;
Generates PWM on CIO 0.05 using a ramp counter.