STM32F1 CMSIS DSP Controller Functions

Started by tha, July 23, 2021, 07:40:16 AM

Previous topic - Next topic

tha

file:///D:/System%20Workbench/STM32CubeF1-master/Drivers/CMSIS/docs/DSP/html/group__PID.html




Description

A Proportional Integral Derivative (PID) controller เป็น a generic feedback control loop mechanism ถูกใช้อย่างแพร่หลายใน industrial control systems. A PID controller เป็น the most commonly used type of feedback controller.

ชุดของ functions นี้จัดให้มีใช้ (PID) controllers สำหรับ Q15, Q31, และ floating-point data types. The functions ทำงานบน a single sample of data และแต่ละการเรียกไปยัง the function จะคืนกลับ a single processed value. S ชี้ไปยัง an instance ของ the PID control data structure. in เป็น the input sample value. The functions คืนกลับ the output value.

tha

Algorithm:

   y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
   A0 = Kp + Ki + Kd
   A1 = (-Kp ) - (2 * Kd )
   A2 = Kd 

โดยที่ Kp คือ proportional constant, Ki คือ Integral constant และ Kd คือ Derivative constant

             

The PID controller คำนวณ an "error" value เป็นความแตกต่างระหว่าง the measured output และ the reference input. The controller พยายามทำให้ต่ำ the error โดยการปรับ the process control inputs. The proportional value กำหนด the reaction ต่อ the current error, the integral value กำหนด the reaction ขึ้นอยู่กับ the sum of recent errors, และ the derivative value กำหนด the reaction ตามอัตราที่ the error ที่กำลังเปลี่ยนอยู่.

ปล. ลองดูที่ไฟล์ก็ได้ มีอยู่นิดเดียว หรือดูที่นี่ก็ได้ เขาใช้ CMSIS DSP PID อยู่ ขอบคุณนะครับ ขอเผยแผ่สักหน่อย
      https://stm32f4-discovery.net/2014/11/project-03-stm32f4xx-pid-controller/

tha

Instance Structure

The Gains A0, A1, A2 และ state variables สำหรับ a PID controller ถูกเก็บเข้าด้วยกันใน an instance data structure. A separate instance structure ต้องถูกกำหนดสำหรับแต่ละ PID Controller. มี separate instance structure declarations สำหรับแต่ละ the 3 supported data types.

Reset Functions

มี an associated reset function อีกด้วยสำหรับแต่ละ data type ซึ่งจะเคลียร์ the state array.

Initialization Functions

มี an associated initialization function อีกด้วยสำหรับแต่ละ data type. The initialization function ดำเนินการการทำงานต่อไปนี้:
   •   เริ่มต้น the Gains A0, A1, A2 จาก Kp,Ki, Kd gains.
   •   เอาศูนย์ออกจากค่าใน the state buffer.

Instance structure ไม่สามารถถูกวางลงใน a const data section และขอแนะนำให้ใช้ the initialization function.

Fixed-Point Behavior

ต้องใช้ความระมัดระวังเมื่อใช้ the fixed-point versions of the PID Controller functions. โดยเฉพาะอย่างยิ่ง, the overflow and saturation behavior of the accumulator ที่ใช้ในแต่ละ function ต้องถูกพิจารณา. อ้างอิงถึง the function specific documentation ข้างล่างสำหรับแนวทางการใช้งาน.


tha



Returns

ส่งออก processed output sample.

References arm_pid_instance_f32::A0, arm_pid_instance_f32::A1, arm_pid_instance_f32::A2, and arm_pid_instance_f32::state.

tha



Description:

The resetStateFlag ระบุว่าจะเซ็ต state เป็นศูนย์หรือไม่.
The function คำนวณ the structure fields: A0, A1 A2 โดยใช้ the proportional gain( Kp), integral gain( Ki) และ derivative gain( Kd) เซ็ต the state variables เป็นศูนย์ทั้งหมดอีกด้วย.

References arm_pid_instance_f32::A0, arm_pid_instance_f32::A1, arm_pid_instance_f32::A2, arm_pid_instance_f32::Kd, arm_pid_instance_f32::Ki, arm_pid_instance_f32::Kp, and arm_pid_instance_f32::state.

tha


tha


tha