Skip to main content
parth kothiya
Associate III
April 10, 2019
Solved

C programming steps to auto set PID gains Kp,Ki,Kd using STM32 ?

  • April 10, 2019
  • 3 replies
  • 3669 views

i want to set PID gains by auto tuning process how can i achieve this by using STM32 C code or any eample ?

    This topic has been closed for replies.
    Best answer by Brian McKay

    Yes, you can convert your Simulink into C code for STM32 using Embedded Coder. The code generated is ANSI / ISO C code that is optimized for deployment on embedded systems. You would import the code generated for your algorithm (so auto-tuned PID in this case) into your existing SW project / IDE and integrate it there for deployment to STM32. This is the generic workflow.

    There are some custom workflows you can also look at using STM32-MAT/Target (authored by ST) and Nucleo / Discovery Support packages (authored by MathWorks).

    -b

    3 replies

    AvaTar
    Senior III
    April 10, 2019

    Attach the controlled system, the input and output circuitry, and implement your own algorithms to tune the control parameters.

    Or use a simulation tool like Matlab/Simulink, Mathematica, Maple, Octave, Scilab, etc.

    Brian McKay
    Visitor II
    April 10, 2019

    You can Use Simulink and Control System Toolbox to do this: https://www.mathworks.com/help/control/ug/pid-controller-tuning-in-simulink.html

    parth kothiya
    Associate III
    April 11, 2019

    can i export auto tuning block of simulink in to c code and then use this code in to STM32

    for auto tuning it is possible?

    Brian McKay
    Brian McKayBest answer
    Visitor II
    April 11, 2019

    Yes, you can convert your Simulink into C code for STM32 using Embedded Coder. The code generated is ANSI / ISO C code that is optimized for deployment on embedded systems. You would import the code generated for your algorithm (so auto-tuned PID in this case) into your existing SW project / IDE and integrate it there for deployment to STM32. This is the generic workflow.

    There are some custom workflows you can also look at using STM32-MAT/Target (authored by ST) and Nucleo / Discovery Support packages (authored by MathWorks).

    -b