User Tools

Site Tools


No renderer 'odt' found for mode 'odt'
mycnc:host_modbus_api

This is an old revision of the document!


Host Modbus API

Modbus Master API is implemented in myCNC software.

Host computer with myCNC able to read Input registers and write data Holding registers from/to modbus Slave device.

User API is available through the Software PLC.

Register Name Address Description
GVAR_XMODBUS_SERVER_ADDR 5750 Writing to this register sets Modbus Server Address
GVAR_XMODBUS_VALUE 5751 Writing to this register sets a Value that will be sent while write to Modbus Server
GVAR_XMODBUS_ADDR2READ 5752 Writing to this Register sets Address of Global register to put a result of Modbus Read operation
GVAR_XMODBUS_READY_READ 5753 Ready Read flag. The value is automatically cleared ion start of Modbus read operation.
If Read is finished successfully, the value is set to “1”.
If Read operation is failed, the value is set to “-1”.
GVAR_XMODBUS_WRITE 5755 Writing to this register initiates Modbus Write operation.
Written value is Modbus Server Register address (for Write).
A value defined in register 5751 will be sent
GVAR_XMODBUS_READ 5756 Writing to this register initiates Modbus Read operation.
Written value is a Modbus Server Register address (for Read).
Writing to this register will clear READY_READ register (5753). The READ_READY register value will be set to “1” when Read completed successfully. The READ_READY register will be set to “-1” if Read Error happens

Example: Need to write a value of “999” to Modbus Server Address #7 to register #25, then read register #24 and save it in glocal variable register #500

//Write
  gvarset(5750,7);  //Set Modbus Server Address
  gvarset(5751,99); //Set a value to write
  gvarset(5755,25); //Write to Modbus regsiter #25
 
//Read
  gvarset(5752,500); //Set Register #500 to receive Modbus Read result
  gvarset(5756,24);  //Read Modbus register #24
 
  do
  {
    //wait ready_ready
    timer++;
  }while(gvarget(5753)==0);
 
  if (gvarget(5753)<0)
  {
    exit(99); //Modbus Ready Error
  };
 
  a=gvarget(500); //Read modbus result can be used by reading redister #500
 
mycnc/host_modbus_api.1539556607.txt.gz · Last modified: 2018/10/14 18:36 by skirillov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki