SPINDLE SERVO SPECS
Moderators: TomKerekes, dynomotion
Re: SPINDLE SERVO SPECS
ok gotcha i will get into that....
thanks
thanks
Re: SPINDLE SERVO SPECS
this requires a physical bit input for CW and CCW also? bit 154 and 155
my brain is destroyed on the FACTOR count. i have 11872.46 per spindle rev
would this be FACTOR (118724.6/60.0)?
my brain is destroyed on the FACTOR count. i have 11872.46 per spindle rev
would this be FACTOR (118724.6/60.0)?
Code: Select all
#include "KMotionDef.h"
#define SPINDLEAXIS 4
#define FACTOR (1000/60.0) //1000 counts/sec / 1000 counts/rev = 1 RPS = 60 RPM
#define SPINDLECW_BIT 154
#define SPINDLECCW_BIT 155
#define SPEEDVAR 99
#define STATEVAR 98
#define KMVAR 1
// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed
main()
{
float speed = *(float *)&persist.UserData[SPEEDVAR]; // value stored is actually a float
float LastState = persist.UserData[STATEVAR]; // get last state
if (LastState==1)
{
// if spindle was CW now we want CCW
// spin down
ClearBit(SPINDLECW_BIT);
ClearBit(SPINDLECCW_BIT);
Jog(SPINDLEAXIS,0);
while (!CheckDone(SPINDLEAXIS)) ;
}
// turn spindle on CCW and ramp to new speed
SetBit(SPINDLECCW_BIT);
// spindle is already on, so ramp to new speed
Jog(SPINDLEAXIS,speed * FACTOR);
printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
persist.UserData[STATEVAR] = -1; // remember we are CCW
}
Re: SPINDLE SERVO SPECS
i got my spindle rapid performance good using the MDi
just need to get the program set for S commands
just need to get the program set for S commands
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: SPINDLE SERVO SPECS
Hi turbothis,
Well how to control Spindles can vary depending on the Spindle Drive used. Most have some type of enable and direction inputs that need to be controlled. Since I believe you have a dual DAC type of drive it can be driven forward or reverse seamlessly as an axis so those might be removed or ignored.this requires a physical bit input for CW and CCW also? bit 154 and 155
Did you intentionally move the decimal point?i have 11872.46 per spindle rev
would this be FACTOR (118724.6/60.0)?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: SPINDLE SERVO SPECS
ya, i am terrible at getting this type of numbers hammered out
so it would be FACTOR (11872.46/60.0) then?
so it would be FACTOR (11872.46/60.0) then?
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: SPINDLE SERVO SPECS
Hi turbothis,
I believe so.so it would be FACTOR (11872.46/60.0) then?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: SPINDLE SERVO SPECS
ok so i got rid of the bit stuff and ended up with this
i really dont know what the VAR or variable thing means or refers to. any pointers on this?
plus here are my M settings
Code: Select all
#include "KMotionDef.h"
#define SPINDLEAXIS 4
#define FACTOR (11872.46/60.0) //1000 counts/sec / 1000 counts/rev = 1 RPS = 60 RPM
#define SPEEDVAR 99
#define STATEVAR 98
#define KMVAR 1
// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed
main()
{
float speed = *(float *)&persist.UserData[SPEEDVAR]; // value stored is actually a float
float LastState = persist.UserData[STATEVAR]; // get last state
if (LastState==1)
{
Jog(SPINDLEAXIS,0);
while (!CheckDone(SPINDLEAXIS)) ;
}
// spindle is already on, so ramp to new speed
Jog(SPINDLEAXIS,speed * FACTOR);
printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
persist.UserData[STATEVAR] = -1; // remember we are CCW
}
plus here are my M settings
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: SPINDLE SERVO SPECS
Hi turbothis,
It seems you have assigned the same program for turning on the spindle (M3) and for setting the speed (S). Also M3 is normally to set the Spindle CW not CCW.
Actually I made a mistake and mislead you earlier. The best example programs to use are in the \C Programs\SpindleUsingJogs\CSS folder. These use a header file that is included to avoid duplicating things.
Please read this carefully and follow the instructions. It describes how the Var is used to pass the desired speed from KMotionCNC to the S Program.
It seems you have assigned the same program for turning on the spindle (M3) and for setting the speed (S). Also M3 is normally to set the Spindle CW not CCW.
Actually I made a mistake and mislead you earlier. The best example programs to use are in the \C Programs\SpindleUsingJogs\CSS folder. These use a header file that is included to avoid duplicating things.
Please read this carefully and follow the instructions. It describes how the Var is used to pass the desired speed from KMotionCNC to the S Program.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: SPINDLE SERVO SPECS
great! i will do my homework and try to not burn up all your time
some of this stuff is very hard for me though
i cant thank you enough
once this lathe is done i plan on getting 2 more kflop/kanalog boards for my remaining 2 machines
some of this stuff is very hard for me though
i cant thank you enough
once this lathe is done i plan on getting 2 more kflop/kanalog boards for my remaining 2 machines
Re: SPINDLE SERVO SPECS
outstanding
it is working good
for some reason the CCW program spins CW too
my new Hdefs.H
it is working good
for some reason the CCW program spins CW too
Code: Select all
#include "KMotionDef.h"
#include "MySpindleDefs.h"
int *css_mode = &persist.UserData[PC_COMM_CSS_MODE]; // Mode 1=Normal RPM mode. 2=CSS
// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed
main()
{
float speed = *(float *)&persist.UserData[SPEEDVAR]; // value stored is actually a float
float LastState = persist.UserData[STATEVAR]; // get last state
if (LastState==1)
{
// if spindle was CW now we want CCW
// spin down
ClearBit(SPINDLECW_BIT);
ClearBit(SPINDLECCW_BIT);
Jog(SPINDLEAXIS,0);
while (!CheckDone(SPINDLEAXIS)) ;
}
// turn spindle on CCW and ramp to new speed
SetBit(SPINDLECCW_BIT);
LastState = -1;
if (*css_mode != 2)
{
// spindle is already on, so ramp to new speed
if (USE_POS_NEG_VOLTAGE)
Jog(SPINDLEAXIS,speed * FACTOR * LastState);
else
Jog(SPINDLEAXIS,speed * FACTOR);
printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
}
persist.UserData[STATEVAR] = -1; // remember we are CCW
}
my new Hdefs.H
Code: Select all
#define SPINDLEAXIS 2 // Axis Channel to Jog to rotate Spindle
#define FACTOR (11872.46/60.0) // to convert RPM to counts/sec (counts/rev / 60.0sec)
#define SPINDLECW_BIT 154 // bit to activate to cause CW rotation
#define SPINDLECCW_BIT 155 // bit to activate to cause CCW rotation
#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 PC_COMM_CSS_S // variable KMotionCNC will pass speed parameter (113)
#define USE_POS_NEG_VOLTAGE 0 // 0 = output Magnitude, 1 = output positive and negative speed