Modbus Server (Accessing robot data through the MODBUS server)

Modbus Server

 (Accessing robot data through the MODBUS server)


What is Modbus:

Modbus is a serial communications protocol. Simple and robust, it has since become a defacto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. The main reasons for the use of Modbus in the industrial environment are:
  • developed with industrial applications in mind,
  • openly published and royalty-free,
  • easy to deploy and maintain,
  • moves raw bits or words without placing many restrictions on vendors.

MODBUS is typically used in a SCADA system
(Example of MODBUS in a SCADA system)

Purpose:

Give read and write access to data in the robot controller for other devices

How it works:

The robot controller acts as a Modbus TCP server (port 502), clients can establish connections to it and send standard MODBUS requests to it.



Functionality:

- Several clients can connect to the server at the same time
- The server can respond to the following function codes:
  • 0x01: READ_COILS (read output bits)
  • 0x02: READ_DISCRETE_INPUTS (read input bits)
  • 0x03: READ_HOLDING_REGISTERS (read output registers)
  • 0x04: READ_INPUT_REGISTERS (read input registers)
  • 0x05: WRITE_SINGLE_COIL (write output bit)
  • 0x06: WRITE_SINGLE_REGISTER(write output register)
  • 0x0F: WRITE_MULTIPLE_COILS (write multiple output bits)
  • 0x10: WRITE_MULTIPLE_REGISTERS (write multiple output registers)
- The server will send a response to all requests
- The server responds error messages with exception codes:
  • 0x01: ILLEGAL_FUNCTION_CODE
  • 0x02: ILLEGAL_DATA_ACCESS (if the request address is illegal)
  • 0x03: ILLEGAL_DATA_VALUE (if the request data is invalid)

Process:

2. Connect socket with port 502



4. Encode the data that received to position, rotation, etc. from hex data to decimal
5. Convert the data to real position with this code :

if reg_xxx_i < 32768:
  reg_xxx_f = float(reg_xxx_i)/10if reg_xxx_i > 32767:
  reg_xxx_i = 65535 - reg_xxx_i
  reg_xxx_f = float(reg_xxx_i)/10*-1

Note : reg_xxx is variable that decode data is received from port map. 
If you need full code about Modbus please contract me 
>> terus_limsurut@hotmail.com 


ความคิดเห็น