Fareed Mohmed · Engineering
Machine Program Builder
Connect · Sequence · Generate · Simulate
Choose a Mitsubishi FX5U CPU and its I/O modules, add the devices that are wired to it (push-buttons, sensors, pneumatic cylinders with end sensors, motors, valves, lamps), then list the machine steps in order. The page writes the structured text (ST) program for GX Works3, the label table and the I/O list, and runs the same program in a simulator so you can see the machine move before you go near a PLC.
This tool has not been tested on a real PLC. It writes a straightforward sequence program and proves its logic in a browser simulator, but a qualified person must read, test and commission the program on the real machine. It contains no safety functions: emergency stops, guards and light curtains must work by safety hardware or a safety PLC. Address numbering and wiring notes must be checked against the FX5 manuals and the GX Works3 module configuration.
Hardware
Pick the CPU and add the extension modules in the order they sit on the rail. Your work is kept in this browser; use Save project below to keep a copy or move it to another computer.
Devices and connections
Add every device that is wired to the PLC. Cylinders bring their own valve coils and end sensors. Each connection gets a PLC address; empty ones are filled in automatically and you can change them.
Sequence
Each step switches things on or off, then waits for sensors or a delay before the next step. Outputs stay as set until a later step changes them, just like a real cylinder or conveyor.
Program
Simulate
The simulator runs the program text above, scan by scan. Cylinders move at their travel time and switch their end sensors. Click the inputs to operate the machine: hold Start, toggle sensors, hold Stop, trip the E-stop.
How it works
One step at a time
The program keeps a step number. Step 0 is idle with every output off. Pressing Start moves to step 1. Each step sets its outputs, then moves on when its waits are satisfied. This is the classic step-sequencer pattern and is easy to read and change.
Time-outs
A step that waits for a sensor can have a time-out. If it passes, the program latches a fault, stops the sequence, switches outputs off and records which step stuck. Reset clears the fault.
What the program does with Stop and E-stop
Stop (normally closed) and the E-stop healthy input send the sequence back to idle and switch outputs off. This is a convenience for the PLC. It is not a safety function.
What it does not do
No ladder output yet, no motion control or servo positioning, no network or HMI, no analog handling, no safety logic. Only Mitsubishi FX5U/FX5UC style addressing is supported.
Related tools
Draw the wiring with the Electrical Circuit Builder, the air circuit with the Pneumatic Circuit Builder, and pick cables with the Machine Wiring Guide.
User manual
Tap a chapter to open it. The buttons marked Load this example replace the drawing on the sheet, so save your work first (Save project).
1. What this tool does and does not do
You describe a machine: the PLC, the devices wired to it, and the steps it must do in order. The page produces a Mitsubishi GX Works3 structured text (ST) program, the label table, an I/O list with wiring notes, and a simulator that runs the same program so you can watch the machine move.
What it covers. Mitsubishi FX5U CPUs (32, 64 and 80 point) with FX5 digital extension modules. Start, stop, E-stop healthy and reset buttons, pneumatic cylinders with end sensors, motors or conveyors switched by a contactor or drive run signal, sensors, solenoid valves, lamps and a buzzer. Sequences of steps with delays, sensor waits, time-outs, repeat and batch counting.
What it does not cover. Ladder output (planned), servo or stepper positioning, analog signals, networks and HMI, and any safety function. Other PLC makes and models are not supported yet.
Not tested on a real PLC. The program logic is proved in the simulator. Module numbering, wiring and syntax details must be checked against your FX5 manuals and GX Works3 version before use.
Who it is for: freshers learning how a machine sequence becomes a PLC program, and the Merlin design team making a quick first draft.
2. Quick start: A+ B+ A- B- in 3 minutes
- Press Load this example below. The page fills with an FX5U-32MT, Start, Stop, E-stop and Reset buttons, cylinders A and B with end sensors, and a four-step sequence.
- In 04 Program read the checks, then the program. It has six blocks: machine controls, timers and time-outs, stop and fault handling, start, the sequence, and lamps.
- In 05 Simulate press Run, then press and hold the Start button for a moment. Cylinder A extends, then B, then A retracts and B retracts, and the cycle repeats. Press and hold Stop to end it.
- Press Run automatic check. The page presses Start, lets the sequence run for two cycles, presses Stop, and reports the time for each step.
- In 03 Sequence change the time-out of step 2 to 0.2 s. Press the check again: B cannot extend in 0.2 s, so the machine faults at step 2, and the report says so.
- Press Copy program or Download .st, and Download I/O list for the wiring list.
3. The page
01 Hardware. The CPU, the extension modules, and how many inputs and outputs you have. 02 Devices and connections. Every device and the PLC address it is wired to. 03 Sequence. The steps. 04 Program. Checks, the ST program, the I/O list and the label tables. 05 Simulate. The machine and the automatic check. 06 How it works explains the program structure. This manual is section 07.
Your work is kept. The page remembers your project in this browser. Save project writes a .json file you can keep or send; Open project loads it again. Loading an example replaces the current project.
4. Hardware and addresses
Inputs are X and outputs are Y, numbered in octal: X0 to X7, then X10 to X17. A 32-point CPU has X0 to X17 and Y0 to Y17. Extension modules continue the numbering after the CPU, in the order they are added. Inputs and outputs are numbered separately.
Check the numbers in GX Works3. The tool assumes the standard continuation. If your module configuration gives a different first address, type it in the first-address box for that module and the tool will use it.
The CPU output type matters. A transistor (MT) output switches about 0.5 A at 24 V DC; a relay (MR) output switches about 2 A. Contactors, drives and bigger valves need an interposing relay on transistor outputs. The I/O list gives a note for every point.
5. Devices
- Start button (normally open), Reset button (normally open).
- Stop button is wired normally closed, so a broken wire stops the machine. Its input is ON when the button is not pressed. The program already allows for this.
- E-stop healthy contact is a contact of your E-stop or safety relay that is ON when everything is healthy. The program only reads it. The emergency stop itself must cut power by hardware.
- Cylinder. Choose double-acting with two coils (5/2 double solenoid), double-acting with one coil and spring (5/2 single solenoid) or single-acting spring return (3/2). Tick the sensors it has. Travel time is only used by the simulator.
- Motor is an output to a contactor coil or a drive run input. Sensor is a generic input you can wait for. Push-button is another operator button. Valve, buzzer and lamp are outputs. A lamp can be a run lamp (on while the sequence runs), a fault lamp (on while faulted) or a free lamp you switch in a step.
Names become labels in the program. Letters, digits and underscores only; duplicates are made unique automatically.
6. Building the sequence
Each step has two parts. Do lists actions: extend or retract a cylinder, start or stop a motor, open or close a valve, switch a lamp. Then wait until lists conditions: a cylinder is extended or retracted, a sensor is on or off, a button is pressed, or a delay has passed. With more than one wait choose all or any.
Outputs stay set. An action stays in force until a later step changes it. A motor started in step 1 keeps running through step 2 until a step stops it. A double-solenoid cylinder keeps its last command. When the sequence stops (Stop, E-stop, fault, or end of cycle) every output in the sequence is switched off.
Time-out. For a step that waits on a sensor, set the number of seconds after which the machine faults. 0 means wait for ever. A fault stops the sequence and the fault lamp comes on; press Reset to clear it. The step that timed out is stored (D1 in direct mode, FaultStep as a label).
Cycle options. At the end of the last step the machine either stops and waits for Start, or repeats from step 1. With repeat you can enter a batch count; the machine then stops after that many cycles. Reset clears the count. The Start button only works when every cylinder with a retracted sensor is retracted, unless you untick that option.
Check by hand. Cylinder A extends (1 s travel) and B extends (0.4 s): with A+ then B+ then waits on their end sensors, the minimum cycle time is the sum of the travel times of each step plus one scan per step transition. The automatic check reports exactly these times.
7. The generated program and how to use it in GX Works3
The program has six blocks, each with a comment:
- Machine controls. Reads the E-stop, the stop button and the start and reset edges.
- Step timers and time-outs. One TON timer for each delay and each time-out.
- Stop, E-stop, fault and reset. Sends the sequence to idle and clears faults.
- Start. Starts at step 1 when idle, nothing is faulted and the cylinders are home.
- Sequence. A CASE statement on the step number.
- Indicator lamps.
Label mode (recommended). The program uses names. Create the global labels in the table shown (label, type, class, assigned device) and paste the program. Timers and edge detectors (TON and R_TRIG) are local labels of the program block; create them with the types shown.
Direct mode. The program uses X, Y, M and D addresses with comments, so only the timers and edge detectors need local labels. M0 to M3 and D0 to D2 are used for internal flags: change them if the project already uses them.
Steps in GX Works3 (menu names vary a little between versions). Create a project for your FX5U. Open the module configuration and add the extension modules. Add a program block in ST. Enter the labels. Paste the program. Convert (build) and fix any message. Write to the PLC with the PLC in STOP, then test with the machine unpowered or in a safe state.
Note. Check that your GX Works3 version has the TON and R_TRIG standard function blocks with the names used here. If it names them differently, use your version's timer and edge blocks.
8. The simulator and the automatic check
The simulator parses the exact program text shown and runs it every 10 ms scan. Cylinders move at their travel time and set their end sensors; outputs light up as they switch on. Buttons marked hold are operated while you press them. Sensors and the E-stop toggle with a click. Speed can be increased to 3× or 10×.
Automatic check. Presses Start at 0.1 s. For each generic sensor it switches the input to the state the current step is waiting for, 0.3 s after the step begins. After two cycles it presses Stop. It reports pass or fail, the time of each step, and the reason for a failure: a fault at a certain step, a sequence that never finishes, or outputs left on in idle.
What a pass means. The sequence logic, the time-outs and the start and stop handling work for the devices as you described them. It does not mean your real sensors, valves, timings and wiring behave the same. Test on the real machine.
Limits. Cylinders are an ideal travel; there is no air supply model, load or cushioning. Sensors are ideal and have no bounce. Scan time is fixed at 10 ms and the real FX5U scan is faster.
9. Worked examples
Single cylinder. Start, A out, 1 s dwell, A in, stop. The shortest useful program.
A+ B+ A- B-. Two cylinders, one double and one single solenoid, run lamp and fault lamp, repeats until Stop.
Conveyor with pusher. The conveyor runs until a part sensor sees a part, stops, waits 0.5 s, the pusher extends and returns, and the cycle repeats. In the simulator click the PartAtEnd sensor when you want a part to arrive.
Pick and place with batch count. Z lowers, the gripper closes, Z lifts, X moves over, Z lowers, the gripper opens, Z lifts, X returns. It stops after 5 cycles.
10. Common mistakes
- Waiting for a sensor the cylinder does not have. The check shows an error. Tick the sensor or wait for a delay.
- Stop button wired normally open. The program expects a normally closed button. A normally open stop button does not fail safe.
- No time-out. A broken sensor stops the machine with no message. Give every sensor wait a time-out.
- Loads on a transistor output that are too large. Use an interposing relay.
- Leaving a double-solenoid cylinder extended at the end of the cycle. After a stop it stays extended. Add a return step.
- Using the program as a safety function. It is not one. Use safety relays or a safety PLC.
11. What is not covered
Ladder diagram output, other PLC makes and series, high-speed counters, positioning, analog values, PID, networks and HMI tags, recipes, and alarm texts. Safety circuits are not generated or checked. Tell Merlin if one of these should come next.
What's new
- v1 · 11 Oct 2026
First release: Mitsubishi FX5U (32, 64, 80 point) with digital extension modules. Devices: buttons, cylinders with end sensors, motors, sensors, valves, lamps, buzzer. Sequence editor with delays, sensor waits, time-outs, repeat and batch count. Structured text output in label and direct modes, I/O list with wiring notes and CSV download, project save and open, simulator and automatic check, four worked examples.