KB Controls is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Read more in our disclaimer
A step by step tutorial for Factory IO's "From A to B" scene and a challenge to test your programming knowledge
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.
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.
Click on “2 — From A to B (Set and Reset)” to open today’s scene.
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.
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.
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).
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?
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).
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.
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.
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.
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.
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.
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.
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 firstname.lastname@example.org.
I look forward to hearing from you.
Take your PLC programming skills and build a portfolio of projects by programming solutions for 10 common industrial automation applications using Connected Components Workbench, Micro800 Simulator, and Factory IO. All lessons are on demand and can be completed in your own time and at your own pace.
A step-by-step guide to installing Factory IO by Real Games on your machine. Factory IO is a cutting-edge 3D simulation environment for simulating industrial automation applications and testing PLC programs from all manufacturers.
A complete step by step tutorial for solving Factory IO's "Mixing Tank (Timers)" scene using Control I/O and a few challenges to test your programming knowledge