■ Explanation
This is a sample program of Modbus/RTU master created in C++, C#, and VB.Net.
Modbus/RTU communication can be executed by specifying the COM port, setting the baudrate and parity etc.
■ Screen Image
■ Step to Use
Function Code |
Button Name (Function Name) |
---|---|
ReadCoils (FC 1) |
modbus_read_bits |
ReadDiscreteInputs (FC 2) |
modbus_read_input_bits |
ReadHoldingRegisters (FC 3) |
modbus_read_registers |
ReadInputRegisters (FC 4) |
modbus_read_input_registers |
WriteCoil (FC 5) |
modbus_write_bit |
WriteRegister (FC6) |
modbus_write_register |
WriteMultipleCoils (FC15) |
modbus_write_bits |
WriteMultipleRegisters (FC16) |
modbus_write_regsiters |
Data format for sending and receiving is as follows.
- Send Data (Hex)
Example) 01 0D AD
- Receive Data (Hex)
Example) 01 0D AD
- Send Data (Bin)
Example) 0 1 1
- Receive Data (Bin)
Example) 0 1 1
In this sample, the maximum number of reading is 2000 bits / 125 words, and the maximum number of writing is 1968 bits / 123 words.
* This is the maximum value of the Modbus specifications.