//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); //30ms delay 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 //delay after the spindle was turned on timer=spindle_on_delay; do{timer--;}while (timer>0); //delay until the spindle reaches the given speed exit(99); //normal exit };