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 [2019/09/27 15:55] ivanmycnc:independent_pulse_generator [2019/10/04 09:36] ivan
Line 192: Line 192:
 ====Pulse Generator control for Spindle==== ====Pulse Generator control for Spindle====
  
-It is possible to control the spindle speed through the pulse generator.+It is possible to control the spindle speed through the pulse generator. This is done through the independent pulse generator implemented in myCNC, which can be "mixed into" the B axis channel. An independent generator is controlled by writing values ​​to the global variables 8130-8133, as described in the table at the beginning of this page (Register Name / Description table)
  
-The independent pulse generator implemented in myCNC can be "mixed intothe B axis channel+When using the GUI elements (buttons, input lines, etc.) it is convenient (and necessary) to use the multiplier and frequency registers when setting the generator frequency (what you see is NOT what you get, as the multipliers convert the human-read values into real machine values). For example, when the operator changes the value of register #8133 (the preset generator frequency), myCNC software will automatically recalculate the value of this preset frequency  while taking into account the preset multiplier and will send this data to the controller.
  
-An independent generator is controlled by writing values ​​to global variables 8130-8133as described in the table at the beginning of this page. .+When utilizing the Hardware PLCyou MUST use the "raw" value register entry (8130) and independently take into account the multiplier (in the PLC code), as no such helpful conversion is available
  
-When using the GUI elements (buttons, input lines, etc.) it is convenient (and necessary) to use the multiplier and frequency registers when setting the generator frequency. When changing the value of register #8133 (the preset generator frequency), myCNC software will automatically recalculate the value of the preset frequency  while taking into account the preset multiplier and will send this data to the controller.+===Independent Pulse Generator Spindle implementation example===
  
-When utilizing the Hardware PLC, you must use the "raw" value register entry (8130) and independently take into account the multiplier (in the PLC code). +1. Add the code that enables the generator into the Hardware PLC procedure M03.plc (spindle ON procedure). It is convenient to add code to the end of the procedure before the exit(99); line.
- +
-**Independent Pulse Generator Spindle implementation example** +
- +
-1. Add the code to enable the generator into the Hardware PLC procedure M03.plc (spindle ON procedure). +
-It is convenient to add code to the end of the procedure before the exit(99); line.+
  
 <code C> <code C>
Line 224: Line 219:
 </code> </code>
  
-2. Add the code to to enable the generator into the Hardware PLC spindle speed adjustment procedure (SPN.plc).+2. Add the following code to to enable the generator into the Hardware PLC spindle speed adjustment procedure (SPN.plc controls the speed with which the spindle is rotating).
  
 <code C> <code C>
Line 234: Line 229:
   // 12-bit spindle speed to generator frequency   // 12-bit spindle speed to generator frequency
   k = 123456;    k = 123456; 
-  freq = eparam * k; // Calculate the raw value of the generator frequency+  freq = eparam * k; // Calculate the raw value of the generator frequency by using the multiplier k
  
   // Send the generator frequency value   // Send the generator frequency value
Line 241: Line 236:
 </code> </code>
  
-3. Add the generator shutdown code to the Hardware PLC spindle shutdown procedure (M05.plc turns the spindle OFF). +3. Add the generator shutdown code to the Hardware PLC spindle shutdown procedure (M05.plc turns the spindle OFF). It is also convenient to add this code right at the end of the PLC procedure, before the exit(99); line. 
-It is also convenient to add this code at the end of the PLC procedure, before the exit(99); line. +
  
 <code C> <code C>
Line 250: Line 244:
 </code> </code>
  
-In this implementation, the pulse-dir generation will be switched on simultaneously with the classic control (a + 0-10V relay analog output). It is assumed that an unused spindle will be shut off physically by the operator and that the additional control signal will not affect operation. + 
 +{{plc:mycnc-spindle-pulse-dir-001.png}} 
 + 
 +{{plc:mycnc-spindle-pulse-dir-002.png}} 
 + 
 +{{plc:mycnc-spindle-pulse-dir-003.png}} 
 + 
 +In this implementation, the pulse-dir generation will be switched ON simultaneously with the classic control (a + 0-10V relay analog output). It is assumed that an unused spindle will be shut off physically by the operator and that the additional control signal will not affect operation. 
  
 <code> <code>
 If the task is to connect both spindles at the same time and switch them during operation If the task is to connect both spindles at the same time and switch them during operation
 (for example, by referencing their tool number), it is necessary to organize  (for example, by referencing their tool number), it is necessary to organize 
-a more complex PLC procedure, in which check the number of the tool, +a more complex PLC procedure, which will be checking the number of the tool, 
 the value of the global variable or input controller and by this condition  the value of the global variable or input controller and by this condition 
-include only one of the spindles.+would include only one of the spindles.
 </code> </code>
  
-In this example, we are assuming that the speed of a conventional spindle is 24,000 rpm. +In this example, we are assuming that the speed of a conventional spindle is 24,000 rpm. This value, respectively, is registered as the maximum spindle speed in the settings (//Settings > Config > Technology > Mill/Lathe > Spindle//).  
-This value, respectively, is registered as the maximum spindle speed in the settings.+ 
 +{{plc:mycnc-spindle-pulse-dir-004.png}}
  
 At this spindle speed, a full 10V signal must be sent to the analog output, so the "voltage ratio" coefficient is set to "1" (in the case of, for example, a spindle with an input signal range of 0-5V, this coefficient would be 0.5 to get a 5V signal at maximum speed). At this spindle speed, a full 10V signal must be sent to the analog output, so the "voltage ratio" coefficient is set to "1" (in the case of, for example, a spindle with an input signal range of 0-5V, this coefficient would be 0.5 to get a 5V signal at maximum speed).
  
-When calling the PLC procedures for turning on the spindle (M03.plc) and changing the spindle speed (SPN.plc), the spindle speed value is stored in the **eparam** variable.+When calling the PLC procedures for turning ON the spindle (M03.plc) and changing the spindle speed (SPN.plc), the spindle speed value is stored in the **eparam** variable. 
  
 myCNC controllers have 12-bit registers for PWM and DAC at 0-10V.This means that with a maximum spindle speed of **24000 rpm** and a factor of **1**, the ''eparam'' variable will have a maximum value of 4095. myCNC controllers have 12-bit registers for PWM and DAC at 0-10V.This means that with a maximum spindle speed of **24000 rpm** and a factor of **1**, the ''eparam'' variable will have a maximum value of 4095.
Line 271: Line 273:
 Assume that the maximum servo spindle speed is 4,500 rpm. Then the ''eparam'' value at a speed of 4500 rpm will be: Assume that the maximum servo spindle speed is 4,500 rpm. Then the ''eparam'' value at a speed of 4500 rpm will be:
  
-<code> 4500 * (4095/24000) = 768</code> +<code> 4500 * (4095 ÷ 24000) = 768</code>
- +
-The Pulse-Dir input of the servo spindle is set to 10,000 pulses, i.e. the motor shaft will make a full revolution every 10,000 pulses. Then, to achieve a full speed of 4500 rpm, the following pulse rate is needed+
  
-<code>10000 * (4500/60) = 750 000</code>+The Pulse-Dir input of the servo spindle is set to 10,000 pulses, i.e. the motor shaft will make a full revolution every 10,000 pulses. Then, to achieve a full speed of 4500 rpm, the following pulse rate is required:
  
-The register RAW value for 750kHz (750,000Hzshould be+<code>10000 * (4500 ÷ 60= 750 000</code>
  
-<code> 750000 / 0.0014549 = 515499347</code>+The register RAW value for 750kHz (750,000Hz) will therefore be calculated as follows:
  
-If the maximum speed corresponds to the ''eparam'' value of "768", then the value of the coefficient to obtain "515499347" will be+<code> 750000 ÷  0.0014549 = 515499347</code>
  
-<code> 515499347/768 = 671223</code>+If the maximum speed corresponds to the ''eparam'' value of "768", then the value of the coefficient to obtain "515499347" will be calculated as follows:
  
-By setting these values ​​in the M03.plc and SPN.plc procedures, we obtain the generation of the required 750 kHz frequency when the spindle speed is set to 4500, as well as smooth frequency control over the entire range from 0 to 4500 rpm.+<code> 515499347 ÷ 768 = 671223</code>
  
 +By setting these values ​​in the M03.plc and SPN.plc procedures, we will generate the required 750 kHz frequency when the spindle speed is set to 4500, as well as smooth frequency control over the entire range from 0 to 4500 rpm.
  
-**A method for evaluating the required acceleration of a generator** 
  
-The unit of the generator Acceleration task in very rough approximation is 1 impulse / s2. +===A method for evaluating the required acceleration of a generator===
-This means that with such an acceleration, the generator “accelerates”  to a frequency of 1 Hz in 1 second.+
  
-If, in our case, the maximum frequency is 750,000, then the acceleration must be equal to the same value in order to “accelerate” to this frequency in 1 second.+One unit of the generator acceleration is, by a very rough approximation, 1 impulse / s2. This means that with such an acceleration, the generator “accelerates”  to a frequency of 1 Hz in 1 second. If, in our case, the maximum frequency is 750,000, then the acceleration must be equal to the same value in order to “accelerate” to this frequency in 1 second.
  
-**Test code for spindle start-up and spindle speed adjustment procedures**:+===Test code for spindle start-up and spindle speed adjustment procedures===
  
 <code C M03.plc> <code C M03.plc>
Line 328: Line 327:
  
  
-  gvarset(8131, 500000); timer=30;do{timer--;}while(timer>0); //Задержка на 30мс+  gvarset(8131, 500000); timer=30;do{timer--;}while(timer>0); //30ms delay
   k=671223;    k=671223; 
   freq=val*k; //calculate the RAW frequency   freq=val*k; //calculate the RAW frequency
   if (freq>515499348) {freq=515499348;};   if (freq>515499348) {freq=515499348;};
-  gvarset(8130,freq); timer=30;do{timer--;}while(timer>0); //Задержка на 30мс+  gvarset(8130,freq); timer=30;do{timer--;}while(timer>0); //30ms delay
  
  
-  //delay after spindle started+  //delay after the spindle was turned on
   timer=spindle_on_delay;   timer=spindle_on_delay;
-  do{timer--;}while (timer>0); //delay for Spindle reach given speed+  do{timer--;}while (timer>0); //delay until the spindle reaches the given speed
  
   exit(99); //normal exit    exit(99); //normal exit 
Line 345: Line 344:
 <code C SPN.plc> <code C SPN.plc>
 #include vars.h   #include vars.h  
-//set Spindle speed control via DAC+//set the Spindle Speed through DAC
 main() main()
 { {
Line 358: Line 357:
   {   {
     k=671223;      k=671223; 
-    freq=val*k; //calculate the RAW frequency+    freq=val*k; //calculate the RAW frequency using the multiplier
     if (freq>515499348) {freq=515499348;};     if (freq>515499348) {freq=515499348;};
     gvarset(8130,freq); timer=30;do{timer--;}while(timer>0); //30ms delay     gvarset(8130,freq); timer=30;do{timer--;}while(timer>0); //30ms delay
Line 370: Line 369:
 ==== Low level CNC registers to control independent pulse generator ==== ==== Low level CNC registers to control independent pulse generator ====
  
-This is for records only. Users don't have to use low-level access.+This is for records only. Users don't have to utilize these settings which can be altered only by having low-level access to the controller.
  
 ^ Register Name ^ Address ^ Description ^ ^ Register Name ^ Address ^ Description ^
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