Hi mmurray70,
Im wondering how things work with a rotary axis brake in KmotionCNC. Can i set it up to release the brake and enable axis automatically whenever it encounters a line of code with an A move in it? And clamp/disable axis again when its done moving the A axis?
Most likely you would need an MCode before the movement to: Enable the axis, Add A to the Coordinate System, Unclamp, and delay until unclamped. Then after A movements another MCode to: Clamp, Delay, Disable, and Remove A from the Coordinate System.
If the A Axis accelerates very slowly and the Clamp/Unclamp fast then it might be possible to detect the start and stop of A motion and automatically unclamp and clamp. But the risk would be that the motion begins before it is fully unclamped or that other motions begin before it has been fully clamped.
Also, wondering how Kmotioncnc handles multiple rotations. For example if i move to A450, and then move back to A0, does it rotate 90 degrees or 450?
It would rotate -450 degrees. If you only want the modulo 360degree portion you can use an MCode to convert the angle first (change 450 to 90) then the movement to A0 would be -90 degrees. See the Modulo360.c example below.
Code:
#include "KMotionDef.h"
#define CNTS_PER_DEG 1000.0
#define AXISA 4
double modf(double, double*); // returns integer part with more than 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);
}
Regards