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 http://www.modbus.org/specs.php).
The Modbus Protocol Device service needs to receive a valid Modbus configuration including the following parameters:
Table of Contents
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:
- 01 (0x01) readCoils(int unitAddr, int dataAddress, int count)
- 02 (0x02) readDiscreteInputs(int unitAddr, int dataAddress, int count).
- 03 (0x03) readHoldingRegisters(int unitAddr, int dataAddress, int count)
- 04 (0x04) readInputRegisters(int unitAddr, int dataAddress, int count)
- 05 (0x05) writeSingleCoil(int unitAddr, int dataAddress, boolean data)
- 06 (0x06) writeSingleRegister(int unitAddr, int dataAddress, int data)
- 15 (0x0F) writeMultipleCoils(int unitAddr, int dataAddress, boolean[ ] data)
- 16 (0x10) writeMultipleRegister(int unitAddr, int dataAddress, int[ ] data)

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:
- 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.
- 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.
- Select parity Even/ Odd/ None
- Stop bit must be 1

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

Modbus protocol mode –
There are two modbus protocol mode which is mostly used
- RTU or ASCII (only RTU mode for Ethernet connections).
- 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
- INVALID_CONFIGURATION
- NOT_AVAILABLE
- NOT_CONNECTED
- TRANSACTION_FAILURE
Summary:
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.