Hi Tom, ok, I have the spindle working, in fact have added some modifiers to the spindledefs to "curve" match the non-linear nature of the VFD to output. Not happy with the tolerance, will definately be changing to closed loop spindle control. At the bottom of this post is what I have done to get the speeds closer to the reality.
In the meantime, I can't figure out how to tell kmotioncnc which axis=x and y and z. Can you help me with this?
Code:
#define SPINDLEAXIS 3 // Axis Channel to Jog to rotate Spindle
#define FACTORBHK3R270 37 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=270-400
#define FACTORBHK3R401 23 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=401-874
#define FACTORBHK3R875 22.8 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=875-950
#define FACTORBHK3R951 21.9 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=951-1250
#define FACTORBHK3R1251 21.4 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=1251-1500
#define FACTORBHK3R1501 20.9 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=1501-1850
#define FACTORBHK3R1851 20.5 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=1851-2650
#define FACTORBHK3R2651 20.3 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=2651-2850
#define FACTORBHK3R2851 20.1 // custom factor using Hellcat CNC BOB=H, Kaboom=3 60000=60.00hz RPM=2851-3200
#define SPINDLE_ENABLE_BIT 0 // bit to enable spindle
#define SPINDLE_DIR_BIT 1 // bit to activate direction 0=CW, 1=CCW
#define SPEEDVAR 99 // global persistant variable to store latest speed
#define STATEVAR 98 // global persistant variable to store latest state (-1=CCW,0=off,1=CW)
#define KMVAR 1 // variable KMotionCNC will pass speed parameter (1)
and
Code:
// spindle is already on, so ramp to new speed
/* check the speed factor to use */
if( speed > 269 && speed <=400 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R270);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R270);
}
else if( speed > 400 && speed <=874 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R401);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R401);
}
else if( speed > 874 && speed <=950 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R875);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R875);
}
else if( speed > 950 && speed <1250 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R951);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R951);
}
else if( speed > 1250 && speed <=1500 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R1251);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R1251);
}
else if( speed > 1500 && speed <=1850 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R1501);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R1501);
}
else if( speed > 1850 && speed <=2650 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R1851);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R1851);
}
else if( speed > 2650 && speed <=2850 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R2651);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R2651);
}
else if( speed > 2850 && speed <=3200 )
{
/* if condition is true then modify speed factor*/
Jog(SPINDLEAXIS,speed * FACTORBHK3R2851);
printf("Jogging Spindle %f counts/sec\n",speed * FACTORBHK3R2851);
}