]> git.gag.com Git - fw/stlink/blob - exampleF4/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_init_f32.c
Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / ControllerFunctions / arm_pid_init_f32.c
1 /* ----------------------------------------------------------------------   
2 * Copyright (C) 2010 ARM Limited. All rights reserved.   
3 *   
4 * $Date:        15. July 2011  
5 * $Revision:    V1.0.10  
6 *   
7 * Project:          CMSIS DSP Library   
8 * Title:            arm_pid_init_f32.c   
9 *   
10 * Description:  Floating-point PID Control initialization function   
11 *                                 
12 *   
13 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 *  
15 * Version 1.0.10 2011/7/15 
16 *    Big Endian support added and Merged M0 and M3/M4 Source code.  
17 *   
18 * Version 1.0.3 2010/11/29  
19 *    Re-organized the CMSIS folders and updated documentation.   
20 *    
21 * Version 1.0.2 2010/11/11   
22 *    Documentation updated.    
23 *   
24 * Version 1.0.1 2010/10/05    
25 *    Production release and review comments incorporated.   
26 *   
27 * Version 1.0.0 2010/09/20    
28 *    Production release and review comments incorporated.   
29 * ------------------------------------------------------------------- */
30
31 #include "arm_math.h"
32
33  /**   
34  * @addtogroup PID   
35  * @{   
36  */
37
38 /**   
39  * @brief  Initialization function for the floating-point PID Control.  
40  * @param[in,out] *S points to an instance of the PID structure.  
41  * @param[in]     resetStateFlag  flag to reset the state. 0 = no change in state & 1 = reset the state.  
42  * @return none.  
43  * \par Description:  
44  * \par   
45  * The <code>resetStateFlag</code> specifies whether to set state to zero or not. \n  
46  * The function computes the structure fields: <code>A0</code>, <code>A1</code> <code>A2</code>   
47  * using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd)   
48  * also sets the state variables to all zeros.   
49  */
50
51 void arm_pid_init_f32(
52   arm_pid_instance_f32 * S,
53   int32_t resetStateFlag)
54 {
55
56   /* Derived coefficient A0 */
57   S->A0 = S->Kp + S->Ki + S->Kd;
58
59   /* Derived coefficient A1 */
60   S->A1 = (-S->Kp) - ((float32_t) 2.0 * S->Kd);
61
62   /* Derived coefficient A2 */
63   S->A2 = S->Kd;
64
65   /* Check whether state needs reset or not */
66   if(resetStateFlag)
67   {
68     /* Clear the state buffer.  The size will be always 3 samples */
69     memset(S->state, 0, 3u * sizeof(float32_t));
70   }
71
72 }
73
74 /**   
75  * @} end of PID group   
76  */