PID Problems: Jerking while in steady run state

More
29 Jan 2024 14:36 - 29 Jan 2024 14:37 #291893 by alangibson
Hello all,

I'm working on finding PID settings for my XYYZ cartesian plasma cutter with only limited success. I'm hoping someone will spot my error because I can't see it.

I've (apparently) gotten close to perfection by setting P=60 and all others to 0. It runs with very little follow error, but the motor 'ticks' by slamming briefly into reverse roughly every second. Oscilloscope shots are attached.

(Sorry for the cell phone screen grabs. No screen shot tool on my minimal install of Bookworm.)

I assume this is due to it correcting accumulated error, but I haven't been able to figure out how to stop the error accumulating. Literally any change to I, D, or the FFs result in more following error.

I tried running automatic tuning, but it never finds a configuration that doesn't oscillate. Using tune-type 0 seems to work the best. With tune-type == 0, oscillations are on the order fo 0.10s of mm. With tune-type == 1, oscillations are on the order of 10s of mm. What I got for tune-type 1 is attached.

A complicating factor here is that setup is unusual. The first oddity is that my motors are just setting on the bench; there's no load on them. The second odditiy is that I'm using kinda-closed loop steppers. I'm getting position feedback from TMC5041 motion controllers but there is no physical encoder. 

Here is my complete configuration in the my-plasma directory, along with the driver source code. Note that I'm only playing with the X axis right now.

github.com/alangibson/hotshot-driver-linuxcnc

Thanks in advance for any help you can give.
Attachments:
Last edit: 29 Jan 2024 14:37 by alangibson.

Please Log in or Create an account to join the conversation.

More
29 Jan 2024 20:27 - 29 Jan 2024 20:32 #291930 by alangibson
I've dug deeper with the oscilloscope. I found that with FFP1=1 and all other PID settings set to 0, the velocity command from LinuxCNC and the velocity reported back from the TMC5041 match pretty much perfectly.

However, the position commanded by joint.0.pos-cmd is consistently 1/5th that reported by the TMC5041. Given the velocity commanded, the TMC5041 is right and LinuxCNC is wrong. What I'm seeing on the scope is that, given a velocity of 25 mm/sec, joint.0.pos-cmd will move about 5 mm while the TMC5041 will report about 25 mm. If I simply divide the TMC5041 position feedback by 5 in the driver code then there is virtually 0 tracking error.

I have no idea why this would be so. I'm going to review the configuration again.
Last edit: 29 Jan 2024 20:32 by alangibson.

Please Log in or Create an account to join the conversation.

More
29 Jan 2024 20:38 #291932 by tommylight
What feedback do the drivers provide?

Please Log in or Create an account to join the conversation.

More
29 Jan 2024 21:17 - 29 Jan 2024 21:19 #291936 by alangibson
They provide actual velocity and actual position as an integer of microsteps. So you have to convert back and forth between mm and microsteps. I'm looking for a bug there now. It's the same code doing the conversion for the velocity and position so I don't think I'm going to find one.

What I find odd though is that LinuxCNC's own position and velocity numbers don't seem to agree. AFAICT it is reporting that it's only gone 5 mm in a second while also traveling at a velocity of 25 mm/sec. I'm sure I'm misconfiguring and/or misinterpreting something. I just haven't found what it is yet.
Last edit: 29 Jan 2024 21:19 by alangibson.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
30 Jan 2024 12:00 #291972 by alangibson
I'm at the point where this looks like it's not a PID problem. It runs with no jerk, but still too much following error with FF1=0.29. So there is definitely some weird scaling issue somewhere. halscope reports that pos-cmd indeed changes at about 20 - 30% of the reported velocity. 

Does anyone have any idea why this would be so?

Please Log in or Create an account to join the conversation.

More
30 Jan 2024 13:51 #291981 by alangibson
I just generated a new config with Stepconf and lightly modified it just to make it work with the TMC5041. I did a few jog runs with jog set at different speeds. halscope still shows that pos-cmd always moves at some fraction of vel-cmd. I'm clearly misunderstanding something because I have no notion why this would be so.

Please Log in or Create an account to join the conversation.

More
30 Jan 2024 21:01 - 30 Jan 2024 22:02 #292015 by alangibson
I've confirmed that the velocity numbers from LinuxCNC are correct. I hadn't noticed at first that ddt = 2.5 in halscope for the motor-position-cmd when jogging at 2.5mm/sec. I was getting around ddt = 7 from the TMC5041. I just entered 0.29 as a conversion factor in my code so I can get back to working on the PID.

With FF1 = 0.8 and P = 20 the motor no longer reverses but it does still pulse. I've attached my current best halscope screenshot. It looks like the PID only really tries to get rid of error every second or so. No clue why. Any advice on how to keep error from accumulating as shown here would be appreciated. 

 

EDIT: Removing the conversion factor from the code and setting FF1=0.349 and P=20, I get this graph. There's very little error but the weird pulsing persists.

 
Attachments:
Last edit: 30 Jan 2024 22:02 by alangibson.

Please Log in or Create an account to join the conversation.

More
31 Jan 2024 10:39 - 31 Jan 2024 10:50 #292057 by alangibson
Apparently the TMC5041 internal clock is wildly inaccurate. There's a section in the manual that I missed that gives a formula for adjusting the velocity that needs to be applied every 100ms to keep the velocity accurate. With that done, the TMC5041 position numbers track the LinuxCNC motor-pos-cmd very well. 

I'm now trying to tune the PID. I'm still seeing this occasional pulsing with FF1=1 and P=10.

 
Attachments:
Last edit: 31 Jan 2024 10:50 by alangibson.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
31 Jan 2024 12:44 - 31 Jan 2024 13:04 #292063 by alangibson
With FF1=1 and P=40, f-error is usually less than 0.05 when you exclude the pulses. 

 

Zooming in you can see that it's definitely the PID commanding a dip in velocity.

 

Adding any I just makes the motor jitter. Does anyone have any ideas on how to proceed?

EDIT: I just learned a valuable lesson about scaling your values correctly. When I change the division on my driver's position feedback I can see that there is a weird bump that's probably causing the issue.

 
Attachments:
Last edit: 31 Jan 2024 13:04 by alangibson.

Please Log in or Create an account to join the conversation.

More
31 Jan 2024 13:31 #292065 by tommylight
Just a stab in the dark, but TMC drives use several features to lower the noise/vibrations that cause positional inaccuracies as documented in their PDF documentation, so try disabling those and check if that helps.

Please Log in or Create an account to join the conversation.

Time to create page: 1.727 seconds
Powered by Kunena Forum