Tom, you are amazing! I should have asked for help sooner. I used your code with a few changes and have it working awesome now. No pulsing at all now and Tau values can be made super small which gives an instant response! This is by far better then any of the other MPG programs.
The changes I had to make were: Im not using hardware encoder so i changed it to suit the normal mpg program. K1M,K2M are not declared. And I didnt try it exactly as you had it, but im pretty sure it wouldnt work the way it was as the new target would only be calculated if there was a change, and i believe it needs to be constantly recalculated. So i changed this code:
Code:
if (Change1) // did we move?
{
if (!InMotion) Target = Target1 = Target2 = chan[Axis].Dest;
Target1 += Change1 * Factor;
Target2 = Target2 * K1 + Target1 * K1M;
Target = Target * K2 + Target2 * K2M;
MoveExp(Axis,Target,TAU); // note: contains a WaitNextTimeSlice
LastChangeTime = Time_sec();
InMotion=TRUE;
}
else
{
WaitNextTimeSlice();
}
To this code:
Code:
if (Change1) // did we move?
{
if (!InMotion) Target = Target1 = Target2 = chan[Axis].Dest;
Target1 += Change1 * Factor;
LastChangeTime = Time_sec();
InMotion=TRUE;
}
if (InMotion) // If moving
{
Target2 = Target2 * K1 + Target1 * K1M;
Target = Target * K2 + Target2 * K2M;
MoveExp(Axis,Target,TAU);
CheckDistToStop(ch0); // Check distance to stop from adjustsoftlimits.c
CheckDistToStop(ch1); // Check distance to stop from adjustsoftlimits.c
CheckDistToStop(ch2); // Check distance to stop from adjustsoftlimits.c
}
else
{
WaitNextTimeSlice();
}
Everything appears to be working great now. I left my checks to stop in there, not sure if they are needed in the latest version or not, but its still working well for me so dont want to risk changing it. I attached the code im using, but my machine uses weird switches and ballscrews so everything couldn't be defined at top of program. Might not be the best program to use as an example. Would be nice for new users to have two new generic MPG programs (for hardware encoder and without) that uses these new filters, really works alot better. Thanks again for all the help!