00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. July 2011 00005 * $Revision: V1.0.10 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_pid_init_f32.c 00009 * 00010 * Description: Floating-point PID Control initialization function 00011 * 00012 * 00013 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 00014 * 00015 * Version 1.0.10 2011/7/15 00016 * Big Endian support added and Merged M0 and M3/M4 Source code. 00017 * 00018 * Version 1.0.3 2010/11/29 00019 * Re-organized the CMSIS folders and updated documentation. 00020 * 00021 * Version 1.0.2 2010/11/11 00022 * Documentation updated. 00023 * 00024 * Version 1.0.1 2010/10/05 00025 * Production release and review comments incorporated. 00026 * 00027 * Version 1.0.0 2010/09/20 00028 * Production release and review comments incorporated. 00029 * ------------------------------------------------------------------- */ 00030 00031 #include "arm_math.h" 00032 00051 void arm_pid_init_f32( 00052 arm_pid_instance_f32 * S, 00053 int32_t resetStateFlag) 00054 { 00055 00056 /* Derived coefficient A0 */ 00057 S->A0 = S->Kp + S->Ki + S->Kd; 00058 00059 /* Derived coefficient A1 */ 00060 S->A1 = (-S->Kp) - ((float32_t) 2.0 * S->Kd); 00061 00062 /* Derived coefficient A2 */ 00063 S->A2 = S->Kd; 00064 00065 /* Check whether state needs reset or not */ 00066 if(resetStateFlag) 00067 { 00068 /* Clear the state buffer. The size will be always 3 samples */ 00069 memset(S->state, 0, 3u * sizeof(float32_t)); 00070 } 00071 00072 } 00073