User Tools

Site Tools


mycnc:host_modbus_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mycnc:host_modbus_api [2019/07/29 15:18] ivanmycnc:host_modbus_api [2019/08/01 15:26] (current) ivan
Line 15: Line 15:
 | 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 | | 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 |
 | GVAR_XMODBUS_ADDR2READ | 5761 | Writing to this Register sets **Address of Global register** to put a result of **Modbus Read** operation | | GVAR_XMODBUS_ADDR2READ | 5761 | Writing to this Register sets **Address of Global register** to put a result of **Modbus Read** operation |
-|GVAR_XMODBUS_READ_INPUT_BITS | 5763 | Read the input bits |+|GVAR_XMODBUS_READ_INPUT_BITS | 5763 | Read the input bits. This will read the digital inputs/outputs in the  |
 | GVAR_XMODBUS_READ | 5764 | Read Modbus register (specify the particular register to read such as 5764,0) | | GVAR_XMODBUS_READ | 5764 | Read Modbus register (specify the particular register to read such as 5764,0) |
  
Line 49: Line 49:
 </code> </code>
  
-**Another read/write example for WP9038ADAM**:+**Another read/write example for WP9038ADAM with digital inputs/outputs and analog inputs** 
 + 
 +The analog inputs in this example are the holding registers, while the bits are the digital inputs and outputs which are dealt with through read/write commands. The code is using a 3 ms delay in order to loop the timer and to allow the Modbus device to receive/send all the necessary commands. 
 <code c>main() <code c>main()
 { {
Line 56: Line 59:
 //Write //Write
   gvarset(5750,34);  //Set Modbus Server Address (device ID is set to be 34 in this case)   gvarset(5750,34);  //Set Modbus Server Address (device ID is set to be 34 in this case)
-  gvarset(5752,1);  //Address to store read value+  gvarset(5752,1);  //Indicator whether the operation is complete (0 for complete, 1 for not complete)
  
   timer=0;    timer=0; 
Line 79: Line 82:
 // Read Holding Registers // Read Holding Registers
  
-  gvarset(5761,address+1);  //Address to store read value will be 501+  gvarset(5761,address+1);  //Address to store read value will be variable 501
   gvarset(5764,0);  //Read Modbus register #0   gvarset(5764,0);  //Read Modbus register #0
   timer=3;do{timer--; }while(timer>0);    timer=3;do{timer--; }while(timer>0); 
Line 85: Line 88:
 // Read Holding Registers // Read Holding Registers
  
-  gvarset(5761,address+2);  //Address to store read value will be 502+  gvarset(5761,address+2);  //Address to store read value will be variable 502
   gvarset(5764,1);  //Read Modbus register #1   gvarset(5764,1);  //Read Modbus register #1
   timer=3;do{timer--; }while(timer>0);    timer=3;do{timer--; }while(timer>0); 
Line 91: Line 94:
 // Read Holding Registers // Read Holding Registers
  
-  gvarset(5761,address+3);  //Address to store read value will be 503+  gvarset(5761,address+3);  //Address to store read value will be variable 503
   gvarset(5764,2);  //Read Modbus register #2   gvarset(5764,2);  //Read Modbus register #2
   timer=3;do{timer--; }while(timer>0);    timer=3;do{timer--; }while(timer>0); 
Line 97: Line 100:
 // Read Holding Registers // Read Holding Registers
  
-  gvarset(5761,address+4);  //Address to store read value will be 504+  gvarset(5761,address+4);  //Address to store read value will be variable 504
   gvarset(5764,3);  //Read Modbus register #3   gvarset(5764,3);  //Read Modbus register #3
   timer=3;do{timer--; }while(timer>0);    timer=3;do{timer--; }while(timer>0); 
Line 109: Line 112:
 };</code> };</code>
  
 +The specifications for the Modbus devices that are currently sold through the myCNC shop can be found here: 
 +[[mycnc:modbus_devices|Modbus Devices available]]
mycnc/host_modbus_api.txt · Last modified: 2019/08/01 15:26 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki