We are using MTConnect to update the status of an Ultra-precision CNC machine - FANUC ROBONANO
The code in action can be found at the Smart Manufacturing Website from MINLab (Manufacturing Innovation Network Laboratory).
- The adapter was cloned from the official MTConnect repository and augmented
- FOCAS2 was used to interface with the FANUC Controller
- The adapter and the agent were deployed on Raspberry Pis
- MQTT protocol was used to transfer data from the agent to the cloud (AWS)
- Topics were created for the following cases
- Data transfer to AWS Services
- Parameter Update from Cloud
- Device Shadow updates to initiate and stop the DAQ process
- Topics were created for the following cases
- By visiting the website, the data upload is initiated by clicking on the "Connect to Machine" button
- Machine
monitoring.py
-> Responsible for parsing and extracting the information from the XML document returned by the agent.
- MQTT
mqtt_callbacks.py
-> Contains functions for the MQTT callbacks.mqtt_device_shadows.py
-> Contains functions for the MQTT device shadows callbacks.
config.yml
-> Contains the configuration for the operation status update function.install_container.sh
-> Starts a container for the MTConnect agent. Refer to the MTConnect's GitHub repository (https://github.com/mtconnect/cppagent).main.py
-> The main file that handles the status update process.mtcagent.service
-> Service file for Linux automation. Enables the ability to automatically start the agent at reboot.mtcagent_mqtt.service
-> Service file for Linux automation. Automatically starts and restarts the script necessary for the status update over MQTT.start_daq.sh
-> Starts the status update process, along with performing a few cleanup tasks.stop_daq.sh
-> Stops the status update process smoothly.
- Ensure the agent is running (as a docker container or otherwise)
- Update the configuration file for the agent to identify the adapter correctly
- Update the configuration file in this repo (
config.yml
) with the right parameters - Configure the AWS appropriately
- IoT Core - To add things.
- Lambda function - For serverless approach to get the adapter's IP address if it is not static. Note: This might not apply to your case. With our case being a research lab under the University's network, we were not able to set a static IP for the edge devices due to some restrictions. Hence, we use AWS as an intermediary to handle the changes in the adapter's IP address over time. Not the best approach, but it is a temporary fix at the moment.
- AWS System's Manager setup for both the agent and the adapter to continuously monitor the device's status remotely
- Depending on how the MTConnect agent is setup, you need to install one or both the services (
mtcagent.service
,mtcagent_mqtt.service
) to the RaspberryPi to enable automatic start and stop at reboot, power loss, etc.- In our case, both the MTConnect agent and the Status Update run on the same device. Hence both the automation scripts were installed. The MTConnect agent runs in a Docker container. For more info, see https://github.com/mtconnect/cppagent
- If you need to run just the status update, install the service -
mtcagent_mqtt.service
, and ensure to update theconfig.yml
file to locate the MTConnect agent correctly.
Copy the service to the appropriate location
sudo cp ./mtcagent_mqtt.service /etc/systemd/system/
Enable the service to automatically start at boot
sudo systemctl enable mtcagent_mqtt
Start the service
sudo systemctl start mtcagent_mqtt
Stop the service for updates, if needed
sudo systemctl stop mtcagent_mqtt
Check the status of the service
sudo systemctl status mtcagent_mqtt
- For connecting to AWS-IotCore you will need the right certificates after creating a
thing
using the AWS console or command line. Check theconfig.yml
file for the location and directory info for placing AWS device certificates.
- Improving the ability of the system to handle errors.
- Elaborate set of error codes for troubleshooting
- Eliminate the need to use AWS lambda functions to get the adapter IP address.
- Improving the shadow document by providing more information on the device.
- Ability to automatically update the
upload_enable
parameter on the shadow document, in case of abrupt connection interruption. - Support for MTConnect streaming to continuously acquire data from the CNC machine using AWS Kinesis
If you have any questions or need more information, please reach out to the owner of the repository.