Difference between revisions of "Advantech Robotic Suite/Modbus-Master Node"
Eric.liang (talk | contribs) (Created page with " <br/> = Brief = Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates...") |
(No difference)
|
Revision as of 04:33, 30 January 2023
= Brief =
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems.
Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
Modbus-Master Node is a ROS node for user to subscribe sensor from client and report the data for post procedure.
Contents
Topic definition
The topic of Modbus-Master data are defined as below:/adv/modbusmaster
Message definition
The messages definition of SUSI node is defined in below link:
http://ess-wiki.advantech.com.tw/view/ROS2_Suite_Advantech_ROS2_Data_Format
Configuration
To config Modbus settings, please refer the guide: http://ess-wiki.advantech.com.tw/view/Modbus_Master#Configuration
Sample Client
This session describe how to subscribe Modbus-Master node data by node's topic.
Node.js
The program rclnodejs_edge_data_client is a node.js example for user to learning how to use rclnodejs client to subscribe Modbus-Master node's data. Please follow below steps to run the program, when the program launched, it will subscribe Modbus-Master node's sensor data and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Go to node.js Modbus-Master node sample client path:
$ cd /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/rclnodejs_edge_data_client/Step4. Run node.js Modbus-Master client:
$ node example_SubscribeSensor.js "rclnodejs_ModbusMaster_subscriber" "/adv/modbusmaster"Step5. Verify received data:
You have entered arguments:<br/> node name: rclnodejs_ModbusMaster_subscriber<br/> message topic: /adv/modbusmaster<br/> ----------------------------------------------<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Temperature", v = 21.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Door-Open", v = 1.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/FAN-Speed", v = 2814.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Humidity", v = 44.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Light-Switch", v = 0.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/>
Steps - Set sensor
This session describe how to set Modbus data by set action. To run the set sensor sample, your device need have writable sensor supported for Modbus driver.
Step1. Setup ROS2 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Go to node.js Modbus-Master node sample client path:
$ cd /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/rclnodejs_edge_data_client/
Step4. Run Modbus-Master node set sensor client:
Command:node example_SetSensor.js [node name] [action] [sensor] [type] [value]Example:
$ node example_SetSensor.js "rclnodejs_ModbusMaster_setter" "adv_modbusmaster_set" "Modbus-Master/Device/Sensor-Device-1/Sensor/FAN-Speed" "v" 3000Step5. Received data:
[INFO] [1671431728.320213435] [adv.rclnodejs_ModbusMaster_setter]: Waiting for action server...<br/> [INFO] [1671431729.034446428] [adv.rclnodejs_ModbusMaster_setter]: Sending goal request...<br/> [INFO] [1671431729.384845693] [adv.rclnodejs_ModbusMaster_setter]: Goal accepted<br/> [INFO] [1671431729.774134098] [adv.rclnodejs_ModbusMaster_setter]: Goal suceeded with result: 202<br/>
Python
The program rclpy_edge_data_client is a Python client example for user to understand how to use rclpy to subscribe Modbus-Master node's data. Please follow below steps to run the program, when the program launched, it will subscribe Modbus-Master node's sensor and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Setup Modbus-Master client:
$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bashStep4. Run Python Modbus-Master client:
$ ros2 run rclpy_edge_data_client listener "rclpy_ModbusMaster_subscriber" "/adv/modbusmaster"Step5. Verify received data:
You have entered arguments:<br/> node name: rclpy_ModbusMaster_subscriber<br/> message topic: /adv/modbusmaster<br/> ----------------------------------------------<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Temperature", v = 21.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Door-Open", v = 1.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/FAN-Speed", v = 2814.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Humidity", v = 44.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Light-Switch", v = 0.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/>
C++
The program rclcpp_susicontrol_client is a C++ example for user to understand how to use rclcpp to subscribe SUSI node's data. Please follow below steps to run the program, when the program launched, it will subscribe SUSI node's sensor and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Setup Modbus-Master client:
$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bashStep4. Run Python Modbus-Master client:
$ ros2 run rclcpp_edge_data_client listener "rclcpp_ModbusMaster_subscriber" "/adv/modbusmaster"Step5. Verify received data:
You have entered arguments:<br/> node name: rclcpp_ModbusMaster_subscriber<br/> message topic: /adv/modbusmaster<br/> ----------------------------------------------<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Temperature", v = 21.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Door-Open", v = 1.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/FAN-Speed", v = 2814.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Humidity", v = 44.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/> Data: sensor = "Modbus-Master/Device/Sensor-Device-1/Sensor/Light-Switch", v = 0.00<br/> Data: sensor = "Modbus-Master/Link/Net1/Message", sv = "Link connected"<br/> Data: sensor = "Modbus-Master/Link/Net1/Status", v = 1.00<br/>