Page 1 of 2

Motor movement during reset of axes

Posted: Wed Jul 27, 2022 1:05 am
by SamMarrocco
I've noticed in the past that during occasional operations that shouldn't cause any motor movement, I would hear my steppers make a slight noise like a movement or like they just locked into place. In particular it would happen when I would perform an Axis.Reset() through the dotnet libraries. I didn't give it a lot of thought at the time.

Lately I've been doing a lot of very precise work, and while measuring backlash and calibrating I began to notice a pattern. This is all within my vb.net app, but I've narrowed it down to some simple steps for recreation below.

Consider the X axis, where left is negative movement and right is positive movement, using backlash settings that are proper for the system....

If I move the X Axis/motor programmatically to the right (additive movement to the right), then perform an Axis.Reset() in the dotnet libraries, my motor moves very slightly (approximately .0005") to the left (negative). This happens with every Axis.Reset(), over and over again.

If I move the X Axis/motor programmatically to the left (subtractive movement to the left), then perform an Axis.Reset() in the dotnet libraries, the motor doesn't move at all.

This is predictable and happens on each axis every time that Axis' .Reset() is performed, and also during a change in my current position, which I do with
Axis.Disable
Axis.SetCurrentPosition(Count)
Axis.SetCommandedDest(Count)
Axis.Enable

Is the motor somehow being 'released' and then 'positioned' each time the .reset or .Disable is performed? There isn't anything pulling against the motors when this happens, so I've ruled that out.

Re: Motor movement during reset of axes

Posted: Wed Jul 27, 2022 6:06 pm
by TomKerekes
Hi Sam,

What Version are you running?

Please post your configuration and all settings.

What is the resolution of your system?

I'm not aware of any Axis 'Reset' method. Did you mean something else?

What Count are you setting the Position and Destination to?

What does the KMotion Axis Screen show before/after the Axis.Enable?

When you say this happens over and over again, is that just repeated Enables or with moves between Enables?

Does this occur with Backlash set to zero?

Enable reads the current Position and sets the target Destination to what it read. So the SetCommandedDest doesn't do anything. There is an EnableDest method where the Destination can be specified.

Re: Motor movement during reset of axes

Posted: Wed Jul 27, 2022 6:46 pm
by SamMarrocco
What Version are you running?
v4.35f. I tried a few earlier versions with no difference in effect.

Please post your configuration and all settings.
Anything in particular you'd like to see? I'm not using KMotion, but can parse out what you'd like to see or do a 'dump' of some parameters. Here is a short list of the tuning params from one of the axis if that helps (forgive the formatting):

With .GetAxis(Y_AXIS_ID, "")
.Velocity = 40000
.Acceleration = 200000
With .TuningParams
.InputMode = INPUTMODE_Enum.NO_INPUT_MODE
.OutputMode = OUTPUTMODE_Enum.STEP_DIR_MODE
.Jerk = 4000000.0
.Pgain = 0
.Igain = 0.01
.Dgain = 0
.FFAccel = 0
.FFVel = 0
.MaxI = 200
.MaxErr = 1000000.0
.MaxOutput = 200
.DeadBandGain = 1
.DeadBandRange = 0
.InputChan0 = 0
.InputChan1 = 0
.OutputChan0 = 9
.OutputChan1 = 0
.MasterAxis = -1
.LimitSwitch = "0x100"
.InputGain0 = 1
.InputGain1 = 1
.InputOffset0 = 0
.InputOffset1 = 0
.OutputGain = 1
.OutputOffset = 0
.SlaveGain = 1
.InvDistPerCycle = 1
.Lead = 0
.MaxFollowingError = 1000000000
.StepperAmplitude = 20
.SetIIR0(1, 0, 0, 0, 0)
.SetIIR1(1, 0, 0, 0, 0)
.SetIIR2(0.000769, 0.001538, 0.000769, 1.92081, 0.923885)
.BacklashMode = BacklashMode_Enum.BACKLASH_LINEAR
,BacklashAmount = .0065 * 40000 (Inches of backlash * steps per unit/inches)
.BacklashRate = 1000
End With

What is the resolution of your system?
For this particular motor, 40,000 steps/unit (inches in my case)

I'm not aware of any Axis 'Reset' method. Did you mean something else?
Apologies, I meant to say Axis.ZeroAxis()

What Count are you setting the Position and Destination to?
Any count seems to have the same effect, and both are being set to the same number.

What does the KMotion Axis Screen show before/after the Axis.Enable?
I'm not using KMotion (this is my own vb.net app), but my DROs show the exact same number before and afterwards). They do not reflect the 'micro-move' that is happening.

When you say this happens over and over again, is that just repeated Enables or with moves between Enables?
To clarify, the micro-move only happens once per .ZeroAxis or .enable sequence mentioned earlier, and happens with ever .ZerAxis() or .enable sequence afterwards, depending on the direction of the aforementioned backlash.

Does this occur with Backlash set to zero?
I have not tried that but will do so and respond asap.

Re: Motor movement during reset of axes

Posted: Wed Jul 27, 2022 8:54 pm
by SamMarrocco
Tom,
Per your suggestion, I performed the same operation (axis.ZeroAxis()) with a backlash value of 0.
The motor movement does not happen with backlash set to zero. It only happens with a non-zero backlash value.

So I tried various backlash values and recorded the results:

Interestingly enough, some values cause the motor to move left on a .ZeroAxis, some cause it to move right, and some cause a random direction upon each ZeroAxis. This is definitely repeatable. In all cases, Backlash Rate was constant at 5000. I performed the .ZeroAxis dozens of time each, then went back and duplicated the results several times.

Backlash Value Movement Direction upon each .ZeroAxis()
.00015 Right
.0001 Right
.001 Left
.0015 Left
.01 Random Left/Right
.015 Random Left/Right
.1 Right
.15 Random Left/Right

I could see no pattern to the backlash value vs. direction. The randomness I had never noticed before since my backlash values stay relatively constant.

Re: Motor movement during reset of axes

Posted: Thu Jul 28, 2022 1:53 am
by TomKerekes
Hi Sam,

So far I'm not able to reproduce.
When you say this happens over and over again, is that just repeated Enables or with moves between Enables?
To clarify, the micro-move only happens once per .ZeroAxis or .enable sequence mentioned earlier, and happens with ever .ZerAxis() or .enable sequence afterwards, depending on the direction of the aforementioned backlash.
I'm afraid it still is not completely clear what exactly you are doing :)

Before you describe having to move some amount in some direction before zeroing. I understand it micro-moves after every ZeroAxis but are you doing something between ZeroAxis commands?

Even though you are not using KMotion.exe you can still run it in parallel with your App for diagnostic purposes.

I assume your Y axis is Axis 1 in KFLOP?

ZeroAxis should simply issue a Zero1 command to KFLOP. Please enter a Zero1 command in the KMotion Console Screen to see if the micro-move happens as well.

If so, stop your App and see if it also occurs with the Zero1 command.

Here is what I am doing:
I have an oscilloscope connected to KFLOP's Step1 output.
Using KMotion.exe I set all your parameters with Backlash of 4 counts (0.0001 inch equivalent)
Enable the Axis with Enable button on Step Response Screen
On Console I do a Move1=10
Scope correctly shows a burst of 4 backlash steps followed by the 10 steps
On Console I enter Zero1
Scope shows no pulses
Repeat all above except with Move1=-10
On Console I enter Zero1
Scope shows no pulses

Re: Motor movement during reset of axes

Posted: Thu Jul 28, 2022 4:12 am
by SamMarrocco
I'll try to make a short movie file of what I'm doing. Perhaps a picture will be worth 10,000 words.

>>Before you describe having to move some amount in some direction before zeroing. I understand it micro-moves after every ZeroAxis but are you doing something between ZeroAxis commands?
No. Every ZeroAxis() call causes the movement under the same conditions once the direction has been established with a single move.

Yes, The Y-Axis is Axis 1 in the KFlop. However, I can duplicate the effect with every axis or motor. At first I considered that I may have a hardware issue (i.e., the Gecko 540 Controller I use or my motor) but that was not the case.

I'll try the Zero1 command you suggested, both from a KMotion Console and from my code via Execute and let you know the results asap.
I will also try to duplicate with the steps you tried with your scope and let you know.

Thanks for your patience with this. It's annoying, but interesting.

Re: Motor movement during reset of axes

Posted: Fri Jul 29, 2022 2:01 am
by SamMarrocco
Tom,

I've tried to attached a video demonstrating my "ZeroAxis" issue. However, the zipped file halts uploading as an attechment with "HTTP Error".
Do you have another method for me to send you a video (approx. 200 MB)

I'll have more test information for you tomorrow as well.

Re: Motor movement during reset of axes

Posted: Fri Jul 29, 2022 4:04 pm
by TomKerekes
Hi Sam,

I'd prefer that you perform the tests and explain the results clearly rather than having to watch a video.

It you show me things happening with your App that I don't have that won't help me much to duplicate it to be able to track it down.

But you might upload the video to YouTube and then post the link.

Re: Motor movement during reset of axes

Posted: Sat Jul 30, 2022 8:10 pm
by SamMarrocco
Tom,
I've narrowed down the 'motor movement' issue a bit further.
Some previous workflows have required that I perform Axis.ZeroAxis() during operations. That lead me to a method (which you may remember) of maintaining backlash after ZeroAxis() ops by the following....

1) Save Current Backlash direction and amount to file
2) Perform the ZeroAxis()
3) Load the saved Backlash direction and amount from user persist variables and apply to the axis. This is done with KFlop C code and called with dotnet command Controller.Writeline("Execute3")

This appeared to work fine but doesn't always. Here is what I've found.....

By itself, a dotnet Axis.ZeroAxis() does not cause the odd motor movement.
By itself, Loading the backlash direction and amount from user persist variables and applying it to the axis does not cause the issue.
However, an dotnet Axis.ZeroAxis() followed by Loading the file of Backlash direction and amount from the user persist variablesand applying it to the axis DOES cause the issue.

Below is the core of the code I use to save the backlash amount and direction to user persist variables, and vice versa for loading it back into the KFlop.

I'm going to try to write a standalone test app to verify this, but that may take a bit. Until then, here is the current C Code I use in the KFlop for the loading and saving of backlash amounts and direction.

// Saving to File
#define GPV__AXIS_1_BACKLASH 2
#define GPV__AXIS_1_BACKLASHDIRECTION 3
float Axis1_Backlash;
int Axis1_BacklashDirection;
Axis1_Backlash=ch1->Backlash;
Axis1_BacklashDirection=ch1->BacklashDirection;
persist.UserData[GPV__AXIS_1_BACKLASH] = *(int *) & Axis1_Backlash;
persist.UserData[GPV__AXIS_1_BACKLASHDIRECTION] = *(int *) & Axis1_BacklashDirection;

//Loading from file
#define GPV__AXIS_1_BACKLASH 2
#define GPV__AXIS_1_BACKLASHDIRECTION 3
float Axis1_Backlash;
int Axis1_BacklashDirection;
Axis1_Backlash = *(float *) &persist.UserData[GPV__AXIS_1_BACKLASH];
Axis1_BacklashDirection = *(int *) &persist.UserData[GPV__AXIS_1_BACKLASHDIRECTION];
ch1->Backlash=Axis1_Backlash;
ch1->BacklashDirection=Axis1_BacklashDirection;

An interesting item:
While a DotNet ZeroAxis followed by the load of back lash values moves the motors.
A KMotionCNC ZeroAxis (the button in the UI) then followed by the load of backlash values in my app does NOT move the motors.

Re: Motor movement during reset of axes

Posted: Sun Jul 31, 2022 3:58 pm
by TomKerekes
Hi Sam,

That makes sense. Basically the motor position will be the Destination + Backlash. The ZeroAxis command zeros the Destination and the Backlash. Setting the Backlash to some value will cause a burst of step pulses to move the Backlash amount.

Maybe you could explain what you are trying to accomplish.

The Zero button in KMotionCNC doesn't do anything to the KFLOP Machine coordinates. Instead it changes an offset to make the GCode position zero.