Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:sw:01-mervis:connecting-to-modbus-slave-device-hidden [2020/06/15 14:32] – [Connecting to Modbus slave] avsetula | en:sw:01-mervis:connecting-to-modbus-slave-device-hidden [2021/08/05 12:25] (current) – avsetula | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| <WRAP half column 15%> | <WRAP half column 15%> | ||
| ;;# | ;;# | ||
| - | < | + | < |
| < | < | ||
| - | < | + | < |
| + | < | ||
| + | < | ||
| ;;# | ;;# | ||
| </ | </ | ||
| Line 56: | Line 58: | ||
| {{ : | {{ : | ||
| - | The values in Modbus slave devices are " | + | The values in Modbus slave devices are " |
| It is time to introduce our ModbusRTU device, from which we want to read the data: The Inepro PRO1-Mod energy meter. | It is time to introduce our ModbusRTU device, from which we want to read the data: The Inepro PRO1-Mod energy meter. | ||
| Line 70: | Line 72: | ||
| Unfortunately, | Unfortunately, | ||
| - | As you can see, the register' | + | As you can see, the register' |
| The Mervis IDE accepts only decimal values for Modbus registers, so you need to manually convert the ones from the manual, e.g. with calculator application in Windows or in MS Excel. | The Mervis IDE accepts only decimal values for Modbus registers, so you need to manually convert the ones from the manual, e.g. with calculator application in Windows or in MS Excel. | ||
| Line 86: | Line 88: | ||
| {{ : | {{ : | ||
| - | A new group called **Group** will appear and also three other **datapoints** were created. Click on the row with name **Group** and in the **Properties panel**, change the **Name** to something more descriptive. We picked the range of original addresses according to the manual (5000 - 5000B). In the **Modbus Group Parameters** we need to specify the number of the first register, or as it is called here **Starting Element**. As we calculated above, the **Starting Element** for register **Voltage** is 20481. The Modbus function is **F03 Read Holding Registers**. The **Quantity of Elements** is a number of registers we want to read from the slave device into this group for later processing into datapoints. Select 12, because we want to read the **Voltage**, | + | A new group called **Group** will appear and also three other **datapoints** were created. Click on the row with name **Group** and in the **Properties panel**, change the **Name** to something more descriptive. We picked the range of original addresses according to the manual (5000-5000B). In the **Modbus Group Parameters** we need to specify the number of the first register, or as it is called here **Starting Element**. As we calculated above, the **Starting Element** for register **Voltage** is 20481. The Modbus function is **F03 Read Holding Registers**. The **Quantity of Elements** is a number of registers we want to read from the slave device into this group for later processing into datapoints. Select 12, because we want to read the **Voltage**, |
| {{ : | {{ : | ||
| Line 128: | Line 130: | ||
| To be able to continue with the tutorial, you need to fully understand, what we did with the **Voltage** and how to represent different data types in Modbus. | To be able to continue with the tutorial, you need to fully understand, what we did with the **Voltage** and how to represent different data types in Modbus. | ||
| - | The Modbus knows only 16bit registers (forget about the " | + | The Modbus knows only 16 bit registers (forget about the " |
| - | But if you need to exchange data type with slave, which needs more then 16bit of space, you need to use more than 1 Modbus register and then do the transformation of data in the Mervis. This is what we did with the **Voltage**. The **Voltage** is a real number which needs 32bit space. In the Inepro manual, you can see the data type is " | + | But if you need to exchange data type with slave, which needs more then 16 bit of space, you need to use more than 1 Modbus register and then do the transformation of data in the Mervis. This is what we did with the **Voltage**. The **Voltage** is a real number which needs 32 bit space. In the Inepro manual, you can see the data type is " |
| - | This parsing of multiple registers into datapoint (variable) is done on two levels. First, we need to tell the Mervis to read more registers at once. This is done on the **Group** level. We specified **the first register number** we want to read (the **Starting Element**) and the number of registers we want to read from this number (the **Quantity of Elements**). As you can check above, we started reading from the register number 20481 and we read 12 consecutive | + | This parsing of multiple registers into datapoint (variable) is done on two levels. First, we need to tell the Mervis to read more registers at once. This is done on the **Group** level. We specified **the first register number** we want to read (the **Starting Element**) and the number of registers we want to read from this number (the **Quantity of Elements**). As you can check above, we started reading from the register number 20481 and we read 12 consecutive |
| Next thing we did, is that we specified the **Voltage** datapoint. We pointed this datapoint to the group, so it will be taking data from this group and transform it to some variable. To tell exactly, which data from the group the datapoint should use, we configured the **Modbus Data Point Parameters**. For reading data from group to datapoint, you need to set the **Data Offset (Parser)** and the **Multibyte Length (Parser)**. | Next thing we did, is that we specified the **Voltage** datapoint. We pointed this datapoint to the group, so it will be taking data from this group and transform it to some variable. To tell exactly, which data from the group the datapoint should use, we configured the **Modbus Data Point Parameters**. For reading data from group to datapoint, you need to set the **Data Offset (Parser)** and the **Multibyte Length (Parser)**. | ||
| - | The **Data Offset (Parser)** indicates the first **byte** (not register!) from the group, and the **Multibyte Length (Parser)** is a number of **bytes** to parse into this variable. As you can check, we selected first 4 bytes from the group (Data Offset = 0, Multibyte Length = 4), which corresponds with 2 registers (4*8bit = 2*16bit). And by setting the **ST Type**, we set the transformation of this 32bit data space into a real number. It sounds a quite complicated, | + | The **Data Offset (Parser)** indicates the first **byte** (not register!) from the group, and the **Multibyte Length (Parser)** is a number of **bytes** to parse into this variable. As you can check, we selected first 4 bytes from the group (Data Offset = 0, Multibyte Length = 4), which corresponds with 2 registers (4*8 bit = 2*16 bit). And by setting the **ST Type**, we set the transformation of this 32 bit data space into a real number. It sounds a quite complicated, |
| So let's add another datapoint - **Grid frequency**. As you can see from the Modbus register' | So let's add another datapoint - **Grid frequency**. As you can see from the Modbus register' | ||
| Line 145: | Line 147: | ||
| * The **Comm. Value Mapped Type** is **Builtin** and the **ST Type** is **real** | * The **Comm. Value Mapped Type** is **Builtin** and the **ST Type** is **real** | ||
| * The **Data Offset (Parser)** = (address of the register - address of the first register in group) * 2 = (5008H-5000H) * 2 = 16 | * The **Data Offset (Parser)** = (address of the register - address of the first register in group) * 2 = (5008H-5000H) * 2 = 16 | ||
| - | * The **MultiByte Length (Parser)** is 4 (4 bytes = 2 16bit registers) | + | * The **MultiByte Length (Parser)** is 4 (4 bytes = 2 16 bit registers) |
| Because we added new datapoint, you need to run the **Set Autogen** on the device. Then **Deploy** the solution, turn on the **Debugging** mode and switch to **Variable Browser** tab in **Main window**. In the browser, search for the **energyMeterL1**. You should see this: | Because we added new datapoint, you need to run the **Set Autogen** on the device. Then **Deploy** the solution, turn on the **Debugging** mode and switch to **Variable Browser** tab in **Main window**. In the browser, search for the **energyMeterL1**. You should see this: | ||
| {{ : | {{ : | ||