Skip to main content
parth kothiya
Associate III
Apr 10, 2019 1:10 PM UTC
Solved

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

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.
    Brian McKay
    Brian McKayBest answer
    Visitor II
    Apr 11, 2019 1:11 PM UTC

    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

    4 replies

    AvaTar
    Senior III
    Apr 10, 2019 1:45 PM UTC

    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
    Apr 10, 2019 7:23 PM UTC

    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
    Apr 11, 2019 3:22 AM UTC

    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
    Apr 11, 2019 1:11 PM UTC

    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