Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:sw:01-mervis:weintek-ip-series-hidden [2021/08/05 12:54]
avsetula
en:sw:01-mervis:weintek-ip-series-hidden [2021/08/05 12:57] (current)
avsetula
Line 155: Line 155:
 In order to share the temperature over ModbusTCP, you need to configure ModbusTCP server channel. We have a tutorial ready for this as well: [[en:​sw:​01-mervis:​setting-modbus-server-hidden]]. In order to share the temperature over ModbusTCP, you need to configure ModbusTCP server channel. We have a tutorial ready for this as well: [[en:​sw:​01-mervis:​setting-modbus-server-hidden]].
  
-Now we need to clarify, what type of data we need to set in the Mervis ModbusTCP server. Modbus protocol knows only two types of data: 16bit registers for numeric values and 1bit "​coils"​ for state values. +Now we need to clarify, what type of data we need to set in the Mervis ModbusTCP server. Modbus protocol knows only two types of data: 16 bit registers for numeric values and 1 bit "​coils"​ for state values. 
-The temperature in the Mervis is represented as a real number - 32bit unsigned integer. To transfer this value via Modbus, we would need to split it into two 16bit registers and put them together on the HMI side, which is out of the scope of this tutorial. But we can convert the real temperature value to roughly fit the 16bit register. Let's assume we measure room temperature,​ where it can be in range of 0 - 40°C, and we want precision at least to 0.1°C. That means we need to cover values of 0 - 400. That can easilly fit into the 16bit register we have. Let's take a look, how to achieve it in FB diagram:+The temperature in the Mervis is represented as a real number - 32 bit unsigned integer. To transfer this value via Modbus, we would need to split it into two 16 bit registers and put them together on the HMI side, which is out of the scope of this tutorial. But we can convert the real temperature value to roughly fit the 16 bit register. Let's assume we measure room temperature,​ where it can be in range of 0-40 °C, and we want precision at least to 0.1 °C. That means we need to cover values of 0-400. That can easilly fit into the 16 bit register we have. Let's take a look, how to achieve it in FB diagram:
  
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_22_conversion_program.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_22_conversion_program.png?​direct |}}
Line 162: Line 162:
 On the input side, we have variable ''​sensor_temperature''​ which is the value of the 1-Wire sensor. On the output side we have variable ''​modbus_temperature''​ - that's the value exported by ModbusTCP server as holding register number 1. On the input side, we have variable ''​sensor_temperature''​ which is the value of the 1-Wire sensor. On the output side we have variable ''​modbus_temperature''​ - that's the value exported by ModbusTCP server as holding register number 1.
  
-The actual temperature if 26.8125°C. We multiply it by 10 in the ''​MUL''​ block to value 268.125. This value is type "​real"​ and we need co convert it to integer to fit the holding register type. The block ''​TO_UINT''​ converts any value to integer, and if the input value is less then 0, it will output 0 - hence the name **to unsigned integer**.+The actual temperature if 26.8125 °C. We multiply it by 10 in the ''​MUL''​ block to value 268.125. This value is type "​real"​ and we need co convert it to integer to fit the holding register type. The block ''​TO_UINT''​ converts any value to integer, and if the input value is less then 0, it will output 0 - hence the name **to unsigned integer**.
  
 We cheated the measured values a bit, but for our purposes, it works OK. Now we can export this variable in ModbusTCP server. In Mervis, double click on the ModbusTCP server device. We cheated the measured values a bit, but for our purposes, it works OK. Now we can export this variable in ModbusTCP server. In Mervis, double click on the ModbusTCP server device.