Difference between revisions of "ModbusRTUCom"
Line 67: | Line 67: | ||
Function code to first address digit relationship: | Function code to first address digit relationship: | ||
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | |Function Code | |
− | + | |First Address Digit | |
− | + | |- | |
− | + | |1,5,15 | |
− | + | |0 | |
− | + | |- | |
− | + | |- | |
− | + | |2 | |
− | + | |1 | |
− | + | |- | |
− | + | |- | |
− | + | |4 | |
− | + | |3 | |
− | + | |- | |
+ | |- | ||
+ | |3,6,16 | ||
+ | |4 | ||
+ | |- | ||
+ | |} | ||
+ | <br> | ||
<font size="4"><u>'''Code Samples'''</u></font> | <font size="4"><u>'''Code Samples'''</u></font> | ||
Revision as of 06:41, 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 Modbus 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.
40001
Forcing function code can be done as follows:
3:0001
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
Function code to first address digit relationship:
Function Code | First Address Digit |
1,5,15 | 0 |
2 | 1 |
4 | 3 |
3,6,16 | 4 |
Code Samples
Dim MyDriver as ModbusRTUCom