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 revisionBoth sides next revision
mycnc:modbus_setup [2019/09/12 10:40] ivanmycnc:modbus_setup [2020/01/27 11:42] ivan
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