mycnc:independent_pulse_generator
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
mycnc:independent_pulse_generator [2018/09/02 14:06] – skirillov | mycnc:independent_pulse_generator [2019/09/27 15:50] – ivan | ||
---|---|---|---|
Line 190: | Line 190: | ||
</ | </ | ||
+ | ====Pulse Generator control for Spindle==== | ||
+ | It is possible to control the spindle speed through the pulse generator. | ||
- | ==== Low level CNC registers to control | + | The independent pulse generator |
- | This is for records only. Users don't have to use low-level access. | + | An independent generator |
- | ^ Register Name ^ Address ^ Description ^ | + | 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 |
- | | EXT_GENERATOR_SPEED | 225 | Generator Frequency, [units] \\ 1 unit = 0.000736 Hz | | + | |
- | | EXT_GENERATOR_ACCEL | 226 | Generator Acceleration, [units] \\ 1unit = 0.736 1/c2 | | + | |
+ | When utilizing the Hardware PLC, you must use the " | ||
+ | **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> | ||
+ | // Set the acceleration of the generator | ||
+ | gvarset (8131, 100000); timer = 30; do {timer -;} while (timer> 0); // Delay for 30ms | ||
+ | // Convert spindle speed reference to frequency. | ||
+ | // The value of the coefficient is selected in such a way as to convert | ||
+ | // 12-bit spindle speed to generator frequency | ||
+ | k = 123456; | ||
+ | freq = eparam * k; // Calculate the raw value of the generator frequency | ||
+ | // Send generator frequency value | ||
+ | gvarset (8130, freq); timer = 30; do {timer -;} while (timer> 0); // Delay for 30ms | ||
+ | |||
+ | exit (99); // normal exit | ||
+ | |||
+ | </ | ||
+ | |||
+ | 2. Add the code to to enable the generator into the Hardware PLC spindle speed adjustment procedure (SPN.plc). | ||
+ | |||
+ | <code C> | ||
+ | // Set the acceleration of the generator | ||
+ | gvarset (8131, 100000); timer = 30; do {timer -;} while (timer> 0); // Delay for 30ms | ||
+ | |||
+ | // Convert reference spindle speed to frequency. | ||
+ | // The value of the coefficient k is selected in such a way as to convert | ||
+ | // 12-bit spindle speed to generator frequency | ||
+ | k = 123456; | ||
+ | freq = eparam * k; // Calculate the raw value of the generator frequency | ||
+ | |||
+ | // Send the generator frequency value | ||
+ | gvarset (8130, freq); timer = 30; do {timer -;} while (timer> 0); // Delay for 30ms | ||
+ | exit (99); // normal exit | ||
+ | </ | ||
+ | |||
+ | 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 at the end of the PLC procedure, before the exit(99); line. | ||
+ | |||
+ | <code C> | ||
+ | // Send generator frequency value | ||
+ | gvarset (8130.0); timer = 30; do {timer -;} while (timer> 0); // Delay for 30ms | ||
+ | exit (99); // normal exit | ||
+ | </ | ||
+ | |||
+ | |||
+ | Screenshots of such an implementation: | ||
+ | {{mycnc-spindle-pulse-dir-001.png}} | ||
+ | {{mycnc-spindle-pulse-dir-002.png}} | ||
+ | {{mycnc-spindle-pulse-dir-003.png}} | ||
+ | |||
+ | In this implementation, | ||
+ | |||
+ | < | ||
+ | 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 | ||
+ | a more complex PLC procedure, in which check the number of the tool, | ||
+ | the value of the global variable or input controller and by this condition | ||
+ | include only one of the spindles. | ||
+ | </ | ||
+ | |||
+ | In this example, we are assuming that the speed of a conventional spindle is 24,000 rpm. | ||
+ | This value, respectively, | ||
+ | |||
+ | {{mycnc-spindle-pulse-dir-004.png}} | ||
+ | |||
+ | At this spindle speed, a full 10V signal must be sent to the analog output, so the " | ||
+ | |||
+ | 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 '' | ||
+ | |||
+ | Assume that the maximum servo spindle speed is 4,500 rpm. Then the '' | ||
+ | |||
+ | < | ||
+ | |||
+ | 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 | ||
+ | |||
+ | < | ||
+ | |||
+ | The register RAW value for 750kHz (750,000Hz) should be | ||
+ | |||
+ | < | ||
+ | |||
+ | If the maximum speed corresponds to the '' | ||
+ | |||
+ | < | ||
+ | |||
+ | 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. | ||
+ | |||
+ | |||
+ | **A method for evaluating the required acceleration of a generator** | ||
+ | |||
+ | The unit of the generator Acceleration task in a very rough approximation is 1 impulse / s2. | ||
+ | This means that with such an acceleration, | ||
+ | |||
+ | 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**: | ||
+ | |||
+ | <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; | ||
+ | |||
+ | timer=0; | ||
+ | proc=plc_proc_spindle; | ||
+ | |||
+ | val=eparam; | ||
+ | if (val> | ||
+ | if (val<0) {val=0;}; | ||
+ | |||
+ | dac01=val; | ||
+ | |||
+ | portclr(OUTPUT_CCW_SPINDLE); | ||
+ | portset(OUTPUT_SPINDLE); | ||
+ | |||
+ | gvarset(7370, | ||
+ | timer=30; | ||
+ | gvarset(7371, | ||
+ | |||
+ | // | ||
+ | // | ||
+ | |||
+ | |||
+ | gvarset(8131, | ||
+ | k=671223; | ||
+ | freq=val*k; //calculate the RAW frequency | ||
+ | if (freq> | ||
+ | gvarset(8130, | ||
+ | |||
+ | |||
+ | //delay after spindle started | ||
+ | timer=spindle_on_delay; | ||
+ | do{timer--; | ||
+ | |||
+ | exit(99); | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | <code C SPN.plc> | ||
+ | #include vars.h | ||
+ | //set Spindle speed control via DAC | ||
+ | main() | ||
+ | { | ||
+ | val=eparam; | ||
+ | dac01=val; | ||
+ | |||
+ | //Change the Spindle State | ||
+ | gvarset(7371, | ||
+ | |||
+ | s=gvarget(7370); | ||
+ | if (s!=0) //if spindle should be ON | ||
+ | { | ||
+ | k=671223; | ||
+ | freq=val*k; //calculate the RAW frequency | ||
+ | if (freq> | ||
+ | gvarset(8130, | ||
+ | }; | ||
+ | exit(99);// | ||
+ | }; | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | {{mycnc: | ||
+ | {{mycnc: | ||
+ | |||
+ | |||
+ | ==== 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, | ||
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