Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:sw:01-mervis:weintek-ip-series-hidden [2020/05/12 14:43]
avsetula [UniPi as master, HMI as slave]
en:sw:01-mervis:weintek-ip-series-hidden [2021/08/05 12:57] (current)
avsetula
Line 1: Line 1:
 ====== Connecting Mervis IDE to Weintek HMI device using the ModbusTCP/​RTU protocol ====== ====== Connecting Mervis IDE to Weintek HMI device using the ModbusTCP/​RTU protocol ======
-In this tutorial, we are going to demonstrate how to connect the Weintek iP series HMI device with UniPi controller running Mervis.+<WRAP group> 
 +<WRAP half column 81%> 
 +In this tutorial, we are going to demonstrate how to connect the Weintek iP series HMI device with Unipi controller running Mervis.
  
-The goal of this tutorial is to display temperature measured by the 1-Wire temperature sensor connected to UniPi on the HMI display and have a touch button on the display that will turn the relay output of the UniPi ON and OFF.+The goal of this tutorial is to display temperature measured by the 1-Wire temperature sensor connected to Unipi on the HMI display and have a touch button on the display that will turn the relay output of the Unipi ON and OFF. 
 +</​WRAP>​ 
 +<WRAP half column 15%> 
 +;;# 
 +<​html><​span class="​dev-tag dev-patron">​Patron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-neuron">​Neuron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-gate">​Gate</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-unipi11">​Unipi&​nbsp1.1</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-axon">​Axon</​span></​html>​ 
 +;;# 
 +</​WRAP>​ 
 +</​WRAP>​
  
 <WRAP center round important 85%> <WRAP center round important 85%>
 Do you need to communicat over Ethernet? Our most recent news might be useful for you. Do you need to communicat over Ethernet? Our most recent news might be useful for you.
 Check out our new tutorial describing connection of a **[[en:​sw:​01-mervis:​weintek-hmi-bacnet-mervis-hidden|Weintek HMI to Unipi PLC through BACnet]]**, using Mervis IDE development environment. Check out our new tutorial describing connection of a **[[en:​sw:​01-mervis:​weintek-hmi-bacnet-mervis-hidden|Weintek HMI to Unipi PLC through BACnet]]**, using Mervis IDE development environment.
- 
 </​WRAP>​ </​WRAP>​
-===== Necessary equipment and setup ===== + 
-  * UniPi Neuron controller with [[en:​files:​software:​os-images:​00-start|Mervis OS]] installed+<WRAP center round box> 
 +<​html><​span class="​kbBlue-H4alt">​Prerequisites:</​span></​html>​ 
 +  * Unipi Neuron controller with [[en:​files:​software:​os-images:​00-start|Mervis OS]] installed
   * [[https://​www.unipi.technology/​hmi-devices-c29|Weintek HMI device]]   * [[https://​www.unipi.technology/​hmi-devices-c29|Weintek HMI device]]
-  * [[https://​www.unipi.technology/​power-supplies-c15|24V power supply]] +  * [[https://​www.unipi.technology/​power-supplies-c15|24 V⎓ power supply]] 
-  * 3 ethernet connections - one for UniPi controller, one for HMI and one for your PC +  * 3 ethernet connections - one for Unipi controller, one for HMI and one for your PC
- +
-In this tutorial, we will use:+
  
 +\\
 +<​html><​span class="​kbBlueText">​In this tutorial, we have used:</​span></​html>​
   * [[https://​www.unipi.technology/​unipi-neuron-l503-p105|Unipi Neuron L503]]   * [[https://​www.unipi.technology/​unipi-neuron-l503-p105|Unipi Neuron L503]]
   * [[https://​www.unipi.technology/​weintek-mt8051ip-p198|Weintek MT8051iP]]   * [[https://​www.unipi.technology/​weintek-mt8051ip-p198|Weintek MT8051iP]]
   * [[https://​www.unipi.technology/​1-wire-temperature-sensor-p63?​categoryId=3|1-Wire temperature sensor]]   * [[https://​www.unipi.technology/​1-wire-temperature-sensor-p63?​categoryId=3|1-Wire temperature sensor]]
 +</​WRAP>​
  
-**Wiring of the test setup**+== Wiring of the test setup ==
  
 {{:​en:​sw:​01-mervis:​infografika.png?​direct&​600|}} {{:​en:​sw:​01-mervis:​infografika.png?​direct&​600|}}
  
 ===== Installation of software ===== ===== Installation of software =====
-For basic configuration of the UniPi controller and installation of Mervis on your computer, please follow [[en:​sw:​01-mervis:​running-on-neuron-hidden|this guide]].+For basic configuration of the Unipi controller and installation of Mervis on your computer, please follow [[en:​sw:​01-mervis:​running-on-neuron-hidden|this guide]].
  
 For configuration of the HMI we need to install the Weintek EasyBuilder Pro. You can download the version used in this tutorial [[files:​software:​tools:​00-start#​weintek_easybuilder_pro|here]],​ or you can download the latest version from the [[http://​www.weintek.com/​|manufacturer'​s website]]. ​ For configuration of the HMI we need to install the Weintek EasyBuilder Pro. You can download the version used in this tutorial [[files:​software:​tools:​00-start#​weintek_easybuilder_pro|here]],​ or you can download the latest version from the [[http://​www.weintek.com/​|manufacturer'​s website]]. ​
Line 59: Line 74:
 In the **New Numeric Object** dialog, we will set some description. The description acts as a comment - it will not be displayed anywhere on the HMI device. In the **New Numeric Object** dialog, we will set some description. The description acts as a comment - it will not be displayed anywhere on the HMI device.
 Since we want to display the temperature,​ we can uncheck the **Allow input**. This will disable the ability of setting the value from touch display. Since we want to display the temperature,​ we can uncheck the **Allow input**. This will disable the ability of setting the value from touch display.
-The **Read address** box is for mapping the **Numeric** object to some variable or register. Because we haven'​t set the communication with UniPi yet, we will leave the **Read address** box as is. Therefor the new numeric object will display the content of local word (LW) variable number 0. Don't bother with this, this is just for demonstration.+The **Read address** box is for mapping the **Numeric** object to some variable or register. Because we haven'​t set the communication with Unipi yet, we will leave the **Read address** box as is. Therefor the new numeric object will display the content of local word (LW) variable number 0. Don't bother with this, this is just for demonstration.
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_09_setting_numeric.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_09_setting_numeric.png?​direct |}}
  
Line 72: Line 87:
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_12_first_simulation.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_12_first_simulation.png?​direct |}}
  
-So far we have created simple window, which displays a numeric value of some register. To make this tutorial little bit more versatile, let's learn, how to create a button, which - in the end - will operate relay output on our UniPi. To do this, we have to place new object onto the window canvas, called **Set bit**. On **Object** panel, click on the **Set bit**.+So far we have created simple window, which displays a numeric value of some register. To make this tutorial little bit more versatile, let's learn, how to create a button, which - in the end - will operate relay output on our Unipi. To do this, we have to place new object onto the window canvas, called **Set bit**. On **Object** panel, click on the **Set bit**.
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_13_adding_button.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_13_adding_button.png?​direct |}}
  
-In the **New Set Bit Object** dialog you can fill the comment. The comment will not be shown anywhere in the window, it is just for your better orientation in the project. The box **Write address** looks very similar to the **Read address** block we saw in the **New Numeric object**. But in this instance, we point the output value of the button (ON/OFF, TRUE/FALSE) to some **bit** variable. In numeric object, we pointed it to **word** variable. Since we still didn't configure connection to UniPi, we will leave it as is.+In the **New Set Bit Object** dialog you can fill the comment. The comment will not be shown anywhere in the window, it is just for your better orientation in the project. The box **Write address** looks very similar to the **Read address** block we saw in the **New Numeric object**. But in this instance, we point the output value of the button (ON/OFF, TRUE/FALSE) to some **bit** variable. In numeric object, we pointed it to **word** variable. Since we still didn't configure connection to Unipi, we will leave it as is.
 What we will change is the **Attribute**. This attribute sets how the button will output the value. We will change it to **Momentary**,​ which will make the button behave as a momentary switch. When the button is pressed (and hold), it will set the **Write address** register to 1 and when it is released, it will set the register to 0. What we will change is the **Attribute**. This attribute sets how the button will output the value. We will change it to **Momentary**,​ which will make the button behave as a momentary switch. When the button is pressed (and hold), it will set the **Write address** register to 1 and when it is released, it will set the register to 0.
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_14_bit_object_configuration.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_14_bit_object_configuration.png?​direct |}}
Line 101: Line 116:
 The only operation you have to do in the **Download** dialog is filling the IP address. Then hit **Download**. The HMI device will reboot and start your project. The result should look the same as in the simulation. The temperature will be 0 and pressing the button does nothing. The only operation you have to do in the **Download** dialog is filling the IP address. Then hit **Download**. The HMI device will reboot and start your project. The result should look the same as in the simulation. The temperature will be 0 and pressing the button does nothing.
  
-===== Communication between HMI and UniPi===== +===== Communication between HMI and Unipi===== 
-So far we have fully functional HMI design and now we have to connect it to UniPi. But first, we need to discuss the data exchange options we have.+So far we have fully functional HMI design and now we have to connect it to Unipi. But first, we need to discuss the data exchange options we have.
  
-The HMI device can communicate with UniPi via two different protocols:+The HMI device can communicate with Unipi via two different protocols:
   - ModbusTCP over ethernet   - ModbusTCP over ethernet
   - ModbusRTU over two wire RS485   - ModbusRTU over two wire RS485
Line 110: Line 125:
 In Modbus protocol, the communication is always initialized by the master (client) device. The slave (server) device responds to the commands issued by the master. Master is the one who reads data from slave, or writes data to slave. In Modbus protocol, the communication is always initialized by the master (client) device. The slave (server) device responds to the commands issued by the master. Master is the one who reads data from slave, or writes data to slave.
  
-Since the UniPi and Weintek iP series HMI can act both as a master and slave, we have to decide which way to go. That depends on your application and overall logic of your system. In this tutorial, we will investigate both options and demonstrate the pros and cons.+Since the Unipi and Weintek iP series HMI can act both as a master and slave, we have to decide which way to go. That depends on your application and overall logic of your system. In this tutorial, we will investigate both options and demonstrate the pros and cons.
  
-==== UniPi as master, HMI as slave ==== +==== Unipi as master, HMI as slave ==== 
-This is the traditional data exchange method. PLC downloads data from Modbus slaves (UniPi extensions, energy meters,​...),​ decides what to do and then uploads the data to the slaves.+This is the traditional data exchange method. PLC downloads data from Modbus slaves (Unipi extensions, energy meters,​...),​ decides what to do and then uploads the data to the slaves.
  
 **Pros:** **Pros:**
Line 120: Line 135:
 **Cons:​** ​ **Cons:​** ​
   * The HMI has to be configured in Mervis as a Modbus slave device with complicated parsing of data   * The HMI has to be configured in Mervis as a Modbus slave device with complicated parsing of data
-  * The HMI doesn'​t have easy method to check, whether the connection to UniPi is running and the registers contain up-to-date data+  * The HMI doesn'​t have easy method to check, whether the connection to Unipi is running and the registers contain up-to-date data
    
-==== HMI as master, ​UniPi as slave ==== +==== HMI as master, ​Unipi as slave ==== 
-In this setup, the data exchange between HMI and UniPi is initiated by the HMI device. The HMI reads the temperature from UniPi, which shares this information via its ModbusTCP Server register.+In this setup, the data exchange between HMI and Unipi is initiated by the HMI device. The HMI reads the temperature from Unipi, which shares this information via its ModbusTCP Server register.
  
-Pros:+**Pros:**
   * HMI can detect broken connection and act accordingly   * HMI can detect broken connection and act accordingly
   * Easier setup on the Mervis side   * Easier setup on the Mervis side
-Cons:+**Cons:**
   * On RS485 connection only one device can act as a master. If the PLC is already a master, you have to use another RS485 connection to HMI   * On RS485 connection only one device can act as a master. If the PLC is already a master, you have to use another RS485 connection to HMI
  
 For the rest of the tutorial, we will use this method. For the rest of the tutorial, we will use this method.
  
-===== Setting up the UniPi for sharing temperature and relay output ===== +===== Setting up the Unipi for sharing temperature and relay output ===== 
-For the purposes of our demonstration,​ we need UniPi controller running Mervis. You can find all the necessary information in our [[en:​sw:​01-mervis|Mervis section]].+For the purposes of our demonstration,​ we need Unipi controller running Mervis. You can find all the necessary information in our [[en:​sw:​01-mervis|Mervis section]].
  
 Next thing we need to configure is the temperature reading from 1-Wire temperature sensor. You can find it [[en:​sw:​01-mervis:​attaching-1-wire-devices-hidden|here]] how to do so. Next thing we need to configure is the temperature reading from 1-Wire temperature sensor. You can find it [[en:​sw:​01-mervis:​attaching-1-wire-devices-hidden|here]] how to do so.
Line 140: 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 |}}
  
 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.
Line 169: Line 185:
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_29_mapped_variable.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_29_mapped_variable.png?​direct |}}
  
-Deploy the solution and start the UniPi controller in **Full mode**.+Deploy the solution and start the Unipi controller in **Full mode**.
  
 ===== Setting the HMI to read data from Mervis ===== ===== Setting the HMI to read data from Mervis =====
Line 190: Line 206:
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_34_ip_address_settings.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_34_ip_address_settings.png?​direct |}}
  
-Now that we have the connection configured, we need to point the **Numeric** and **Set bit** objects to the correct devices and registers. Double click on the temperature **Numeric** object. In the **Numeric Object'​s Properties** dialog, select the UniPi controller in the **Device** drop down menu.+Now that we have the connection configured, we need to point the **Numeric** and **Set bit** objects to the correct devices and registers. Double click on the temperature **Numeric** object. In the **Numeric Object'​s Properties** dialog, select the Unipi controller in the **Device** drop down menu.
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_36_select_the_plc.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_36_select_the_plc.png?​direct |}}
  
Line 205: Line 221:
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_41_correct_temperature_format.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_41_correct_temperature_format.png?​direct |}}
  
-The last missing step is the address on the button. Double click the button and on the **Set Bit Object'​s Properties** change the **Write address** device to the UniPi controller, **Address** to **0x** which is a designation of "​coil"​ and the coil number leave at **1**.+The last missing step is the address on the button. Double click the button and on the **Set Bit Object'​s Properties** change the **Write address** device to the Unipi controller, **Address** to **0x** which is a designation of "​coil"​ and the coil number leave at **1**.
 {{ :​en:​hw:​04-hmi:​weintek_ip_series_42_set_bit_attribute.png?​direct |}} {{ :​en:​hw:​04-hmi:​weintek_ip_series_42_set_bit_attribute.png?​direct |}}