Deviation observed on 3+2 axis CNC milling setup.

Moderators: TomKerekes, dynomotion

j.wilson
Posts: 11
Joined: Fri Apr 22, 2022 6:48 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by j.wilson » Tue May 31, 2022 8:54 am

Hi Tom,

Hope you've been good, thanks for all your help.

So an update, we have corrected the axis X and Y Origin issue, I will send an update regarding the deviation error soon.

Regarding the Kanalog integration though I am still facing difficulty.

I am certain I am doing something wrong and really need your help.

I have connected the + to the DAC output 0 and the - and the ground to the ground terminals on JP11 as you suggested.

I have connected A/B channels and to JP1 (A0-, A0+, B0- and B0+ respectively) and Z channel to JP2 (A4+ and A-).

However the drive needs 24v to enable the servo, I have connected the pins to JP8 terminal SW0 and ground on the JP11 ground terminal.

I am attaching a primitive init file I am using with this reply. When I run it on thread 1 to initialize however in the digital I/O window of the Kmotion application I can see that FET Driver 0 (152) is ticked but when I test the voltage across the SW0 and Ground there is no voltage.

Code: Select all

#include "KMotionDef.h"
#include "KflopToKMotionCNCFunctions.c"

main()
{
	ch0->InputMode=ENCODER_MODE;
	ch0->OutputMode=DAC_SERVO_MODE;
	ch0->Vel=166666;
	ch0->Accel=833333;
	ch0->Jerk=3.2e+06;
	ch0->P=0.09;
	ch0->I=1e-05;
	ch0->D=0;
	ch0->FFAccel=0;
	ch0->FFVel=0.001023;
	ch0->MaxI=2700;
	ch0->MaxErr=1000;
	ch0->MaxOutput=2047;
	ch0->DeadBandGain=0;
	ch0->DeadBandRange=0;
	ch0->InputChan0=0;
	ch0->InputChan1=0;
	ch0->OutputChan0=0;
	ch0->OutputChan1=0;
	ch0->MasterAxis=-1;
	ch0->LimitSwitchOptions=0x100;
	ch0->LimitSwitchNegBit=0;
	ch0->LimitSwitchPosBit=0;
	ch0->SoftLimitPos=1e+09;
	ch0->SoftLimitNeg=-1e+09;
	ch0->InputGain0=1;
	ch0->InputGain1=1;
	ch0->InputOffset0=0;
	ch0->InputOffset1=0;
	ch0->OutputGain=1;
	ch0->OutputOffset=0;
	ch0->SlaveGain=1;
	ch0->BacklashMode=BACKLASH_OFF;
	ch0->BacklashAmount=0;
	ch0->BacklashRate=0;
	ch0->invDistPerCycle=1;
	ch0->Lead=0;
	ch0->MaxFollowingError=100000000;
	ch0->StepperAmplitude=20;

	ch0->iir[0].B0=1;
	ch0->iir[0].B1=0;
	ch0->iir[0].B2=0;
	ch0->iir[0].A1=0;
	ch0->iir[0].A2=0;

	ch0->iir[1].B0=1;
	ch0->iir[1].B1=0;
	ch0->iir[1].B2=0;
	ch0->iir[1].A1=0;
	ch0->iir[1].A2=0;

	ch0->iir[2].B0=0.016609;
	ch0->iir[2].B1=0.033219;
	ch0->iir[2].B2=0.016609;
	ch0->iir[2].A1=1.60679;
	ch0->iir[2].A2=-0.673229;

	EnableAxis(0);
	SetBit(152); // Amp Enable X
	SetBit(144); // Amp Enable X
}
I'm not sure what I might be doing wrong, please help.

Regards,
Wilson

User avatar
TomKerekes
Posts: 1935
Joined: Mon Dec 04, 2017 1:49 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by TomKerekes » Tue May 31, 2022 5:07 pm

SW0 is like a switch. It won't provide any voltage. Post a diagram of what you are doing and the specifications for the Drive enable input.
Regards,

Tom Kerekes
Dynomotion, Inc.

j.wilson
Posts: 11
Joined: Fri Apr 22, 2022 6:48 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by j.wilson » Tue Jun 07, 2022 4:39 pm

Hi Tom,

Thanks for the clarification, I managed to get an external power supply hooked up.
Below is the specification of the Drive Enable Input as well as a Diagram of how I have wired everything.
File_000.png
Encoder Details.png
Drive Enable Pins.png
Drive Enable Pins.png (8.04 KiB) Viewed 529 times
DAC input.png
I managed to get the drive and motor communicating with Kmotion but am now stuck with the tuning.
I am also uncertain if the wiring needs any optimization given resistances or anything else.

A strange thing I noticed when I give DAC0=10 and DAC=-10, DAC=100 and DAV=-100 and so on, I notice that the positive and negative voltage supplied between JP11 pin0 and gnd are not identical, it seems the positive always tends to get more juice. Will the offset provision in the Configuration section in kmotion be able to fix this? Am I rushing things, is there any advice you can give me please?

Also if the encoder resolution of the drive helps in any advice it is 23bit(8388608 ppr).

User avatar
TomKerekes
Posts: 1935
Joined: Mon Dec 04, 2017 1:49 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by TomKerekes » Tue Jun 07, 2022 5:01 pm

Hi Wilson,
I managed to get the drive and motor communicating with Kmotion but am now stuck with the tuning.
I am also uncertain if the wiring needs any optimization given resistances or anything else.
Resistances shouldn't matter. Wiring should be short to pick up less noise.
A strange thing I noticed when I give DAC0=10 and DAC=-10, DAC=100 and DAV=-100 and so on, I notice that the positive and negative voltage supplied between JP11 pin0 and gnd are not identical, it seems the positive always tends to get more juice. Will the offset provision in the Configuration section in kmotion be able to fix this? Am I rushing things, is there any advice you can give me please?
Offset should not be an issue the Servo will compensate for it. See here.
Also if the encoder resolution of the drive helps in any advice it is 23bit(8388608 ppr).
I don't think the drive outputs that.
Regards,

Tom Kerekes
Dynomotion, Inc.

j.wilson
Posts: 11
Joined: Fri Apr 22, 2022 6:48 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by j.wilson » Thu Jun 09, 2022 9:05 am

Hi Tom,
Resistances shouldn't matter. Wiring should be short to pick up less noise.
I have ensured that the length of the cables between Kanalog and the drive is under 2 feet.
I have also controlled drive enable and disable using Konnect and it powers on only after being initialized.

I went through the page as well as the link at the bottom.
https://www.cnczone.com/forums/dynomoti ... 4-cnc.html

Definitely exciting stuff, really love the way you've explained the parameters in terms or a car chasing a bike with a brick under the accelerator pedal! It really makes things a whole lot more relatable for people like me. :lol:

I managed to reach the motor tuning step, below are my results.

Configuration:
Configuration.png
Running move the first time:
tuning1.png
Running the move command subsequent times:
tuning2.png
I tried fiddling with the settings but it only seems to make things worse. What do you think I could try optimizing?

j.wilson
Posts: 11
Joined: Fri Apr 22, 2022 6:48 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by j.wilson » Thu Jun 09, 2022 12:57 pm

Fiddled and fiddled. I think I made some progress...
tuning3.png
What do you think?

User avatar
TomKerekes
Posts: 1935
Joined: Mon Dec 04, 2017 1:49 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by TomKerekes » Thu Jun 09, 2022 5:07 pm

Follow the steps here.

Describe what you see in the graphs. Can you see it is nearly unstable?

Describe what you did and what happened, not just the final plot.

Post the Step Response, Filters, and Config Screens so we know what all your parameters are.

Dead band is normally used to help the axis sit still when not moving by lowering the gain for small errors. So a gain more than 1 is unusual. Remove the deadband for now by setting gain to 1 with 0 range.

What is the resolution of your system? How many counts per inch or mm.
Regards,

Tom Kerekes
Dynomotion, Inc.

j.wilson
Posts: 11
Joined: Fri Apr 22, 2022 6:48 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by j.wilson » Wed Jun 15, 2022 12:52 pm

Hi Tom,
Can you see it is nearly unstable?
Yes, I could see that, I just got excited with the progress and shot off that reply, sorry about that.
Describe what you did and what happened, not just the final plot.
Again, I apologies, I took too many things for granted and assumed that you'd be able to decipher things without giving you enough information.
Follow the steps here.
I went through the link you shared. It’s super comprehensive, and really well laid out, it clarified alot of the confusion I had.
Thank you very much!

I followed the steps and here is a breakup of everything I did and the results.

I connected the Drive and servo using a Kanalog, Kflop and Konnect.
Used the Kanalog for DAC out and Encoder feedback (A,B,Z Channel)
Used the Konnect to enable and disable the drive.

Then using the wiki that you shared I did the following.

1. Opened C Program Screen and ran Init.c to enable the Servo.

Code: Select all

#include "KMotionDef.h"
#include "AdjustSoftLimits.c"
#include "KflopToKMotionCNCFunctions.c"

#define QA 26					// define to which IO bits the AB signals are connected
#define QB 27

main()
{
	ch0->InputMode = ENCODER_MODE;
	ch0->OutputMode = DAC_SERVO_MODE;
	ch0->Vel = 166666;
	ch0->Accel = 833333;
	ch0->Jerk = 3200000;
	ch0->P = 0.09;
	ch0->I = 0.00001;
	ch0->D = 0;
	ch0->FFAccel = 0;
	ch0->FFVel = 0.001023;
	ch0->MaxI = 2700;
	ch0->MaxErr = 1000;
	ch0->MaxOutput = 2047;
	ch0->DeadBandGain = 0;
	ch0->DeadBandRange = 0;
	ch0->InputChan0 = 0;
	ch0->InputChan1 = 0;
	ch0->OutputChan0 = 48;
	ch0->OutputChan1 = 48;
	ch0->MasterAxis = -1;
	ch0->LimitSwitchOptions = 0x100;
	ch0->LimitSwitchNegBit = 0;
	ch0->LimitSwitchPosBit = 0;
	ch0->SoftLimitPos = 1e+09;
	ch0->SoftLimitNeg = -1e+09;
	ch0->InputGain0 = 1;
	ch0->InputGain1 = 1;
	ch0->InputOffset0 = 0;
	ch0->InputOffset1 = 0;
	ch0->OutputGain = 1;
	ch0->OutputOffset = 7;
	ch0->SlaveGain = 1;
	ch0->BacklashMode = BACKLASH_OFF;
	ch0->BacklashAmount = 0;
	ch0->BacklashRate = 0;
	ch0->invDistPerCycle = 1;
	ch0->Lead = 0;
	ch0->MaxFollowingError = 100000000;
	ch0->StepperAmplitude = 20;

	ch0->iir[0].B0 = 1;
	ch0->iir[0].B1 = 0;
	ch0->iir[0].B2 = 0;
	ch0->iir[0].A1 = 0;
	ch0->iir[0].A2 = 0;

	ch0->iir[1].B0 = 1;
	ch0->iir[1].B1 = 0;
	ch0->iir[1].B2 = 0;
	ch0->iir[1].A1 = 0;
	ch0->iir[1].A2 = 0;

	ch0->iir[2].B0 = 0.016609;
	ch0->iir[2].B1 = 0.033219;
	ch0->iir[2].B2 = 0.016609;
	ch0->iir[2].A1 = 1.60679;
	ch0->iir[2].A2 = -0.673229;
	
	InitAux();
	AddKonnect(0, &VirtualBits, VirtualBitsEx);
	AddKonnect(1, VirtualBitsEx + 1, VirtualBitsEx + 2);

	EnableAxis(0);
	SetBit(152);				// Amp Enable X
	SetBit(48);					// Enable Servo
}

2. Opened the ‘Configuration’ Screen and loaded KanalogDAC.mot
b1.png
3. Opened the ‘Step Response’ Screen, set max limits (output to 2000, integrator to 200, error to 20,000) enabled the servo and began tuning.

4. Found Max Velocity: Selected a Large step size (100000), Large Acceleration (10,000,000), Larger Jerk (100,000,000). Plotting and monitoring a ‘Velocity, Output vs Time, secs’ graph, I slowly Increased ’V’ (Velocity) and P (Gain) in small increments until the motor was maxed out, (this was the most frightening I’ve done in my life). Then I dialed back ‘V’ to about 50% of the maximum Velocity and gradually reduced the P Gain till it was just a little more than what was needed for the motor to achieve 50% of its maximum velocity. Ie. 460,000

5. Found Max Acceleration: Plotting and monitoring a ‘Command, Position, Output Command vs Time, Sec’ Graph, I dialed down the value till I noticed that the ‘Red’ (Position Line) Stated to get affected (acceleration slowing down) and from that limit I dialed it down 20%. Ie. 7,200,000

6. Found the Max Jerk: Used the suggestion on your wiki and set J at A/0.020. ie. 360,000,000
10.png
7. Increased the Test Move Step ‘time’ to 0.9 second and ‘size’ to 120,000 position units to see the graph more clearly. Tweaked PID and motion profile and finally got this as a result.
12.png
8. Using the ‘Position Error, Output vs Time, secs’ graph, I set the ‘Max Following Error’ to 20% more than what was recorded. Ie. 4,800
poserror.png
b4.png
Here are the screenshots of the ‘Filters’ screen as well
filters.png
Also here is the resolution that you asked for as well.

~10000 position units per motor rev (disabled the axis and rotated the servo 360 degrees)
1:1 gear reduction from motor to lead screw
0.19685 inch (5 mm) lead screw pitch

Axis Resolution = 10,000 x 1 / 0.19685 = 50,800.1 steps/inch

I have 3 questions.
1. Do you have any feedback on the graph shown in step seven?
2. Also the drive manual states that the drive and motor is capable of (8388608 ppr) but when manually rotating the servo with an input gain of 1 it only records 10,000 position units.
3. Since all tuning begins with setting a maximum velocity and
The KFLOP parameters are used for 3rd order motions. These include things like: Jogging, Homing, and GCode Rapids (G0).
Does this mean that this tuning doesn't affect machine operations (G01 operations) when running a GCODE program?
If so does one need to do any motor tuning or any other procedures to optimize these other operations?

User avatar
TomKerekes
Posts: 1935
Joined: Mon Dec 04, 2017 1:49 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by TomKerekes » Wed Jun 15, 2022 9:27 pm

Hi,

Thanks for the detailed explanation.

Note you don't really need any C Program at this stage. You could have just used the Digital IO Screen to enable your Drive.
1. Do you have any feedback on the graph shown in step seven?
Well you changed parameters laterso I'm not sure it is worth commenting. But mainly the max Accel was not being used. The acceleration is purely jerk limited. To ramp up to that acceleration would take 0.05 sec. And back down to zero another 0.05 sec total of 0.1 seconds. Getting up to max acceleration and back down would exceed your max velocity. Hence the move is Jerk limited. If you plot commanded Velocity and zoom in:

vel.png
vel.png (11.42 KiB) Viewed 417 times
you should see that it is fully up to max velocity in ~ 0.05 sec not 0.1 seconds.

We have a 3rd order Trip Planning tool to help understand motion profiles which includes an acceleration plot. See Video. Here is a solution with your parameters:


accel.png

Note the Acceleration peaks at 23e6 counts/sec no where near the 200e6 max setting.

Even 23e6 is very high. at 50800 counts/inch that is 453 in/sec2 or almost 1.2G

What are your velocity and acceleration requirements?
2. Also the drive manual states that the drive and motor is capable of (8388608 ppr) but when manually rotating the servo with an input gain of 1 it only records 10,000 position units.
I'm not sure I believe that or possibly specmanship based on some theoretical interpolation. The drive probably has a setting for this set for 2500 cycles per rev. Too high of a resolution will limit max velocity. KFLOP has a max count rate of 1e6 counts/sec. You are already testing at 0.55e6 counts/sec.

Another minor note is that to go 55000 cnts/sec (10.8 in/sec, 650ipm) the output is going to about 75%. You might be able to go a bit faster but not much or there will not be enough margin).
3. Since all tuning begins with setting a maximum velocity and Does this mean that this tuning doesn't affect machine operations (G01 operations) when running a GCODE program?
If so does one need to do any motor tuning or any other procedures to optimize these other operations?
Basically yes. See here.

Note you might be focusing on velocities and accelerations too much at this stage. The process is to get some reasonable and conservative velocities and accelerations, then optimize tuning for minimal errors. Then go back and push velocities and acceleration to see what you can achieve without causing excessive error if needed.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

j.wilson
Posts: 11
Joined: Fri Apr 22, 2022 6:48 am

Re: Deviation observed on 3+2 axis CNC milling setup.

Post by j.wilson » Tue Aug 02, 2022 6:48 am

Hi Tom,

Sorry for the silence, it has been quite a hectic month. I hope all has been well with you.

I'm now back on task so without further ado, here is an update.

So what I had done in my previous post between point 6 and 7 was basically:

1. Pushed the velocity up to 550,000 from 460,000. - I assumed since the maximum velocity was 900,000, I thought I had a bit of wiggle room and pushed it up a bit more.
2. Plotting a ‘Velocity Output vs Time, secs’ I noticed that the operation was completing before the servo could reach the full speed so I increased the ‘step size’ to observe the results better.
3. Increased Acceleration till I noticed that the curve would not get any steeper.
4. Increased Jerk till I noticed the curves at the beginning and the end of the acceleration incline seemed to match between the ‘Command’ and ‘Position’.
5. Reduced the P gain till the servo would freeze and then bumped it back up a tiny bit.

Using your most recent advice regarding the max acceleration and using the TripWPF program:

1. Entered the current Max Jerk, Max Acceleration, Max Velocity and Distance and observed the graphs.
2. I noticed what you told me about the ‘Max Acceleration’ being capped by ‘Max Jerk’ and so reduced the ‘Max Jerk’ till the ‘Max Acceleration’ was not restricted and then reduced it a bit more to give a buffer
3. Reduced ‘Max Acceleration’ till the ‘Max Velocity’ curve looked more gradual
4. Reduced ‘Max Jerk’ again to further smoothen the curve and give a slight buffer to ‘Max Acceleration’ as well.

Then I did some calculation with what I would like to be the Max Velocity and the Max Acceleration.

Taking into consideration that
Even 23e6 is very high. at 50800 counts/inch that is 453 in/sec2
I aimed for a ‘Max Acceleration’ of 200 inches/s^2
200 (inches per second square) * 50800 (counts per inch) = 10,160,000
I rounded that down and set the ‘Max Acceleration’ to ’10,000,000’

Then drawing inspiration from
Then go back and push velocities and acceleration to see what you can achieve without causing excessive error if needed.
I aimed for 13 inches/s as ‘Max Velocity’
13 (inches per second) * 50800 (counts per inch) = 660,400
Ambitiously I bumped up the ‘Max Velocity’ to ‘700,000’ but the servo stalled so I increased the P gain in increments of 0.01 and then when it was stable I added an extra 20% to be sure. Ie. A value of 0.37 finally

Then I…
1. Fiddled ever so slightly with your wonderful TripWPF program updated the new ‘Max Velocity’, ‘Max Acceleration’ ‘Max Deceleration’ as well and experimented with ‘Max Jerk’ to smoothen the graph
2. Reduced the P gain till the servo stalled and bumped it back up a bit
3. Removed I and D for now since it didn’t seem to have much impact

And here are the final results.
20.png
23.png
22.png
21.png
Do you think I am moving in the right direction?
Did I make any mistakes?
Do you have any feedback?

Post Reply