KB Controls is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Read more in our disclaimer

Factory IO From A to B (Set and Reset) Tutorial with Control IO

A step by step tutorial for Factory IO's "From A to B" scene and a challenge to test your programming knowledge

If you have taken my free PLC Bootcamp, then you know that I am a huge fan of Factory IO for learning PLC Programming by simulating common industrial automation applications.

Since launching PLC Bootcamp and introducing Factory IO to my audience, I have received a few emails asking for advice on how to solve the pre-built scenes available in Factory IO.

Instead of answering those emails privately, I have decided to put together a series of tutorials that explain how to write programs for each Factory IO scene and how to extend the scenes to make them more realistic.

In this post, I will show you how to implement a solution for the “From A to B (Set and Reset)” scene and give you a challenge to test your programming knowledge.

If you haven’t already, I suggest that you head over to the Factory IO website and install Factory IO so that you can follow along with this tutorial.

Already have Factory IO installed? Then let’s get started.

Open the “From A to B (Set and Reset)” Scene

Launch Factory IO from the Start Menu of your machine and click on Scenes to open the list of pre-built scenes available for Factory IO.

Open the Scenes list in Factory IO

Click on “2 — From A to B (Set and Reset)” to open today’s scene.

Open “2 — From A to B (Set and Reset)”

Basic Solution for Scene

Launch the Control I/O Editor

Before we can program a solution for this scene with the built-in Control I/O editor, we have to configure the Control I/O driver.

To do that, click on File > Drivers.

Open the Drivers menu with File > Drivers

In the Driver Selection dropdown, chose Control I/O. Control I/O is the built-in soft PLC and programming environment for Factory IO that allows you to write and test PLC programs in a graphical environment.

Select the Control I/O Driver

After selecting the Control I/O driver, the Control I/O editor opens. This is a graphical code editor that can be used to write PLC programs for Factory IO simulations in a language similar to Function Block Diagram (FBD).

Solution Requirements

What do we want to accomplish in this scene?

Basically, the first conveyor, called the entry conveyor, should run continuously to transport the tote to the second conveyor.

The downstream conveyor should start running when the tote hits the photoelectric sensor at the start of the conveyor (Sensor A). The downstream conveyor should stop running when the tote hits the photoelectric cell at the end of the conveyor (Sensor B).

The downstream conveyor should not start running again until the tote is removed and the photoelectric cell is no longer occupied.

How can we create that logic in the Control I/O editor?

Entry Conveyor Logic

Let’s start with the entry conveyor. The logic here is simple — since this conveyor will run continuously, we can connect the entry conveyor tag directly to a memory bit that permanently has the value true. This will permanently run the conveyor.

To create this logic, I have added the entry conveyor tag (1) and a Boolean Source variable to the canvas (2). I then connected those elements together to complete the logic by dragging and dropping between them (3).

Entry Conveyor Logic

We can set the value of the Source Boolean variable to true by clicking on the power icon in the instruction. Now the entry conveyor will run continuously while the Factory IO model is running.

Toggle Value of Source Boolean Variable

Conveyor Logic

Now let’s look at the logic for the downstream conveyor.

This conveyor should start running when Sensor A is triggered and stop running when Sensor B is triggered. Another way to say this is that we want the Conveyor tag to be set to true when Sensor A is triggered and reset to false when Sensor B is triggered.

To implement this behaviour, we can use an SR, short for Set-Reset, or RS, short for Reset-Set, Function Block. The difference between these two instructions is the priority.

In an SR instruction, the setting action has the priority, so if both inputs are activated then the associated tag will be set to true.

In an RS instruction, the resetting action has the priority, so if both inputs are activated then the associated tag will be set to false.

In our application, we will use the RS Function Block. In general, if you have moving parts like a conveyor, then reset should be the priority. That way, the movement stops in the case of an abnormal situation.

I add an RS instruction to the canvas.

Add an RS Instruction to the Canvas

Now we can connect Sensor A to the SET input of the RS Function Block and connect Sensor B to the RESET input of the RS Function Block.

Since the photoelectric cells in Factory IO are normally closed (that is, the tag has the value true when the sensor is free and the value false when the sensor is occupied), then we have to put a NOT instruction in front of the SET and RESET pins.

Finally, we can connect the Conveyor tag to the output of the Function Block.

The completed logic looks like the image below.

Completed Logic

Back in Factory IO, press the play button to run the scene.

You should see the entry conveyor running continuously. When the tote hits Sensor A, the conveyor should start running until the tote hits Sensor B.

Our logic seems to be working correctly.

Working Factory IO Model


In Factory IO, you can add multiple products to a model by using an “Emitter” component.

To add an Emitter to the model, select the tote and press delete to remove the tote. Once the tote is deleted, drag an Emitter from the toolbox onto the position where the tote was.

Add an Emitter to the Model

Now when you run the model, multiple products are introduced to the model. You can see that when the downstream conveyor stops running, the entry conveyor continues to run and products eventually crash into each other.

Products Colliding

Although this highlights how good the physics engine in Factory IO is, it is not a great situation for the products being transported.

Your challenge is to update the logic in Control I/O to stop the entry conveyor when the downstream conveyor is not running.

I am really interested in hearing how you get on with this challenge. If you want, you can let me know how you solved them (or where you got stuck), by dropping an email to ken@kb-controls.io.

I look forward to hearing from you.

PLC Programming Bootcamp

Learn PLC programming and kick start your career as a PLC programmer by following our free 5 day bootcamp.

Learn More

Related Content