Here is my code to clamp:
Code:
#include "KMotionDef.h"
main()
{
Delay_sec(0.25); // wait for everything to stop
ch3->MaxOutput=1; // reduce max gain
ch3->I=0.0; // reduce integrator
SetBit(53); // turn on brake
while (!ReadBit(1052)) WaitNextTimeSlice(); // Wait for clamped signal
}
And here is the code to unclamp:
Code:
#include "KMotionDef.h"
main()
{
ClearBit(53); // turn off brake
while (!ReadBit(1053)) WaitNextTimeSlice(); // Wait for unclamped signal
ch3->MaxOutput=2000; // increase max gain
ch3->I=0.010; // increase integrator
}
I just configured my M30 to unclamp so it unclamps at the end of every program, and you will also want to do the same thing for your halt/reset button. So anytime im not running g-code, its unclamped. If I ever need to do some very heavy hogging with the MPG (not likely) ill just use the M code in MDI to reclamp.