User Tools

Site Tools

Translations of this page:

Sidebar

MyCNC Shop

MyCNC website

myCNC Price List

mycnc:host_modbus_api

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 with Address #7 to register #25,
  • then read register #24 and save it in global 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.txt · Last modified: 2018/10/14 18:37 by skirillov

Translations of this page: