cancel
Showing results for 
Search instead for 
Did you mean: 

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

parth kothiya
Senior

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

1 ACCEPTED SOLUTION

Accepted Solutions
Brian McKay
Associate III

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

View solution in original post

4 REPLIES 4
AvaTar
Lead

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
Associate III

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

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
Associate III

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