Difference between revisions of "ModbusRTUCom"
m |
m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 42: | Line 42: | ||
<font size="4"><u>'''Addressing'''</u></font> | <font size="4"><u>'''Addressing'''</u></font> | ||
− | This driver uses the common | + | This driver uses the common Modicon style addressing scheme. The first digit determines the address space (function codes) to use. The remaining digits determine the offset. The address offset starts at 1, therefore to access register 0, you must use 1. |
− | + | The first digit of the address is used by the driver to determine which function codes to use. The following table shows the function code to first address digit relationship: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 90: | Line 69: | ||
|- | |- | ||
|} | |} | ||
+ | |||
+ | For example, a typical address would be one that used function code 3 to read with an offset of 0. This would be translated to the following: | ||
+ | |||
+ | ''40001'' | ||
+ | |||
+ | |||
+ | Double integers can be read by telling the driver to combine 2 registers by using a prefix "L". For example: | ||
+ | |||
+ | ''L40001'' | ||
+ | |||
+ | Note that since 2 registers are used, the register numbers will be every other number, such as L40001, L40003, L40005 | ||
+ | |||
+ | |||
+ | Floating point values are read using a prefix "F". For example: | ||
+ | |||
+ | ''F40001'' | ||
+ | |||
+ | As with double integers, floating point value also require 2 registers, therefore the register numbers must use every other register such as F40001, F40003, F40005 | ||
+ | |||
+ | By default, 16 bit integers are returned as signed integers. If you application requires unsigned integers, use the "U" prefix. For example: | ||
+ | |||
+ | ''U40001'' | ||
+ | |||
+ | If your device returns data in BCD and you want it to display as a normal integer, precede it with a "B". For example: | ||
+ | |||
+ | ''B40001'' | ||
+ | |||
+ | In certain scenarios you may not want the driver to determine the function code to use. In this case, you can force a specific function code as follows: | ||
+ | |||
+ | ''3:0001'' | ||
+ | |||
+ | |||
<br> | <br> | ||
<font size="4"><u>'''Code Samples'''</u></font> | <font size="4"><u>'''Code Samples'''</u></font> |
Latest revision as of 07:14, 14 August 2017
ModbusRTUCom
This driver implements the common ModbusRTU protocol as used by many PLCs as well as other devices such as VFD, temperature controllers, servos, etc.
Properties | |
---|---|
BaudRate | The Baud Rate to match that of the device |
DataBits | The serial communication data bit length. Options are 7 or 8 |
EnableLogging | Used as a troubleshooting tool only. When set to True, the driver will write all data bytes sent and received by the driver. |
DisableSubscriptions | uses updating of subscriptions. This is useful in cases such as when hiding a form and there is no longer a need to refresh the values. Or when used with a Trend Chart, it can pause the charting. |
PollRateOverride | This set the target rate for refreshing all of the subscriptions. When there are a large number of subscriptions that have to be split amongst sever requests, this value is divided by the number of requests required to determine the delay between each packet. A value of 0 will make the driver update as fast as the PLC will respond, but be cautious because it can reach rates less than 5ms and start to use a lot of resources. |
INIFileName | An INI file can be created to store the properties for being set during application startup. See INI File Usage for more details |
INIFileSection | Specifies the section within the INI file to use for this driver instance settings |
MaxReadGroupSize | When using subscriptions, the driver will optimize communications by grouping multiple subscriptions into a single read. The MaxReadGroupSize determines the largest number of registers to read in a single request. |
Methods
For the methods common to all drivers see the section on the IComComponent
No driver specific methods exist.
Addressing
This driver uses the common Modicon style addressing scheme. The first digit determines the address space (function codes) to use. The remaining digits determine the offset. The address offset starts at 1, therefore to access register 0, you must use 1.
The first digit of the address is used by the driver to determine which function codes to use. The following table shows the function code to first address digit relationship:
Function Code | First Address Digit | Data Type |
1,5,15 | 0 | Boolean |
2 | 1 | Boolean |
4 | 3 | 16 bit integer |
3,6,16 | 4 | 16 bit integer |
For example, a typical address would be one that used function code 3 to read with an offset of 0. This would be translated to the following:
40001
Double integers can be read by telling the driver to combine 2 registers by using a prefix "L". For example:
L40001
Note that since 2 registers are used, the register numbers will be every other number, such as L40001, L40003, L40005
Floating point values are read using a prefix "F". For example:
F40001
As with double integers, floating point value also require 2 registers, therefore the register numbers must use every other register such as F40001, F40003, F40005
By default, 16 bit integers are returned as signed integers. If you application requires unsigned integers, use the "U" prefix. For example:
U40001
If your device returns data in BCD and you want it to display as a normal integer, precede it with a "B". For example:
B40001
In certain scenarios you may not want the driver to determine the function code to use. In this case, you can force a specific function code as follows:
3:0001
Code Samples
Dim MyDriver as ModbusRTUCom