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/10/03 14:31] ivanmycnc:independent_pulse_generator [2020/02/20 08:54] ivan
Line 6: Line 6:
 <code> <code>
 Independent Pulse Generator was added to firmware dated July 20, 2018. 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> </code>
  
Line 51: Line 49:
  
 The first application we used the Pulse Generator was a Coolant control base on a stepper driver. The first application we used the Pulse Generator was a Coolant control base on a stepper driver.
- 
- 
-=== Pulse Generator settings in User Widget === 
-We added Pulse generator settings to a User Widget of "1280M5" profile. We are going to test it and distribute these settings for other profiles and other applications as well later. 
- 
- 
-{{mycnc:generator:mycnc-pulse-coolant-001.png}} 
- 
-The programming of Pulse the Coolant widget is shown below. 
- 
-"user-m5.xml" configuration file contains a code for the User Widget. There are lines to add Coolant widget itself and include a xml file with Coolant widget content 
- 
-<code XML> 
-<gitem  where="user-widget" name="coolant-widget"  
- bgColor="##b-widget"  type="myitems" 
- position="590;300" width="490" height="150" /> 
- 
- <include>user-coolant.xml</include> 
-</code> 
-   
-The lines contain "coolant-widget" definition (a background color, position on the parent widget, a widget size and a widget type (myitems). 
- 
-"user-coolant.xml code is shown below 
- 
-<code XML user-coolant.xml> 
-<mycnc-configuration version="1.0"> 
-<gitem where="coolant-widget" 
- position="0;0" width="490" height="30" labelWidth="490" type="label"  
- labelFgColor="white" labelBgColor="##f-display" labelFontSize="18" labelFontStyle="bold" > 
-  <message>Coolant</message> 
-  <message_ru>Охлаждение</message_ru> 
-  <message_vn>Chất làm mát</message_vn> 
-</gitem> 
- 
-<gitem where="coolant-widget" 
- position="10;40" width="220" height="60" displayWidth="90" labelWidth="130" 
- type="bdisplay" action="item:cnc-gvariable-8133" name="display-cnc-gvariable-8133" 
- bgColor="##b-display" fgColor="##f-display" fontSize="18" fontStyle="bold" format="%5.1f"  
- K="1" labelFontSize="16" labelFontStyle="bold" labelFgColor="white" > 
-  <message>Rate, ml/hour</message> 
-  <message_ru>Расход, мл/час</message_ru> 
-</gitem> 
- 
-<gitem where="coolant-widget" 
- position="280;40" width="180" height="60" displayWidth="90" labelWidth="90" 
- type="bdisplay" action="item:cnc-gvariable-8132" name="display-cnc-gvariable-8132" 
- bgColor="##b-display" fgColor="##f-display" fontSize="14" fontStyle="bold"  
- format="%d" K="1" labelFontSize="16" labelFontStyle="bold" labelFgColor="white" > 
-  <message>Ratio</message> 
-  <message_ru>Коэффициент</message_ru> 
-</gitem> 
- 
-</screen> 
-</code> 
- 
-The code contains 3 parts  
-  * the widget label set up 
-  * the frequency setup 
-  * the Ratio set up 
- 
-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. 
- 
  
 === Pulse Generator settings in the Software PLC === === Pulse Generator settings in the Software PLC ===
 The rate, ratio and acceleration can be set up in the Software PLC as well.  The rate, ratio and acceleration can be set up in the Software PLC as well. 
  
-"HANDLER_INIT.plc" procedure is started just after the configuration is sent to the myCNC controller. A few lines to set the Frequency generator can be added there.+"HANDLER_INIT.plc" procedure is started just after the configuration is sent to the myCNC controller. A few lines to set up the Frequency generator can be added there.
  
 <code C HANDLER_INIT.plc> <code C HANDLER_INIT.plc>
Line 134: Line 69:
  
  
-==== (Coolant) Pulse Generator control through Hardware PLC ====+==== MQL (Coolant) Pulse Generator control through Hardware PLC ====
  
-Function coolant_motor_start() is addaed to "mill-func.h" include file+Function ''coolant_motor_start()'' is added to the ''mill-func.h'' file
  
 <code C mill-func.h> <code C mill-func.h>
Line 155: Line 90:
 </code> </code>
  
-M08.plc procedure which starts the coolant motor would be +''M08.plc'' procedure which starts the coolant motor would be the following (//note the inclusion of mill-func.h at the beginning of the code//):
  
 <code C M08.plc> <code C M08.plc>
Line 171: Line 106:
  
  
-A procedure M09.plc to stop a coolant motor is simpler. Just need to write "0" to the raw frequency register.+A procedure ''M09.plc'' to stop a coolant motor is simpler - we simply need to write "0" to the raw frequency register.
  
 <code C M09.plc> <code C M09.plc>
Line 198: Line 133:
 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), as no such helpful conversion is available.  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), as no such helpful conversion is available. 
  
-**Independent Pulse Generator Spindle implementation example**+===Independent Pulse Generator Spindle implementation example===
  
 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. 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.
Line 243: Line 178:
   exit (99); // normal exit   exit (99); // normal exit
 </code> </code>
 +
 +
 +{{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.  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. 
Line 254: Line 196:
 </code> </code>
  
-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//). 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).+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//).  
 + 
 +{{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).
  
-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 262: Line 208:
 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 required: 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:
  
-<code>10000 * (4500/60) = 750 000</code>+<code>10000 * (4500 ÷ 60) = 750 000</code>
  
-The register RAW value for 750kHz (750,000Hz) should be+The register RAW value for 750kHz (750,000Hz) will therefore be calculated as follows:
  
-<code> 750000 0.0014549 = 515499347</code>+<code> 750000 ÷  0.0014549 = 515499347</code>
  
-If the maximum speed corresponds to the ''eparam'' value of "768", then the value of the coefficient to obtain "515499347" will be+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:
  
-<code> 515499347/768 = 671223</code>+<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. 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**+===A method for evaluating the required acceleration of a generator===
  
 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. 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 323: Line 269:
  
  
-  //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 333: Line 279:
 <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 346: Line 292:
   {   {
     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 358: Line 304:
 ==== 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 utilize these settings which are changed by having low-level access to the controller.+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