You are currently viewing How to use modbus protocol in embedded system
how to use modbus protocol

How to use modbus protocol in embedded system

Spread the love

We know that importance of can and modbus protocol. if you don’t know about this communication protocol then click on hyperlink.

Modbus Protocol Device is a service that provides a connection using Serial communication (RS-485) or Ethernet using the Modbus protocol. for more more information
The Modbus Protocol Device service needs to receive a valid Modbus configuration including the following parameters:

Basic steps to use modscan protocol in embedded

Step 1st: You should need to first download modscan 32 software

official modscan 32 website

Step 2d: Modscan interface look like this

The following function codes are implemented for Modbus Protocol Device protocol:

  1. 01 (0x01) readCoils(int unitAddr, int dataAddress, int count)
  2. 02 (0x02) readDiscreteInputs(int unitAddr, int dataAddress, int count).
  3. 03 (0x03) readHoldingRegisters(int unitAddr, int dataAddress, int count)
  4. 04 (0x04) readInputRegisters(int unitAddr, int dataAddress, int count)
  5. 05 (0x05) writeSingleCoil(int unitAddr, int dataAddress, boolean data)
  6. 06 (0x06) writeSingleRegister(int unitAddr, int dataAddress, int data)
  7. 15 (0x0F) writeMultipleCoils(int unitAddr, int dataAddress, boolean[ ] data)
  8. 16 (0x10) writeMultipleRegister(int unitAddr, int dataAddress, int[ ] data)
How to connect modscan step by step
How to connect modscan step by step

Highlight box show you message (Device Not Connected ). If device is not connected to modscan then msg appear like this.

Step 3rd: If we need to connect device to modscan then follow below steps:

  1. Select connection , in this case we select TCP/IP connection if you want to connect device directly or you connect device directly using COM Port then select specific COM Port.
  2. Select Baud rate in my case i select 19200 baud rate . Note that basically we defined baud rate on the basic of communication distance i.e. for short distance 19200 and for long distance 9600.
  3. Select parity Even/ Odd/ None
  4. Stop bit must be 1
connection of tcp in modscan
connection of tcp in modscan

Step 4th: Below windows show flat steps in modbus communication

  1. Address is one of the most important parameter in communication it depends on modbus communication types
  2. In Master slave combination . ID FR MASTER IS 1
  3. Length is basically depends on user How much length want to read
  4. Modbus point types 01: Coil Register 02: Input register 03: Holding Register 04: Input register
Important steps in modbus communication
Important steps in modbus communication

Modbus protocol mode –

There are two modbus protocol mode which is mostly used

  1. RTU or ASCII (only RTU mode for Ethernet connections).
  2. TCP/IP mode

Timeout parameter – sets the timeout in order to detect or disconnected device.

  • For serial line connection following valid point required
  • port name
  • baudrate
  • bits
  • stops
  • parity
  • similar for ethernet
  • Ethernet
  • ip address
  • port number

Exceptions in Modbus protocol



In this article we saw How to use modbus protocol in embedded system so about this article you have any query then free to ask me.

sachin Pagar

I am Mr. Sachin pagar Embedded software engineer, the founder of Sach Educational Support(Pythonslearning), a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Reply