You might be able to tune it a bit better now. I see at the beginning there is a jump ahead. Probably because we have too much FFs as so much is now not needed to overcome the Deadband to get moving. Although the reverse move behaves differently.
This might be part of the reason. We did a simplistic approach of when the motion should be positive apply +Deadband otherwise -Deadband. So when the forward motion stops the Output Jumps Negative. So then the integrator needs to ramp way positive to move the last little bit. And then when the negative move starts the integrator has negated the -Deadband already applied earlier.
We could be a little smarter and if moving forward apply forward correction and if backward apply backward correction and if neither none:
Code:
#include "KMotionDef.h"
#define DEADBAND 700
#define THRESH 2.0
void main()
{
for (;;)
{
if (ch0->last_vel > THRESH)
DAC(0, (int)(ch0->Output + DEADBAND));
else if (ch0->last_vel < -THRESH)
DAC(0, (int)(ch0->Output - DEADBAND));
else
DAC(0, (int)(ch0->Output));
}
}
And still further all of the above but if not moving and the error is significantly negative apply forward correction, and if error is significantly positive apply negative, and otherwise none.
Code:
#include "KMotionDef.h"
#define DEADBAND 700
#define THRESH 2.0
#define THRESHFE 5.0
void main()
{
for (;;)
{
if (ch0->last_vel > THRESH)
DAC(0, (int)(ch0->Output + DEADBAND));
else if (ch0->last_vel < -THRESH)
DAC(0, (int)(ch0->Output - DEADBAND));
else if (ch0->LastFollowingError > THRESHFE)
DAC(0, (int)(ch0->Output - DEADBAND));
else if (ch0->LastFollowingError < -THRESHFE)
DAC(0, (int)(ch0->Output + DEADBAND));
else
DAC(0, (int)(ch0->Output));
}
}
I'm not sure how much time you want to spend on trying to use tricks to overcome mechanical problems. For me its fun but rarely helps much.