Seafoxc

Factory I/O is a simulation software to learn PLC programming. 
You can use OpenPLC to connect with the Modbus protocol to Factory I/O. 
This code is written to run the "production line" one of the Factory I/O scene's.  

Is used the OpenPLC Runtime on Windows for this project and the language is FBD. 

Factory IO post.jpg   

The line exist out of two CNC machine centers and some conveyers. The CNC centers look difficult but it is a lot easier then it seems. 

I made a small video (3:20min) to give you an idea what the code does. 

https://youtu.be/20qy7CKbF7E


Explanation program 

First I started with some good RTFM (Read The F***ng manual) about the machine center:  https://docs.factoryio.com/manual/parts/stations/

Then I opened the scene's and changed all the variables. 
I use a variable name based if it is an Input or Output, The location, The object and the function. 

I_ = Input
Q_ = Output
Z = Zone
MC = Machine Center
Sens = Sensor
Pb = Pushbutton
BC = Band Conveyer
RC = Roller Conveyer

So for example: I_Z01BC01ArrivedSens
is an input in Zone 1 and is the arrived sensor of Band Conveyer 01. 

I added the adjusted Scene to the ZIP file. 

Object oriented programming

You have a few objects in the program like the belt conveyers but there is not a lot of control for those in the scene (no manual switch not a lot of sensors) so I did not bother to write a Function block for that. I did made a function block for the Machine center. 

FB machine center.jpgSo both Machine centers use the same function block. 

This code can be improved upon to make it easier to spot mechanical or electrical failures but it is just for training and learning so I will put my time in solving the next scene's. 
 
How to run the code?

Factory I/O set-up

First of all you need Factory I/O (There is a free trail for 30 days without credit card) => Factoryio.com.


Then you unzip the file added to this post and you copy the scene "Production_Line_renamed_var.factoryIO" to the default location of the Factory I/O scene's. 

Documents\Factory IO\MyScenes

You open Factory I/O and open the scene and go to "drivers" (key "F4").

The mapping should be already made but some options should be checked/changed.


driver.jpg 

- Write down the IP address (to be entered in the settings for OpenPLC Runtime slave settings). 

Check the configuration (IP address and Network adaptor can be different). 


settings driver.jpg 

OpenPLC Runtime settings

 - Run Open PLC runtime and add a slave. 


OpenPLCRuntime settings.jpg

- Change the IP address to the same address as in Factory I/O settings. 

Make sure the addresses look like this:



slave good.jpg 

- Upload the OpenPLC runtime project "MachineCenter.st" (file from ZIP file). 
- Set the OpenPLC in Run
- Set Factory I/O in the play setting. 

 

In the Zip file there is also the OpenPLC editor file for you to change and take a look at. 

Let me know what you think if you downloaded it. 

If you are stuck on setting up Factory I/O with OpenPLC you can also find a video on how to do it on my YouTube Channel. 







I have no Idea what I'm doing...
Reply 3 0
thiagoralves
Yes, you can do anything you want with this, as long as you use Modbus to capture the data. Obviously you will have to build the program that consumes the data over Modbus and convert that to whatever format you want (like a csv for example)
Reply 0 0
Seafoxc
RexJustesen wrote:
Could you control the robotic arms in the scene with OpenPLC and then output the Accelerometer, gyroscope current and other data outside of the PLC to say a csv over modbus? Or could I even use a Siemens IPC and the modbus connector to send that data to the Siemens databus? 
You don't get data from the Robot arm like this from factory IO. The data you do get you can indeed log to a CSV file. Read the manual of the Machine Center in Factory IO to know which sensor data is available and Wich actuators are available.
I have no Idea what I'm doing...
Reply 0 0
Adnankhan
Respected Sir, I am new in this field I want to run the file but i have the following issue, how can i solve it. please guide me
[203128%2F8575591%2Fmceclip0]
Reply 0 0
thiagoralves
You must run OpenPLC runtime with sudo
Reply 1 0
Peterson
It stops after 3\4 details done.
Is there a logical error in OpenPLC program?
Reply 0 0
baskoinge
Good morning. I'm new to this, and when I load the program in Program Info and click Start PLC, I get the following message:
Internal server error
The server encountered an internal error and could not complete your request. Either the server is overloaded or there is an error in the application.
Could you help me?
Thank you.
Reply 0 0
thiagoralves
How are you loading the program into the runtime?
Reply 0 0
baskoinge
Hello, thank you for your reply.
I am doing as indicated in the post, but I am attaching the screenshots.
Captura de pantalla 2025-09-09 131650.png
Captura de pantalla 2025-09-09 131734.png
Captura de pantalla 2025-09-09 131842.png
[203128%2F9469250%2Fmceclip0]
[203128%2F9469251%2Fmceclip0]
Reply 0 0
thiagoralves
Your program has compilation errors. It will not run until you have fixed those errors. If you paste the full compilation output we might be able to help you sort it out.
Reply 0 0
baskoinge
[203128%2F9475761%2Fmceclip0]
[203128%2F9475762%2Fmceclip0]
[203128%2F9475763%2Fmceclip0]
[203128%2F9475764%2Fmceclip0]
[203128%2F9475765%2Fmceclip0]
[203128%2F9475766%2Fmceclip0]
Reply 0 0
thiagoralves
There was a problem with the Windows runtime after this latest update. Just rebase your runtime installation or reinstall the runtime and you will be good
Reply 0 0
baskoinge
I had already done this, but I reinstalled everything and it worked! Thank you very much!
Reply 2 0
baskoinge
Hi again, i have a problem with the VM. I have a Windows Machine in VmWare ESxI 8 However, despite having more memory, video, and other resources than my laptop, FactoryIO performs very poorly. In the image, you can see that it runs at 2 FPS and it is not possible to make the simulation work. I am also attaching the virtual configuration to see if you can help me. Thank you.
Reply 0 0
thiagoralves
You will not be able to run Factory IO on a VM with any decent performance. It requires a physical GPU to render the 3D graphics.
Reply 0 0
baskoinge
You will not be able to run Factory IO on a VM with any decent performance. It requires a physical GPU to render the 3D graphics.
Thank's, in my laptop the configuration is:
Captura de pantalla 2025-12-05 172744.png
And the performance is correct.
But I understand.
And the other issue in the scada is the nextone:
[203128%2F9595923%2Fmceclip0]
Do you know what is the problem?
Thnak's a lot!
Reply 0 0
Reply