User Tools

Site Tools


mycnc:modbus_setup

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
Next revisionBoth sides next revision
mycnc:modbus_setup [2019/07/29 15:53] ivanmycnc:modbus_setup [2020/01/27 11:42] ivan
Line 43: Line 43:
 Using the I/O Expand cards mapping window allows for a guaranteed signal delivery even if the Modbus device was turned off when the initial signal was sent (for example, when changing the Binary Outputs status from OFF to ON in the System Diagnostics window). However, a certain amount of latency (up to 100-200 ms) is introduced, as the system has to regularly loop through and check for the inputs/outputs on the Modbus device. Therefore, using I/O expansions via a Modbus device is recommended on systems which are less time-critical.  Using the I/O Expand cards mapping window allows for a guaranteed signal delivery even if the Modbus device was turned off when the initial signal was sent (for example, when changing the Binary Outputs status from OFF to ON in the System Diagnostics window). However, a certain amount of latency (up to 100-200 ms) is introduced, as the system has to regularly loop through and check for the inputs/outputs on the Modbus device. Therefore, using I/O expansions via a Modbus device is recommended on systems which are less time-critical. 
  
-**NOTE:** The latency becomes larger when more mapping devices are introduced, as the system loops through each such device one at a time. +**NOTE:** The latency will increase as more mapping devices are introduced, as the system loops through each such device one at a time. 
  
 ====Using Modbus through PLC commands==== ====Using Modbus through PLC commands====
Line 56: Line 56:
 ====Modbus Devices available==== ====Modbus Devices available====
 The detailed description of the available Modbus devices is located at the [[mycnc:modbus_devices|Modbus Devices]] page. The detailed description of the available Modbus devices is located at the [[mycnc:modbus_devices|Modbus Devices]] page.
 +
 +====Sample M03 procedure for Spindle ON through Modbus====
 +
 +++++ Expand M03 code |
 +
 +<code>#include pins.h
 +#include vars.h
 +
 +#define command   var00
 +#define parameter var01
 +
 +// =======================================================================
 +//SPINDLE_ON_CW_VALUE  should be redefined according to VFD specification
 +#define SPINDLE_ON_CW_VALUE   12345
 +// =======================================================================
 +
 +main()
 +{
 +  proc=plc_proc_spindle;
 +
 +  timer=0;
 +  val=eparam;
 +
 +  message=PLCCMD_MODBUS_SPINDLE_CMD;
 +  command=SPINDLE_ON_CW_VALUE;
 +  parameter=SPINDLE_ON_CW_VALUE;
 +  timer=10; do{timer--;} while (timer>0);
 +
 +  message=PLCCMD_MODBUS_SPINDLE_SPEED;
 +  command=val;
 +  parameter=val;
 +  timer=30; do { timer--; } while (timer>0);
 +
 +
 +  gvarset(7370,1);   //Spindle State
 +  timer=10; do { timer--; } while (timer>0);
 +  gvarset(7371,val); //Spindle Speed Mirror register
 +  timer=10; do { timer--; } while (timer>0);
 +
 +  //delay after spindle started
 +  timeout=timer+spindle_on_delay;
 +  do{timer++;}while (timer<timeout); //delay for Spindle reach given speed
 +
 +  exit(99); //normal exit 
 +}; </code>
 +
 +++++
 +
 +This M03 procedure can be found by going into Settings > Config > PLC > Hardware PLC Templates > Mill (Modbus): Spindle CW Turn-ON.
 +
 +  * As can be seen in the sample code, the ''timeout'' delay is set to the spindle ON delay. This spindle ON delay is specified in the User Settings: 
 +
 +{{:mycnc:modbus-setup-002-timeout-delay.png}}
  
mycnc/modbus_setup.txt · Last modified: 2020/07/03 11:26 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki