1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
8 * Title: arm_pid_init_f32.c
10 * Description: Floating-point PID Control initialization function
13 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
15 * Version 1.0.10 2011/7/15
16 * Big Endian support added and Merged M0 and M3/M4 Source code.
18 * Version 1.0.3 2010/11/29
19 * Re-organized the CMSIS folders and updated documentation.
21 * Version 1.0.2 2010/11/11
22 * Documentation updated.
24 * Version 1.0.1 2010/10/05
25 * Production release and review comments incorporated.
27 * Version 1.0.0 2010/09/20
28 * Production release and review comments incorporated.
29 * ------------------------------------------------------------------- */
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.
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.
51 void arm_pid_init_f32(
52 arm_pid_instance_f32 * S,
53 int32_t resetStateFlag)
56 /* Derived coefficient A0 */
57 S->A0 = S->Kp + S->Ki + S->Kd;
59 /* Derived coefficient A1 */
60 S->A1 = (-S->Kp) - ((float32_t) 2.0 * S->Kd);
62 /* Derived coefficient A2 */
65 /* Check whether state needs reset or not */
68 /* Clear the state buffer. The size will be always 3 samples */
69 memset(S->state, 0, 3u * sizeof(float32_t));