Page 1 of 2
C axis AC servo info
Posted: Wed Mar 20, 2019 5:03 pm
by turbothis
i want to direct drive a 2.5KW AC servo for my lathe spindle and have indexing also
this will have typical A,B,Z encoder input and dual dac output
i have no idea which C program to start with on this. completely beginner
my first question would be about this line in the dualdac program
"DefineCoordSystem(0,-1,2,-1);"
is the last channel in there the C or would it be A?
would it not be more like this?
DefineCoordSystem(0,-1,2,-1,-1,6);
also not sure about the kmotion screen showing A axis with the X and Y
i might have to get some experience with the editor on that
Re: C axis AC servo info
Posted: Wed Mar 20, 2019 5:18 pm
by TomKerekes
Hi turbothis,
i want to direct drive a 2.5KW AC servo for my lathe spindle and have indexing also
this will have typical A,B,Z encoder input and dual dac output
i have no idea which C program to start with on this. completely beginner
I assume you mean you wish to drive the Spindle Axis like an A Axis Servo to certain angles?
Will you need to sometimes use it as a regular free spinning Spindle? If so you might create two C Programs to add and remove it from the Coordinate System and assign those to M Code Actions.
my first question would be about this line in the dualdac program
"DefineCoordSystem(0,-1,2,-1);"
is the last channel in there the C or would it be A?
A
also not sure about the kmotion screen showing A axis with the X and Y
i might have to get some experience with the editor on that
The standard 4 Axis Screen shows XYZA. If you don't want to see the Y Axis you will need to create a custom Screen with the Screen Editor and Hide the Axes you don't want.
Re: C axis AC servo info
Posted: Wed Mar 20, 2019 5:24 pm
by turbothis
i do like the idea of 2 separate user buttons to change from turning and indexing the spindle!
i was thinking the lathe axis where in this configuration?
is there a way to have the A axis read in degrees and only up to 360 and roll back over to 0 after 360? or is it set to just run 0-infinity?
Re: C axis AC servo info
Posted: Fri Mar 22, 2019 4:36 pm
by turbothis
morning bump 4 answer.
Re: C axis AC servo info
Posted: Fri Mar 22, 2019 6:54 pm
by TomKerekes
Hi turbothis,
The angular axes operate over +/- infinity.
You can use an MCode to reset the commanded destination to modulo 360 degrees. See the Modulo360.c example.
Code: Select all
#include "KMotionDef.h"
#define CNTS_PER_DEG 1000.0
#define AXISA 4
double modf(double, double*); // returns integer part with more han 32-bit precision
double floor(double x) // truncate down toward -ininity
{
double y;
return (modf(x, &y) < 0 ? y - 1 : y);
}
main()
{
double dest = chan[AXISA].Dest;
double cnts = CNTS_PER_DEG * 360.0;
EnableAxisDest(AXISA, dest - (floor(dest/cnts)) * cnts);
}
Re: C axis AC servo info
Posted: Fri Mar 22, 2019 8:37 pm
by turbothis
awesome!
getting ready to start my weekend of tweaking on this
Re: C axis AC servo info
Posted: Mon Apr 08, 2019 6:59 pm
by turbothis
how would i use this program?
add it to my main axis enable program or into the spindle jog?
Re: C axis AC servo info
Posted: Mon Apr 08, 2019 8:07 pm
by TomKerekes
Hi turbothis,
how would i use this program?
add it to my main axis enable program or into the spindle jog?
Configure an MCode to execute this program. Add the MCode into your GCode wherever you wish to reset the Position.
Re: C axis AC servo info
Posted: Mon Apr 08, 2019 8:53 pm
by turbothis
i set this as M100 in kmotioncnc
i ran it through and downloaded in kmotion
if i command M100 in the MDIm bar it should read up to 360 and start over right?
it does not now
Code: Select all
#include "KMotionDef.h"
#define CNTS_PER_DEG 32.97907
#define AXISA 4
double modf(double, double*); // returns integer part with more han 32-bit precision
double floor(double x) // truncate down toward -ininity
{
double y;
return (modf(x, &y) < 0 ? y - 1 : y);
}
main()
{
double dest = chan[AXISA].Dest;
double cnts = CNTS_PER_DEG * 360.0;
EnableAxisDest(AXISA, dest - (floor(dest/cnts)) * cnts);
}
Re: C axis AC servo info
Posted: Mon Apr 08, 2019 9:58 pm
by TomKerekes
Hi turbothis,
Actually if your Spindle has an encoder the code will need to be slightly different. See
here.
But it isn't clear what you are saying. When executed the program resets the current value to a value between 0 and 360. It does not cause future movements to roll over at 360. For example if the current machine position is 400 then executing M100 should change it to 40.