In this simple Side Project, I wanted to use both my knowledge in Control engineering and my Data wrangling skills together, by making a Power Bi report that get Live (almost) data from a Factory IO scene where this scene is also controller by Siemens PLCSIM program.
Simply put, I'm doing simple box sorting based on box weight then recording data (weight, time) in a CSV file, then read this CSV file by Power Bi desktop, do some data transform then create Visuals. the last part of this Side project is extra step.
I added a panel and placed some 1 emergency stop Button and a Start Button, I also added a Digital display to show Box weight and lastly I put a stacked light on top of the panel
On Factory IO, I chose PLCSIM to Simulate the PLC and setup Inputs (sensors) and outputs (actuators) as follows (apologies, I'm terrible at naming I/O so I kind of kept most as default )
Depending on its weight, each Box will be moved to a different direction. since I'm only interested in recording box weight and counting the number of boxes, I didn't complete the scene after the sorting phase.
Well, I know there is a scene template in Factory I/O that has the box sorter by weight too, but at the time of the making, I didn't know that, so I'm just documenting my learning journey that's all :)
I used a time to wait for the box to move past the turn table and then return the table 90° in the opposite direction
The Scale_func function below allow us to read voltage value from the weight scale sensor and convert it to weight unit
The move function will send the weight value to the digital display in Factory I/O.
Finally I added the emergency button and Green light , red light indicators.
Factory I/O starting from version 2.4.6 offer new feature which allows users to send HTTP request and receive a variety of data on the scene they are working on, including the Tags , values, name of Inputs and Outputs...
Learn more from their official documentation: Factory I/O Docs
to receive data from factory IO, I setup a simple local web server using Node.js express library and started sending request to Factory I/O every 400ms to get name and values for all the tags.
The createCsvWriter will create a csv with the column titles as set in the code below, in addtion to box weight I wanted to add if there was an malfunctioning component or sensor, Factory IO can have that , but I didn't know how to make use of it so I ended up using only weight and time information in Power Bi
Then using the app.web_server = True command in Factory I/O's console In order to establish communication between Factory I/O and server. Default Port N° is 7410
Once the data is received on the Back-end server I appended it to a CSV file so that each line represent a Box that was sorted. as shown above
Next, comes Power Bi:
I will import the data and choose source as CSV and then apply a little data Transformation to make it ready for visuals
Import Data source to Power Bi (in our case, it's a CSV file)
I added a Column to convert Epoch timestamp to a regular date format to use in report visuals
One more Transformation is adding a column to classify Boxes based on their weight Value using DAX in Power Query of Power Bi
and now for the report visuals, the visual shown below are simply for demonstrating the method of using Power Bi to handle data from Factory I/O.
Now, I'm not using the Premium version of Power Bi, so in order to see the latest data on the report, I'll just click refresh when I open the report file
I wanted to take it a step further because why not :) , so the Idea is to get a Chat Bot to talk to us and know about the process, so stakeholders can ask it some questions and the chat bot reaches to Database to retrieve latest information stored or even generate a simple report.
On a local industrial network setting, it can know who is on duty for particular day, and managers can use it to send notifications about maintenance schedules
For this chat bot , I will be using PostgreSQL database because it's easier to query and extract data from on Node Js compared to a CSV file.
The getPostGres_data function will query the data from postgreSQL and return results, we are going to use it to get the Number of rows (aka the number of boxes sorted).
Note ::I'm still using the same backend application for this one.
Asking for how many boxes will call the function above to get the count of rows from PostgreSQL database
This a proof of concept application and I would love to hear what you guys think about this, and any good use case or good Factory I/O project that would be awesome if we used something like this.
My aim is always to keep applying what I learned in both Control systems and Data Analysis.