User Tools

Site Tools


mycnc:independent_pulse_generator

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:independent_pulse_generator [2018/09/02 14:06] skirillovmycnc:independent_pulse_generator [2019/09/23 11:25] ivan
Line 190: Line 190:
 </code> </code>
  
 +====Pulse Generator control for Spindle====
  
 +It is possible to control the spindle speed through the pulse generator. The following code describes such a setup:
  
-==== Low level CNC registers to control independent pulse generator ====+<code C M03.plc> 
 +//Turn on Spindle clockwise 
 +#include pins.h 
 +#include vars.h 
 +main() 
 +
 +  command=PLC_MESSAGE_SPINDLE_SPEED_CHANGED; 
 +  parameter=eparam; 
 +  message=PLCCMD_REPLY_TO_MYCNC; 
 +  timer=0;do{timer++;}while (timer<10);//pause to push the message with Spindle Speed data
  
-This is for records only. Users don't have to use low-level access.+  timer=0; 
 +  proc=plc_proc_spindle;
  
-^ Register Name ^ Address ^ Description ^ +  val=eparam; 
-| EXT_GENERATOR_SPEED | 225 | Generator Frequency, [units] \\ 1 unit 0.000736 Hz  | +  if (val>0xfff) {val=0xfff;}; 
-| EXT_GENERATOR_ACCEL | 226 | Generator Acceleration, [units] \\ 1unit = 0.736 1/c2 |+  if (val<0) {val=0;};
  
 +  dac01=val;
  
 +  portclr(OUTPUT_CCW_SPINDLE);
 +  portset(OUTPUT_SPINDLE);
  
 +  gvarset(7370,1);//Spindle State
 +  timer=30;do{timer--;}while (timer>0); //
 +  gvarset(7371,eparam);//Spindle Speed Mirror register
  
 +  //gvarset(7372,0);//Mist State
 +  //gvarset(7373,0);//Flood State
  
  
 +  gvarset(8131, 500000); timer=30;do{timer--;}while(timer>0); //Задержка на 30мс
 +  k=671223; 
 +  freq=val*k; //calculate the RAW frequency
 +  if (freq>515499348) {freq=515499348;};
 +  gvarset(8130,freq); timer=30;do{timer--;}while(timer>0); //Задержка на 30мс
 +
 +
 +  //delay after spindle started
 +  timer=spindle_on_delay;
 +  do{timer--;}while (timer>0); //delay for Spindle reach given speed
 +
 +  exit(99); //normal exit 
 +};
 +</code>
 +
 +<code C SPN.plc>
 +#include vars.h  
 +//set Spindle speed control via DAC
 +main()
 +{
 +  val=eparam;
 +  dac01=val; //send the value to the DAC register
 +
 +  //Change the Spindle State
 +  gvarset(7371,eparam);  timer=30;do{timer--;}while (timer>0);  //30ms delay
 +
 +  s=gvarget(7370);
 +  if (s!=0) //if spindle should be ON
 +  {
 +    k=671223; 
 +    freq=val*k; //calculate the RAW frequency
 +    if (freq>515499348) {freq=515499348;};
 +    gvarset(8130,freq); timer=30;do{timer--;}while(timer>0); //30ms delay
 +  };
 +  exit(99);//normal exit 
 +};
 +
 +</code>
 +
 +
 +{{mycnc-spindle-pulse-dir-005.png}}
 +{{mycnc-spindle-pulse-dir-006.png}}
 +
 +==== Low level CNC registers to control independent pulse generator ====
 +
 +This is for records only. Users don't have to use low-level access.
 +
 +^ Register Name ^ Address ^ Description ^
 +| EXT_GENERATOR_SPEED | 225 | Generator Frequency, [units] \\ 1 unit = 0.000736 Hz  |
 +| EXT_GENERATOR_ACCEL | 226 | Generator Acceleration, [units] \\ 1unit = 0.736 1/c2 |
  
 Independent pulse output can be used for - Independent pulse output can be used for -
mycnc/independent_pulse_generator.txt · Last modified: 2022/02/11 15:45 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki