This project showcases an HMI application that simulates the operation of an Offset printing machine running with a Modbus TCP/IP Server. This is a simplified simulation of an Offset printing machine used to demonstrate the capabilities of Modbus. Do note that we wrote this simulator not because we are specialists in the printing industry, but because we needed a portable simulator with a certain set of features.
The simulator was developed to work on Linux on both ARM and x86, in C++ with the QT Framework. It uses the libmodbus library for handling Modbus communication. Also, it is designed with a GUI for use with touchscreens, and a resolution 800x600 for the display.Software Setup
The application was developed in two parts. The first part consists of a library which is responsible for hosting the machine logic. It contains machines and components. The machine is the host for components, and they both can exchange messages. The machine can notify the components of its status (start/stop), and the components can notify the machine if they’re empty, in which case the machine needs to stop working. A conveyor belt is the most important component, as it is the one responsible for periodically pinging all the other components. One of the reasons is to change their count.
The second part is the QT Application. It has the library included as a dependency. It uses the simulators’ hooks and the Signal/Slot mechanism in QT to provide values from the simulator and interact with it. Similarly, the Modbus Server allows for interaction and monitoring of simulator values.
Deployment of the application is a step-by-step process, and we will go through it. The process consists of :
- Cloning the source code
- Installing all dependencies
- Building the application
- Doing additional hardware setup
We start by making the easiest step - cloning the source code for the application by doing the following:
git clone https://github.com/Wolkabout/offset-printing-machine-simulator-application.git --recurse-submodules
After we’re done, we need to install all the dependencies. The dependencies are listed below:
- gcc, make & cmake (>= 3.14)
- libpthread-stubs0-dev (pthread), libmodbus-dev (libmodbus)
- libqt4-dev, libqt4-dev-bin
You can do this in a much faster way - by executing the included shell script. This is available if you have access to apt and the snap store. Do the following:
If not, install the dependencies on your distributions respective package provider. Or, in the case of cmake (>= 3.14) and Raspberry Pi, compile it on your hardware.
After all the dependencies have been installed, you can finally build the application. To ease this process, we created a shell script that builds the application for you. Execute the following command:
After you’ve run the build script, you should have an executable ready to be executed, and moved to a folder /out. To run the application, type the next command:
And that’s it! The application is fully working! You will land on the main screen which looks like this:
You can see the controls on the bottom, where you have the back and home button. The logs button leads to the log screen, while the settings button leads to the settings screen.
Start demo button shows the main part of the application, the simulator.
On this screen, you can see the state the machine is in, together with all the controls. They are listed below:
- Causing simulated issues: paper jam and emergency stop
- Refilling the components
- Changing the speed of the machine
You can also reset the machine to the default state from the settings screen by pressing the button “Reset to Config”.Hardware Setup
Our hardware setup is set to a Compulab Fitlet2 IoT PC and IEI DM-F08A Industrial Monitor. Ubuntu 19.04 Desktop is installed on the drive. This specific composition requires the install of the Penmount Touchscreen driver.
What’s left to be done is some minor configuration of hardware on which we are running the application. There are a few steps that are necessary to complete the setup. Those include:
- Creating a xdg/autostart desktop entry
- Setup of the static IP address
To add the desktop autostart entry, copy the desktop file from the project's attachments to the /etc/xdg/autostart/ folder. This will show the effect the next time you reboot the computer.
And then continue setting up the static IP address. This is done in a few steps.
Go to the “Wired Settings” and then change the settings for the connected interface. You need to disable DHCP and set it to Manual. Set the Address, Netmask and Gateway. If you need to find these settings, look into your router settings. In most cases, the IP address is 192.168.0.x. So, generally, you’d want to take any free address between 192.168.0.1 and 192.168.0.255. Do note that the Netmask is 255.255.255.0 in most of the cases, and the Gateway is the address of the router, which is often 192.168.0.1.
After you have everything set up, you finally have a fully functioning simulator. It contains the working logic of an Offset printing machine, which you can access via Modbus through a GUI. We tested the Modbus with Modpoll and targeted specific registers linked here.
Next step would be to connect the device with a gateway, which is capable of actuating and polling data with Modbus and sending it to the Cloud. See how that is achieved in our other Hackster project here.
Do you have an IoT project in mind? Share it with the WolkAbout Community through Hackster.io. We’d love to see what you can do using WolkAbout IoT Platform!
If you need help developing it, we’ve got you covered! Read our team’s projects and stay tuned for the new ones.