mycnc:host_modbus_api
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
mycnc:host_modbus_api [2018/10/14 18:37] – skirillov | mycnc:host_modbus_api [2019/08/01 15:26] (current) – ivan | ||
---|---|---|---|
Line 10: | Line 10: | ||
| GVAR_XMODBUS_SERVER_ADDR | 5750 | Writing to this register sets **Modbus Server Address** | | | 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_VALUE | 5751 | Writing to this register sets a **Value** that will be sent while **write to Modbus Server** | | ||
- | | GVAR_XMODBUS_ADDR2READ | + | | GVAR_XMODBUS_RW_READY| 5752 | | |
| GVAR_XMODBUS_READY_READ | 5753 | Ready Read flag. The value is automatically cleared ion start of Modbus read operation. \\ If Read is finished successfully, | | GVAR_XMODBUS_READY_READ | 5753 | Ready Read flag. The value is automatically cleared ion start of Modbus read operation. \\ If Read is finished successfully, | ||
| 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_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 " | | 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 " | ||
+ | | 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. This will read the digital inputs/ | ||
+ | | GVAR_XMODBUS_READ | 5764 | Read Modbus register (specify the particular register to read such as 5764,0) | | ||
Line 46: | Line 49: | ||
</ | </ | ||
+ | **Another read/write example for WP9038ADAM with digital 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/ | ||
+ | |||
+ | <code c>main() | ||
+ | { | ||
+ | |||
+ | |||
+ | //Write | ||
+ | gvarset(5750, | ||
+ | gvarset(5752, | ||
+ | |||
+ | timer=0; | ||
+ | |||
+ | address=500; | ||
+ | gvarset(5761, | ||
+ | |||
+ | count=0; | ||
+ | do | ||
+ | { | ||
+ | gvarset(5761, | ||
+ | |||
+ | gvarset(5751, | ||
+ | gvarset(5756, | ||
+ | |||
+ | timer=3; | ||
+ | |||
+ | // Read Bits | ||
+ | gvarset(5763, | ||
+ | timer=3; | ||
+ | |||
+ | // Read Holding Registers | ||
+ | |||
+ | gvarset(5761, | ||
+ | gvarset(5764, | ||
+ | timer=3; | ||
+ | |||
+ | // Read Holding Registers | ||
+ | |||
+ | gvarset(5761, | ||
+ | gvarset(5764, | ||
+ | timer=3; | ||
+ | |||
+ | // Read Holding Registers | ||
+ | |||
+ | gvarset(5761, | ||
+ | gvarset(5764, | ||
+ | timer=3; | ||
+ | |||
+ | // Read Holding Registers | ||
+ | |||
+ | gvarset(5761, | ||
+ | gvarset(5764, | ||
+ | timer=3; | ||
+ | |||
+ | count++; | ||
+ | gvarset(507, | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | };</ | ||
+ | |||
+ | The specifications for the Modbus devices that are currently sold through the myCNC shop can be found here: | ||
+ | [[mycnc: |
mycnc/host_modbus_api.txt · Last modified: 2019/08/01 15:26 by ivan