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 revision
Previous revision
Next revisionBoth sides next revision
mycnc:independent_pulse_generator [2018/09/02 10:08] skirillovmycnc:independent_pulse_generator [2019/09/23 11:25] ivan
Line 3: Line 3:
  
 myCNC controllers Axis B can be switched to independent pulse generator output. myCNC controllers Axis B can be switched to independent pulse generator output.
 +
 +<code>
 +Independent Pulse Generator was added to firmware dated July 20, 2018.
 +At the moment the firmware is available as the
 +"Testing" version at the "Support" widget.
 +</code>
  
  
Line 11: Line 17:
  
 ^ Register Name ^ Address ^ Description ^ ^ Register Name ^ Address ^ Description ^
-| GVAR_GENERATOR_FRQ_RAW | 8130 | Pulse Generator RAW frequency value, [units] \\ 1 unit = | +| GVAR_GENERATOR_FRQ_RAW | 8130 | Pulse Generator RAW frequency value, [units] \\ 1 unit = 0.000736 Hz 
 | GVAR_GENERATOR_ACCEL | 8131 | Generator Acceleration, [units] \\ 1unit = 0.736 1/c2 | | GVAR_GENERATOR_ACCEL | 8131 | Generator Acceleration, [units] \\ 1unit = 0.736 1/c2 |
 | GVAR_GENERATOR_FRQ_RATIO | 8132 | Generator Frequency Ratio | | GVAR_GENERATOR_FRQ_RATIO | 8132 | Generator Frequency Ratio |
Line 105: Line 111:
   * the Ratio set up   * the Ratio set up
  
-It's supposed operator no need to change frequency acceleration and this setting is hidden from operator.+It's supposed operator no need to change frequency acceleration and this setting is hidden from an  operator.
 The acceleration can be set up in the Software or Hardware PLC for example. The acceleration can be set up in the Software or Hardware PLC for example.
  
Line 128: Line 134:
  
  
 +==== (Coolant) Pulse Generator control through Hardware PLC ====
  
 +Function coolant_motor_start() is addaed to "mill-func.h" include file
  
-==== Low level CNC registers to control independent pulse generator ====+<code C mill-func.h> 
 +coolant_motor_start() 
 +
 +  timer=10;do{timer--;}while(timer>0);
  
-This is for records only. Users don't have to use low-level access.+  gvarset(8131,1000000); //acceleration 
 +  timer=10;do{timer--;}while(timer>0);
  
-^ Register Name ^ Address ^ Description ^ +  x=gvarget(8133);//get the speed (frequency) 
-| EXT_GENERATOR_SPEED | 225 | Generator Frequency, [units] \\ 1 unit 0.000736 Hz  | +  k=gvarget(8132);//get the ratio
-| EXT_GENERATOR_ACCEL | 226 | Generator Acceleration, [units] \\ 1unit 0.736 1/c2 |+
  
 +  x=x*k; //calculate the RAW frequency
 +  gvarset(8130,x); //send the raw frequency to the register
 +  timer=30;do{timer--;}while(timer>0); //wait a time for the frequency value to be delivered
 +};
 +</code>
  
 +M08.plc procedure which starts the coolant motor would be 
  
 +<code C M08.plc>
 +#include pins.h
 +#include mill-func.h
  
 +main()
 +{
 +  gvarset(7372,1);
 +  portset(OUTPUT_FLOOD); //
 +  coolant_motor_start();
 +  exit(99); //normal exit 
 +};
 +</code>
  
  
 +A procedure M09.plc to stop a coolant motor is simpler. Just need to write "0" to the raw frequency register.
 +
 +<code C M09.plc>
 +#include pins.h
 +main()
 +{
 +  gvarset(7373,0);
 +  gvarset(7372,0);
 +
 +  portclr(OUTPUT_FLOOD);
 +  portclr(OUTPUT_MIST);
 +
 +  gvarset(8130,0); //stop the pulse generator
 +  timer=30;do{timer--;}while(timer>0); //wait a time for the frequency value to be delivered
 +  exit(99); //normal exit 
 +};
 +
 +</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:
 +
 +<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
 +
 +  timer=0;
 +  proc=plc_proc_spindle;
 +
 +  val=eparam;
 +  if (val>0xfff) {val=0xfff;};
 +  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