Skip to main content
karlis
Associate III
December 30, 2017
Question

How to fix Undefined reference to `arm_pid_init_q31', error?

  • December 30, 2017
  • 2 replies
  • 2923 views
Posted on December 30, 2017 at 13:21

Hi, everyone!

I am trying to implement PID controller from arm_math library. I use this code as kind of example for this 

https://stm32f4-discovery.net/2014/11/project-03-stm32f4xx-pid-controller/

  

I am getting error - Undefined reference to `arm_pid_init_q31',

There is nothing much regarding PID in my code, I copied only lines regarding PID.

&sharpinclude <arm_math.h>

&sharpdefine PID_PARAM_KP 10 /* Proporcional */

&sharpdefine PID_PARAM_KI 10 /* Integral */

&sharpdefine PID_PARAM_KD 10 /* Derivative */

uint32_t PID_ERROR;

arm_pid_instance_q31 PID;

PID.Kp = PID_PARAM_KP; /* Proporcional */

PID.Ki = PID_PARAM_KI; /* Integral */

PID.Kd = PID_PARAM_KD; /* Derivative */

arm_pid_init_q31(&PID, 1);

while(1)

{

output_voltage_mv = (3300*VOUT * 21) / 4096;

PID_ERROR = Vreg - output_voltage_mv;

duty_cycle = arm_pid_q31(&PID, PID_ERROR);

}

Can any help please?

#pid #arm_math
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    December 30, 2017
    Posted on December 30, 2017 at 15:25

    Error suggests you need to add the library file to your project, or add in the source files from the library.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    karlis
    karlisAuthor
    Associate III
    January 3, 2018
    Posted on January 03, 2018 at 12:51

    But I have included arm_math.h and this arm_pid_init_q31 is defined in arm_math.h....

    I do not understand why shouldn't it work. If arm_math would not be accessable for project I would get error about that.

    Andrew Neil
    Super User
    January 3, 2018
    Posted on January 03, 2018 at 13:12

    karlis77 wrote:

    But I have included arm_math.h and thisarm_pid_init_q31 is defined (sic?) in arm_math.h....

    Are you sure it's actually defined there ...?

    https://community.st.com/0D50X00009XkWruSAF

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Zt Liu
    Senior III
    January 2, 2018
    Posted on January 02, 2018 at 11:17

    If using keil, you may need to enable your CMSIS-DSP pack.

    Good luck!

    Zt.