The document describes how to add and set up MODBUS RTU sensors to work with TCW260 or TCG140-4 controllers.
1. MODBUS RTU forewords
Modbus is a serial communications protocol originally published by Modicon (now Schneider Electric) in 1979. The MODBUS RTU protocol uses a master-slave architecture over an RS-485 interface. Every system consists of one MODBUS RTU master (controller, PLC, PC, etc.) and at least one MODBUS RTU slave (sensor).
The communication between the master and slaves goes with standard messages. The MODBUS RTU message consists of an MB Address (slave address), Function code, Data, and CRC.
The MB Address should be unique for every slave device in the system. In other words, it is not allowed to use the same address for two or more slave devices – this will cause a mismatch in the communication.
According to the MODBUS RTU rules, the address can be a number in the range from 1 to 247.
Every manufacturer of MODBUS RTU sensors has its own system for address changing.
For all Teracom sensors, the address is changed over the interface, using the “Sensor setup tool” available in the controller. By default, the address is 1.
In addition to the MB address, during communication, the master uses the so-called register addresses. They indicate to the sensor which data exactly the master is interested in.
We can compare the MB Address as street name (number) while the register addresses as house numbers along that street.
For example, for the temperature sensor TST300, the temperature value is available in register number 100. So, if we have two TST300 sensors, one at MB Address 1 and another one at MB Address 2, to read their temperatures the master will use register number 100 for both of them. Pay attention that the MB addresses are different (mandatory), but the used register number for every sensor can be the same.
Every register has its own data length and order. These parameters should be specified by the manufacturer. They are essential for the MODBUS RTU master for the right data interpretation.
2. How to play with the MB Addresses of TST300 and TSH300 using TCW140-4
Before adding and set up more than one sensor on the Modbus interface, we should check/change their MB Addresses, to follow the rule for different addresses.
All new Teracom MODBUS RTU sensors are with the default address 1. If the sensors are not brand new, the good practice is to return them to their factory defaults. So, you can expect a collision if you connect both (TST300 and TSH300) sensors directly to the interface.
To check/change the MB Addresses we will use the “Sensor setup tool” available in the controller. The link to the tool is on the bottom of Setup->MODBUS RTU sensors page:
Attention! The “Sensor setup tool” should be used with one sensor only on the interface.
The “Sensor setup tool” consists of 3 paragraphs – “Communication setup”, “Sensor communication register setup”, and “Sensor register check”:
For MB Address check, the first paragraph only will be used, while for MB Address change first two paragraphs will be used.
In the “Communication setup” all necessary parameters for the sensor should be filled up. The algorithm of work is as follows:
First, the right bit rate, parity, and the number of stop bits are chosen. This information is available in the user manual of the sensor.
After this, we will use the scan tool to find the interface address of the sensor. It is recommended to use Time-out=100, First address=1, and Last address=247. Pressing the “Scan” button initiate the scanning process. As a result of the scan, the sensor address will be shown after the string “sensors with the following addresses:”.
If we want just to check the address of the sensor the above is enough.
If we want to make changes in the sensor, the found address should be written in the field “MB address”.
To have the possibility to read/write the sensors register, all 4 parameters on the left side of “Communication setup” paragraph must be correct.
Remember, the scan process is just a tool that helps you to find the address of the sensor. If you know the sensor’s address (after default procedure for example) you don’t need to execute it.
After the successful MB Address check, we can continue with MB Address change.
The algorithm of work is as follows:
According to the user manual of the sensor, the register for the MB Address is 10. This number should be written in the field “Address register #”. The new sensor address should be filled up in the “Value” field. For example, we want to change the address from 1 to 2, the “Value” field should be changed to 2.
Press the “Write” button.
To be sure that the address is changed press “Scan” button in “Communication setup” paragraph. If all is OK, the scan report will be “sensors with the following addresses: 2”.
3. How to add and setup TST300 and TSH300 to work with TCG140-4
After checking the MB Addresses of the sensors and we are sure that no collisions will occur due to the same addresses we can go to the actual adding and setting of the sensors in the controller.
This could be done on page Services->Modbus for TCG140-4 or equivalent for other controllers.
For the MODBUS RTU, the second and third paragraphs are used.
First, the right bit rate, parity, and the number of stop bits are chosen.
The scan tool can be used as an option. If we previously set up TST300 on MB Address 1 and TSH300 on MB Address 2, we know the addresses and scan tool is not necessary to be used.
From the user manual of TST300 we know that the temperature is available in the register with address 100, the format of data is “Float”, the order is “MSW first”, and the response time-out is 50mS.
So, combining all know the information we set up the first row as follows:
Press the button “Save”.
If all is done well, in the column “Raw value” the actual temperature will appear.
The same procedure is repeated for TSH300. The only difference is that we will read values from two registers.
From the user manual of TSH300 we know that the temperature is available in the register with address 100, the humidity is available in the register with address 102, the format of data is “Float”, the order is “MSW first”, and the response time-out is 50mS.
So, combining all know the information we set up the first row as follows:
Press the button “Save”.
If all is done well, the column “Raw value” will show the actual temperature and humidity.
With already installed sensors the monitoring page will look as follows:
The above procedures can be used for the third-party sensors too.