Modbus Master

Description

The Modbus Master Software Package provides Modbus RTU Master communication over RS232 or RS485 to a Modbus slave device. Holding registers are available to read and write in word, single, and double data types.

Using the Modbus Master Package

Use the "+" button on the console to select the Modbus Master Software package or File | Open the MMC Modbus Master to test the package in the provided test scaffolding:

The package is initialized in the main form setup routine:

If the parameter is true the pcakge is configured for RS485. If it is false it is configured for RS232. Communication is set to 9600,N,8,1.

Interface

The following procedures and functions are available:

WriteRegister(DeviceID,DataAddress,DataValue)
WriteSingle(DeviceID,DataAddress,DataValue)
WriteDouble(DeviceID,DataAddress,DataValue)
ReadReigster(DeviceID,DataAddress)
ReadSingle(DeviceID,DataAddress)
ReadDouble(DeviceID,DataAddress)

Escape Codes

The following escape code will occur for the indicated reasons:

1001 - Checksum Error
1002 - ReadReigster failure
1003 - ReadSingle failure
1004 - ReadDouble failure
1005 - WriteRegister failure
1006 - WriteSingle failure
1007 - WriteDouble failure
1008 - Address Out Of Bounds
1009 - Protocol pattern problem

Examples

The test scaffold provides examples of how the Modbus Master is used. The WriteRegister click procedure looks like this:

Note that references to procedures inside the ModbusMaster package must be prefixed with the package name using object oriented syntax. The ReadWord click procedure looks like this:

Contact Modusystems with questions regarding adjustments of the MMC Modbus Master that may be needed to suit a specific application.