-
Driving a Linear Stage With the TMC4671 – Controller Tuning
Welcome back to my blog post series! I previously described how I set everything up in the post: Driving a Linear Stage With the TMC4671 – Setup. Today I will show you how I tuned my controller gains for torque/flux-, velocity- and position-mode.
In order to do this, I use the USB-2-RTMI adapter and the TMCL-IDE. I start with the current controllers and use the torque/flux tuning tool.
I set a target voltage of 1000 and monitor the step response. The red line displays my voltage reference while the blue line shows the current rising with lowpass behavior. The algorithm estimates the inductance and resistance of the motor from the step response. The green line displays the fitting result for a first order lowpass with estimated parameters. Basically, the green line should fit well to the noisy blue line. If I see a bad fitting result, I can either perform the measurement again or modify the data range.
In the first picture, we see the step response for the default values. The second picture shows a bad fitting result because I reduced the data range. When I increase the data range again I get good values as seen in the third picture.
- Figure 1: Step response for default values
- Figure 2: Step response with reduced data range
- Figure 3: Step response with increased data range
My controller parameters are automatically calculated and displayed in the bottom right. I can set them directly with the button “Set Parameters”.
I can check my controller performance with the step response tool by setting a small but good visible flux target. I chose 1000 here and measurement time of 1000 samples. Current controllers are pretty dynamic and will reach their target value after a few PWM cycles if the voltage limitation is not tripped. Here are two different step responses for different controller parameters.
- Figure 4: Step response Flux untuned
- Figure 5: Step response Flux tuned (1000 samples)
- Figure 6: Step response Flux tuned (100 samples)
Figure 7: PI control torque – tuned I can now proceed with my velocity controller tuning. For this, I need to change my settings in the step response tool to velocity target and velocity actual. My reference value is now a little lower at 100 rpm. Since I selected PHI_M_ABN for velocity selection, the real mechanical velocity is displayed. I set PID_VELOCITY_P to 100 as a starting value and increase the value until I end up at 50% of the step response. After that, I increase the I-parameter concluding with P = 3000 and I = 2200.
Figure 8: Velocity PHI_M_ABN selection - Figure 9: Velocity P100
- Figure 10: Velocity P500
- Figure 11: Velocity P1000
- Figure 12: Velocity tuning good
With that tuning result, I start tuning my position control loop. I set a small P parameter (e.g. 10) while velocity mode is still active. Then I open the position mode dialog to reset the actual position with the “Clear” button. In order to not drive into the end stop, I do this in the middle of my traveling distance.
Figure 13: Position p start Figure 14: Resetting the actual position with the ‘clear’ button Now I use the step response tool to tune my position controller. Before applying a higher gain, I check my velocity limit in PID_VELOCITY_LIMIT. This should be a value the drive should actually be capable of driving. For this setup, it is 200 rpm as I chose mechanical angle PHI_M_ABN for velocity selection.
Figure 15: Checking velocity limit PID_VELOCITY_LIMIT Now I can set up the step response tool for position control loop. I set POSITION_SELECTION in the selectors-section to phi_m_abn and choose a target value that represents one full revolution of my motor: 65536.
Figure 16: Setting the position selector to phi_m_abn I open the step response tool again and evaluate the result of P = 10. As I’m not satisfied with the result, I increase P to 30. As seen below, the result already looks better but there is room for improvement since the target value is not yet reached. Thus, I set the gain to 60. This yields very good results as we reach our target value of one revolution and do not overshoot the target position.
- Figure 17: Position step P10
- Figure 18: Position step P30
- Figure 19: Position step P60
Figure 20: Position mode unstable If I increase the gain too much (e.g. P = 30,000 as seen above), the cascade gets unstable and the drive gets noisy. This resulted in the slide not reaching the actual target position as the feedback of the controller is too strong. This is not acceptable. Think about a CNC-mill for example. What you absolutely do not want is a cut where none should exist. This is why I stick to my previous results of P = 60.
Now I can do some tests with the position mode dialog driving back and forth. I can monitor the position in the position graph.
Monitoring the position using the position graph With these results, I can start developing some C-code for my firmware using the Trinamic API. I will see you in the next blog post, where I will show you my code and talk a little bit about the functions I used. See you there!
Related
February 26, 2020 / Klemens Konhäuser / 7
Categories: Products, Software, technology, Tutorial
Tags: code, code snippet, drive, eval kit, evaluation kit, Field Oriented Control, FOC, GUI, guide, How-To, IC, linear stage, programming, rtmi, servo, servo controller IC, setup, TMC4671, TMCL-IDE, tuning
Driving a Linear Stage With the TMC4671 – Setup Driving a linear stage with the TMC4671 – Firmware Adaptation
Comments are currently closed.
7 thoughts on “Driving a Linear Stage With the TMC4671 – Controller Tuning”
[…] our last blog post, we were able to determine stable P-I-parameters for our cascaded controller loop. With that […]
Hello,I have a problem that , I set the selectors box like Figure 16.
And I opened the position mode box did what the video above did.
But my Step two phase motor position did not work,and the PID_ACTUAL_POSITION in the position graph still zero.
Did I miss something,and How to set the position mode?
Hey CJ,
thank you for your question!
You can set the position mode in the TMCL-IDE (and any other motion mode) either at TMC4671-EVAL > Axis0 > Settings > Selectors > 0x63 MODE_MOTION or use the Register Browser and look for Register 0x63 where you can set the motion mode as well.
To get some more insight on your project could you please answer the following questions:
What kind of setup are you using besides the stepper motor (e.g. Landungsbruecke, 4671 Eval, USB-2-RTMI-adapter, ABN-encoder)?
Were you able to turn the motor in Open-loop- and later Torque-mode as described in the setup blogpost: https://blog.trinamic.com/2020/02/25/driving-a-linear-stage-with-the-tmc4671/ ?
Did you tune the P/I-parameters for torque/flux, velocity and position via the step-response-tool so they fit your motor?
If yes: Did the motor move for any of those step responses? (It should move during velocity Tuning, ideally with target velocity, and move to the target position during position tuning)
Did you specify a target position either using the position mode window (s. figure 14 of the blog) or the register browser?
Best regards
Klemens
Hi,Klemens Konhäuser
I’m using the Landungsbruecke .
And I follow this video https://www.youtube.com/watch?v=g2BHEdvW9bU ,and it works.
But when I follow the step above ,I still can not set the position mode well.
May I have your email ,I want to sent the pictures to you.So that we can solve this problem easily.
Hey CJ,
you can create a support ticket on the main page (trinamic.com) using the orange support button on the bottom right.
Mention me in there so it will be sent to me later.
Best regards
Klemens
Do you think I could use your approache with a bldc motor with 3 internal hall sensor and a TMC-UPS-xAxV-EVAL board?
I too have a linear actuator but not a stepper motor but a bldc motor.
Thanks
Hi Stephan,
this should be possible when you reconfigure the application for your setup. (E.g. Nr of polepairs, Hall as feedback instead of ABN and so on)
The statemachine should the work the same.
If you have more detailed questions you can always file a support-ticket as well!
Best regards