Learn ROCKWELL-STUDIO5000 with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Hello World in Studio 5000 (Structured Text)
IF Start_PB THEN
Motor_Run := TRUE;
ELSE
Motor_Run := FALSE;
END_IF;
A simple Structured Text routine turning on an output.
2
TON Timer Example (ST)
TON_Timer(IN := Start_PB,
PT := T#5s,
Q => Done,
ET => Elapsed);
Using an Allen-Bradley TON timer in ST.
3
CTU Counter Example (ST)
CTU_Counter(CU := Pulse,
RESET := Reset,
PV := 10,
CV => Count);
A simple up-counter using CTU.
4
Move Instruction (ST)
Output_Value := Input_Value;
Copying a tag's value using MOV equivalent in ST.
5
Scaling Analog Input (ST)
Scaled := (Raw_AI * 100.0) / 16383.0;
Scaling a 0–16383 analog input to 0–100 engineering units.
6
Start/Stop Motor Latch (ST)
IF Start_PB THEN
Motor := TRUE;
END_IF;
IF Stop_PB THEN
Motor := FALSE;
END_IF;
Classic motor latch logic in Studio 5000 ST.
7
Rising Edge Detection (ST)
Prev := Curr;
Curr := Signal;
Rising_Edge := Curr AND NOT Prev;
Detecting a rising edge on a BOOL tag.
8
Array Summation (ST)
Sum := 0;
FOR i := 0 TO 9 DO
Sum := Sum + Values[i];
END_FOR;
Looping through a DINT array to calculate the sum.
9
Simple AO Scaling (ST)
Analog_mA := (Control_Output * 16.0) + 4.0;
Scaling a controller output to a 4–20 mA analog signal.
10
PID Call in Studio 5000 (ST)
PID(
PV := Process_Value,
SP := Setpoint,
CV => Control_Output,
EN := TRUE
);
Calling an A-B PID instruction in Structured Text.