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 I/O with Control I/O: From A to B Extended Solution

A Step-by-Step Tutorial for solving an extended and more realistic version of Factory I/O's "From A to B" Scene with Control I/O

This tutorial is part of the series, "Factory I/O with Control I/O". In this series, you can learn PLC programming by programming solutions for a range of common industrial automation applications. By the end of the series, you will have created a portfolio of projects that demonstrate your expertise in PLC programming. You can find all of the content from that series here.

In this tutorial, I will show you how to extend the Factory IO scene "From A to B" to make it more realistic and how to program the controls for the extended scene. Along the way, we will learn how to add parts to a Factory I/O scene and how to program a common PLC programming design pattern known as a seal-in circuit.

At the end of the tutorial, I will introduce some challenges for you to solve to apply the lessons that we have covered in the course and to test your PLC programming skills.

Since this is the second tutorial in the series, I will move faster through the topics that we have already covered and only explain new concepts in detail.

To follow along with this tutorial, you will need to have Factory IO installed on your machine. If you don't already have Factory IO installed on your machine, you can use my affiliate link to start your 30-day trial of Factory IO.

Before we start programming a solution for this scene, let's look at the requirements for this application.

Application Requirements

Factory I/O From A to B Extended Overview

In this tutorial, we will extend the From A to B scene that we worked in the previous tutorial to introduce some operator controls.

These controls allow an operator to press a Start button to start the conveyor. Once started, the conveyor motor continues to run until the operator presses the Stop button or the sensor at the end of the conveyor is triggered by a tote.

To restart the conveyor, the operator must press the Start button and the sensor must be unblocked.

As you can see, the requirements for this application are a little bit more complex than what we dealt with in the previous tutorial.

Now that we understand the requirements from the application, let's set up our program and start programming a solution.

Add Parts to a Factory I/O Scene

Just like we did in the previous tutorial, open the Factory I/O Scene From A to B.

You can add parts to a Factory I/O scene when the scene is in Edit Mode. You can switch from Run Mode to Edit Mode by clicking on the Stop icon in the Factory I/O toolbar in the top-right corner of the window.

Switch the scene from Run Mode to Edit Mode

When the Factory I/O scene is in Edit Mode, the Parts Palette is available on the right-hand side of the screen. The Palette is a complete catalog of all of the parts that can be added to a Factory I/O scene. You can filter the list of parts using the categories dropdown or the search bar available at the top of the Palette.

If you don't see the Parts Palette, check that the Palette is configured to display in the View menu.

Click View > Palette to toggle the visibility of the parts palette

In the Palette's search bar, search for "switchboard" to find the Electric Switchboard part.

Search for the Electric Switchboard part

The Electric Switchboard is an optional part that can be used to group Operator parts together.

You can add a part to your Factory I/O scene by dragging the part from the Palette and dropping it on the Factory I/O canvas.

Add a Part to the Factory I/O Scene by Dragging and Dropping

To rotate a part, you can right-click on the part and toggle the Yaw configuration of the part.

Rotate a Part by Toggling the Yaw Configuration of the Part

Now that the Electric Switchboard is in place, we can add the Start and Stop buttons to the scene.

To find the full set of pushbuttons parts available in Factory I/O, use the category dropdown to filter on Operator parts.

Filter the Operator Parts in the Palette

From the Palette, add a Start button and a Stop button to the Factory I/O scene, taking care to place them on the Electric Switchboard. When dragging a part, you can switch from adjusting the horizontal position of the part to the vertical position of the part by holding down the "V" keyboard button.

Once again, you can rotate the buttons by adjusting their Yaw configuration.

The end result should look like the Factory I/O scene shown below.

Finalized Extended Factory I/O Scene

Now that our Factory I/O scene is extended, we can start to program a solution for the application.

Seal-In Circuit

Open the Control I/O Editor and, if needed, delete the program from the previous tutorial to start from a blank canvas.

Let's start by programming the controls for the conveyor motor. Remember that the application requirements say that the conveyor motor should run continuously when the operator presses the start button. Another way to say this is that the conveyor motor should run when the Start button is pressed or the conveyor motor is already running.

In Control I/O, we can create OR logic using the OR function block. Drag an OR2 function block from the Function Blocks > Logical folder onto the Control I/O Editor canvas.

Add an OR2 Function Block to the Control I/O Editor Canvas

In an OR function block, the output pin OUT has the value True when either input pin, IN1 or IN2, has the value True.

With the OR function block placed on the canvas, we can connect the required tags to the function block. Remember that conveyor motor should run if the Start button is pressed (the tag Start Button 0 has the value True) or the conveyor is already running (the tag Conveyor has the value True).

Drag the required tags onto the Control I/O canvas from the Tags folder and connect them to OR function block as shown.

Seal-In Circuit for Conveyor Tag

Text what you have created so far by putting the Factory I/O Scene in Run Mode and pressing the Start button on the Electric Switchboard. Once you press the Start button, you should see that the Conveyor motor starts and remains running.

Press the Start Button and Verify that the Conveyor Runs

In the Control I/O Editor, we can see that the status of the Conveyor tag is sealed-in as expected.

Status of the Conveyor Tag is Sealed-In

In this program, the Start button is a "permissive" condition for the seal-in circuit. A permissive condition is a condition that needs to be True to start a seal-in circuit but does not affect the circuit once it is started. Here, the Start button needed to be pressed to start running the Conveyor motor, but it doesn't need to be pressed to continue running the Conveyor motor.

Now that we can run the Conveyor motor, let's see how to program the conditions to stop the Conveyor motor when the Stop button is pressed or the Sensor is triggered.

Interlock Conditions

According to to our application requirements, the Conveyor motor should stop running when the Stop button is pressed or the sensor at the end of the conveyor is triggered. Just like the sensor, the Stop button is wired normally-closed. This makes sense since we want the conveyor to stop if the Stop button is damaged.

Since both devices are wired normally-closed, we can say that the Conveyor motor should stop when the Sensor tag has the value False or the Stop Button 0 tag has the value False. We can invert this to say that the Conveyor motor can run when the value of the Sensor tag is True and the value of the Stop tag is True.

We can create AND logic in our Control I/O programs using the AND function block. In an AND function block when both of the input pins IN1 and IN2 have the value True, then the output pin OUT has the value True.

Drag an AND function block onto the canvas and connect the required tags as shown.

Interlock conditions

In this program, the Sensor and Stop buttons are "interlock" conditions. Interlock conditions are conditions that must be met for a process to start or continue running. In this program, if the Stop button is pressed, the Conveyor motor should immediately stop running and should not start running again until the Stop button is released.

We can combine the interlock conditions of the program, with the seal-in circuit using another AND function block since the seal-in circuit must be activated and the interlock conditions must be True for the Conveyor motor to run.

Update the program as shown below with and additional AND function block.

Final Program

Now that our program is finalized, go ahead and test it to make sure that it behaves as expected.

After pressing the Start button, the Conveyor motor should stop when you press the Stop button or the Tote triggers the sensor.

Test Result

Refactor the Code

As programs get bigger, it becomes more important to add comments and to think carefully about the way your code is structured and organized. This is important so that you can maintain and extend your code in the future.

Although this is a small program, it is a good chance to see how refactoring can make our code easier to read.

Let's start by adding some intermediate tags to group related logic together.

In Factory I/O, you can create new tags by dragging components from the Memories folder. Add a Boolean tag to the canvas.

Add a Boolean Memory Tag to the Canvas

You can assign a logical name to a tag in Control I/O by clicking on the tag and updating the name property. Go ahead and give the name "Permissives OK" to the Boolean tag that you added to the canvas.

Now, connect the permissives from the program to the variable and copy and paste the variable to use the same variable in the seal-in circuit.

Refactor to Check if All Permissives are OK 

It may seem strange to create this structure for a program with one permissive but programs tend to grow with time and this structure makes it easy to add new permissive conditions in the future. Although it is more work to create the program now, it is more maintainable in the future.

Next, we can do the same with the interlock conditions for the program.

Refactor to Check if all Interlocks are OK

When you are setting the name for a variable, you can also set the address of the variable in the memory. Each variable has a unique address in memory.

The last bit of refactoring to do is to add comments to the program. Comments are available in the Utils folder, called Note, and can be used to provide an explanation of what a part of a program is doing.

Finished Program with Comments

After updating the program, be sure to test it again to make sure that our refactoring didn't break any of the functionality that we programmed earlier.

Now that we have finished the PLC program, let's look at the challenges for this tutorial.


Challenge #1

Did you notice that both buttons that we added to the model are illuminated pushbuttons? That means that the buttons have a built-in light that can be controlled by a PLC.

Your first challenge is to control the button lights using the Start Button 0 (Light) and Stop Button 0 (Light) tags.

The Start Button Light should be on when the conveyor is running and the Stop Button Light should be off when the conveyor is stopped.

Don’t forget to organize your code well and leave a comment to explain what is happening in that section of the code!

Challenge #2

What happens if an operator presses the Start Button at the end of his shift?

The conveyor will run all day, wasting energy and causing unnecessary wear on the system.

To protect against this, use the TON Timer to create a maximum running time for the conveyor. The conveyor should only be able to run for 30 seconds before stopping.

This means that you now have three stopping conditions for the conveyor:

  • When the Stop button is pressed,
  • When the Sensor is triggered,
  • When the conveyor has been running for 30 seconds

If you want to learn more about how the TON Timer works, you can check the Factory I/O documentation here.

Wrap Up

In this tutorial, we learned how to create a seal-in circuit with permissive and interlock conditions to control a conveyor. This was an example of a more complex PLC program with Boolean logic and intermediate variables.

At the end of the tutorial, I introduced two challenges to test your PLC programming skills. If you haven't already, sign up to the mailing list below to be notified when the challenge solutions are available.

Finally, the project files for this tutorial are linked below.

Factory I/O with Control I/O

Take your PLC programming skills and build a portfolio of projects by programming solutions for 10 common industrial automation applications using Factory I/O and Control I/O, Factory I/O's built-in soft PLC.