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 11:05] – skirillov | mycnc:independent_pulse_generator [2019/09/23 14:47] – ivan | ||
---|---|---|---|
Line 17: | 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, | | GVAR_GENERATOR_ACCEL | 8131 | Generator Acceleration, | ||
| GVAR_GENERATOR_FRQ_RATIO | 8132 | Generator Frequency Ratio | | | GVAR_GENERATOR_FRQ_RATIO | 8132 | Generator Frequency Ratio | | ||
Line 190: | Line 190: | ||
</ | </ | ||
+ | ====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 | + | <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; | ||
- | 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> |
- | | EXT_GENERATOR_ACCEL | 226 | Generator Acceleration, | + | 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); | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | The SPN code will be changed to look like the following: | ||
+ | |||
+ | <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);// | ||
+ | }; | ||
+ | |||
+ | </ | ||
+ | |||
+ | Screenshots: | ||
+ | |||
+ | {{plc: | ||
+ | |||
+ | {{plc: | ||
+ | |||
+ | {{plc: | ||
+ | |||
+ | ==== 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