ADI Trinamic Blog

We transform digital information into physical motion.

 
  • Newsletter
  • Blog Ethics
  • Legal/Impressum
  • Main Website
Menu
  • Newsletter
  • Blog Ethics
  • Legal/Impressum
  • Main Website
  • Driving a Linear Stage With the TMC4671 – Controller Tuning

    Application Setup

    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.

    • Step response for default values
      Figure 1: Step response for default values
    • Step response reduced data range
      Figure 2: Step response with reduced data range
    • Step response with increased 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.

    • Step response Flux untuned
      Figure 4: Step response Flux untuned
    • Step response Flux tuned
      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
    • Velocity P100
      Figure 9: Velocity P100
    • Velocity P500
      Figure 10: Velocity P500
    • Velocity P1000
      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!

    Share this:

    • Twitter
    • Facebook
    • LinkedIn
    • Pinterest
    • Print
    • Email

    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”

    • Driving a linear stage with the TMC4671 - Firmware Adaptation says:
      February 28, 2020 at 4:17 pm

      […] our last blog post, we were able to determine stable P-I-parameters for our cascaded controller loop. With that […]

    • CJ says:
      March 27, 2020 at 2:54 am

      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?

    • Klemens Konhäuser says:
      March 27, 2020 at 9:24 am

      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

    • CJ says:
      March 27, 2020 at 4:05 pm

      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.

    • Klemens Konhäuser says:
      March 27, 2020 at 4:35 pm

      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

    • Stephan says:
      July 12, 2020 at 1:32 am

      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

    • Klemens Konhäuser says:
      July 13, 2020 at 7:31 am

      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

Recent Posts

  • Guest Blog: UBC Thunderbots
  • Guest Blog: TURAG
  • Guest Blog: School of Engineering Telecom Physics University of Strasbourg
  • Guest Blog: STAR Dresden
  • Pushing the Limits of Stepper Motor Control in 3D Printing

Social

  • View trinamic.mc’s profile on Facebook
  • View Trinamic_MC’s profile on Twitter
  • View trinamic’s profile on GitHub
  • View UC4SHA5_GAw1Wbm2T2NWpWbA’s profile on YouTube

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Newsletter

 

Info

Waterloohain 5
22769 Hamburg
+49 40 514 806 40

Tags

3D printer 3d printing arduino BLDC cDriver code code snippet coolStep drive Driver ease of use ethercat eval kit evaluation kit Field Oriented Control FOC GUI guide heliostat How-To IC linear stage motion controller motor driver open source hardware programming rtmi servo servo controller IC setup silentstepstick stealthChop stepper stepper motor stepper motor driver stepper motor driver ic stepper motors technology TMC4671 tmc5130 TMCL TMCL-IDE TRINAMIC TRINAMIC Motion Control tuning

Tag Cloud

    3D printer 3d printing arduino BLDC cDriver code code snippet coolStep drive Driver ease of use ethercat eval kit evaluation kit Field Oriented Control FOC GUI guide heliostat How-To IC linear stage motion controller motor driver open source hardware programming rtmi servo servo controller IC setup silentstepstick stealthChop stepper stepper motor stepper motor driver stepper motor driver ic stepper motors technology TMC4671 tmc5130 TMCL TMCL-IDE TRINAMIC TRINAMIC Motion Control tuning

Pages

  • Blog Ethics
  • Newsletter
  • Player Embed
  • Search Videos
  • User Videos
  • Video Category
  • Video Tag

Categories

  • Competition
  • Guest blog
  • Industry News
  • Jobs
  • Myths about Motors
  • Open Source Hardware
  • Products
  • Projects
    • DIY
    • University Projects
  • Research
  • Social
  • Software
  • technology
  • Trade Shows
  • Tutorial
    • Code Snippet
  • Uncategorized

Copyright © 2015 TRINAMIC BlogTheme created by PWT. Powered by WordPress.org

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.