/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** * File Name : MC_PID_regulators.c * Author : IMS Systems Lab * Date First Issued : 21/11/07 * Description : This file contains the software implementation for the PI(D) regulators. ******************************************************************************** * History: * 21/11/07 v1.0 * 29/05/08 v2.0 ******************************************************************************** * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * * THIS SOURCE CODE IS PROTECTED BY A LICENSE. * FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED * IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE. *******************************************************************************/ /* Standard include ----------------------------------------------------------*/ #include "MC_PID_regulators.h" #include "string.h" /*根据型号设置不同的PID参数*/ //Volans PID参数 const PID_Struct_t PID_Torque_InitStructure_Volans = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output //电流环给微弱的负值,给转子施加反向扭矩让电机可以缓慢降速 (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Flux_InitStructure_Volans = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-32768, //hLower_Limit_Output (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Weak_InitStructure_Volans = { (int16_t)64, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-262144, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-268435456, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_ConstantPower_Volans = { (int16_t)30000, //hKp_Gain (uint16_t)256, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-2100, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-2150400, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_MotorSpd_Volans = { (int16_t)4096, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)1, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output (int32_t)1050, //hUpper_Limit_Output (int32_t)-358400, //wLower_Limit_Integral (int32_t)358400, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_IMax_Volans = { (int16_t)30000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-1050, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-1075200, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; //Volans_Plus PID参数 const PID_Struct_t PID_Torque_InitStructure_Volans_Plus = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output //电流环给微弱的负值,给转子施加反向扭矩让电机可以缓慢降速 (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Flux_InitStructure_Volans_Plus = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-32768, //hLower_Limit_Output (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Weak_InitStructure_Volans_Plus = { (int16_t)64, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-262144, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-268435456, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_ConstantPower_Volans_Plus = { (int16_t)30000, //hKp_Gain (uint16_t)256, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-2100, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-2150400, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_MotorSpd_Volans_Plus = { (int16_t)4096, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)1, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output (int32_t)1050, //hUpper_Limit_Output (int32_t)-358400, //wLower_Limit_Integral (int32_t)358400, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_IMax_Volans_Plus = { (int16_t)30000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-1050, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-1075200, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; //Pegasi PID参数 const PID_Struct_t PID_Torque_InitStructure_Pegasi = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output //电流环给微弱的负值,给转子施加反向扭矩让电机可以缓慢降速 (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Flux_InitStructure_Pegasi = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-32768, //hLower_Limit_Output (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Weak_InitStructure_Pegasi = { (int16_t)64, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-262144, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-268435456, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_ConstantPower_Pegasi = { (int16_t)30000, //hKp_Gain (uint16_t)256, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-2100, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-2150400, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_MotorSpd_Pegasi = { (int16_t)4096, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)1, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output (int32_t)1050, //hUpper_Limit_Output (int32_t)-358400, //wLower_Limit_Integral (int32_t)358400, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_IMax_Pegasi = { (int16_t)30000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-1050, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-1075200, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; //Pegasi_Plus PID参数 const PID_Struct_t PID_Torque_InitStructure_Pegasi_Plus = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output //电流环给微弱的负值,给转子施加反向扭矩让电机可以缓慢降速 (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Flux_InitStructure_Pegasi_Plus = { (int16_t)20000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-32768, //hLower_Limit_Output (int32_t)32767, //hUpper_Limit_Output (int32_t)(-32768 * 1024), //wLower_Limit_Integral (int32_t)(32767 * 1024), //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_Weak_InitStructure_Pegasi_Plus = { (int16_t)64, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)3, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-262144, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-268435456, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_ConstantPower_Pegasi_Plus = { (int16_t)30000, //hKp_Gain (uint16_t)256, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-2100, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-2150400, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_MotorSpd_Pegasi_Plus = { (int16_t)4096, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)1, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-100, //hLower_Limit_Output (int32_t)1050, //hUpper_Limit_Output (int32_t)-358400, //wLower_Limit_Integral (int32_t)358400, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; const PID_Struct_t PID_IMax_Pegasi_Plus = { (int16_t)30000, //hKp_Gain (uint16_t)1024, //hKp_Divisor (int16_t)300, //hKi_Gain (uint16_t)1024, //hKi_Divisor (int16_t)0, //hKd_Gain (uint16_t)1024, //hKd_Divisor (int32_t)0, //wPreviousError (int32_t)-1050, //hLower_Limit_Output (int32_t)0, //hUpper_Limit_Output (int32_t)-1075200, //wLower_Limit_Integral (int32_t)0, //wUpper_Limit_Integral (int32_t)0 //wIntegral }; /* 根据型号设置不同的PID参数 END */ //PID控制变量定义 PID_Struct_t PID_Torque_InitStructure; // q轴电流环闭环 PID_Struct_t PID_Flux_InitStructure; // d轴电流环闭环 PID_Struct_t PID_Weak_InitStructure; // 输出电压弱磁闭环 PID_Struct_t PID_ConstantPower; // 恒定功率 PID_Struct_t PID_MotorSpd; // 电机速度闭环 PID_Struct_t PID_IMax; // 母线电流闭环 /******************************************************************************* * Function Name : PID_Init * Description : Initialize PID coefficients for torque, flux and speed loop: Kp_Gain: proportional coeffcient Ki_Gain: integral coeffcient Kd_Gain: differential coeffcient * Input : Pointer 1 to Torque PI structure, Pointer 2 to Flux PI structure, Pointer 3 to Speed PI structure * Output : None * Return : None *******************************************************************************/ void PID_Init (uint8_t SerialNum) { switch(SerialNum) { case 1://Volans { memcpy(&PID_Torque_InitStructure.hKp_Gain, &PID_Torque_InitStructure_Volans.hKp_Gain, sizeof(PID_Torque_InitStructure_Volans)); memcpy(&PID_Flux_InitStructure.hKp_Gain, &PID_Flux_InitStructure_Volans.hKp_Gain, sizeof(PID_Flux_InitStructure_Volans)); memcpy(&PID_Weak_InitStructure.hKp_Gain, &PID_Weak_InitStructure_Volans.hKp_Gain, sizeof(PID_Weak_InitStructure_Volans)); memcpy(&PID_ConstantPower.hKp_Gain, &PID_ConstantPower_Volans.hKp_Gain, sizeof(PID_ConstantPower_Volans)); memcpy(&PID_MotorSpd.hKp_Gain, &PID_MotorSpd_Volans.hKp_Gain, sizeof(PID_MotorSpd_Volans)); memcpy(&PID_IMax.hKp_Gain, &PID_IMax_Volans.hKp_Gain, sizeof(PID_IMax_Volans)); break; } case 2://Volans Plus { memcpy(&PID_Torque_InitStructure.hKp_Gain, &PID_Torque_InitStructure_Volans_Plus.hKp_Gain, sizeof(PID_Torque_InitStructure_Volans_Plus)); memcpy(&PID_Flux_InitStructure.hKp_Gain, &PID_Flux_InitStructure_Volans_Plus.hKp_Gain, sizeof(PID_Flux_InitStructure_Volans_Plus)); memcpy(&PID_Weak_InitStructure.hKp_Gain, &PID_Weak_InitStructure_Volans_Plus.hKp_Gain, sizeof(PID_Weak_InitStructure_Volans_Plus)); memcpy(&PID_ConstantPower.hKp_Gain, &PID_ConstantPower_Volans_Plus.hKp_Gain, sizeof(PID_ConstantPower_Volans_Plus)); memcpy(&PID_MotorSpd.hKp_Gain, &PID_MotorSpd_Volans_Plus.hKp_Gain, sizeof(PID_MotorSpd_Volans_Plus)); memcpy(&PID_IMax.hKp_Gain, &PID_IMax_Volans_Plus.hKp_Gain, sizeof(PID_IMax_Volans_Plus)); break; } case 3://Pegasi { memcpy(&PID_Torque_InitStructure.hKp_Gain, &PID_Torque_InitStructure_Pegasi.hKp_Gain, sizeof(PID_Torque_InitStructure_Pegasi)); memcpy(&PID_Flux_InitStructure.hKp_Gain, &PID_Flux_InitStructure_Pegasi.hKp_Gain, sizeof(PID_Flux_InitStructure_Pegasi)); memcpy(&PID_Weak_InitStructure.hKp_Gain, &PID_Weak_InitStructure_Pegasi.hKp_Gain, sizeof(PID_Weak_InitStructure_Pegasi)); memcpy(&PID_ConstantPower.hKp_Gain, &PID_ConstantPower_Pegasi.hKp_Gain, sizeof(PID_ConstantPower_Pegasi)); memcpy(&PID_MotorSpd.hKp_Gain, &PID_MotorSpd_Pegasi.hKp_Gain, sizeof(PID_MotorSpd_Pegasi)); memcpy(&PID_IMax.hKp_Gain, &PID_IMax_Pegasi.hKp_Gain, sizeof(PID_IMax_Pegasi)); break; } case 4://Pegasi Plus { memcpy(&PID_Torque_InitStructure.hKp_Gain, &PID_Torque_InitStructure_Pegasi_Plus.hKp_Gain, sizeof(PID_Torque_InitStructure_Pegasi_Plus)); memcpy(&PID_Flux_InitStructure.hKp_Gain, &PID_Flux_InitStructure_Pegasi_Plus.hKp_Gain, sizeof(PID_Flux_InitStructure_Pegasi_Plus)); memcpy(&PID_Weak_InitStructure.hKp_Gain, &PID_Weak_InitStructure_Pegasi_Plus.hKp_Gain, sizeof(PID_Weak_InitStructure_Pegasi_Plus)); memcpy(&PID_ConstantPower.hKp_Gain, &PID_ConstantPower_Pegasi_Plus.hKp_Gain, sizeof(PID_ConstantPower_Pegasi_Plus)); memcpy(&PID_MotorSpd.hKp_Gain, &PID_MotorSpd_Pegasi_Plus.hKp_Gain, sizeof(PID_MotorSpd_Pegasi_Plus)); memcpy(&PID_IMax.hKp_Gain, &PID_IMax_Pegasi_Plus.hKp_Gain, sizeof(PID_IMax_Pegasi_Plus)); break; } default://默认处理 { memcpy(&PID_Torque_InitStructure.hKp_Gain, &PID_Torque_InitStructure_Volans.hKp_Gain, sizeof(PID_Torque_InitStructure_Volans)); memcpy(&PID_Flux_InitStructure.hKp_Gain, &PID_Flux_InitStructure_Volans.hKp_Gain, sizeof(PID_Flux_InitStructure_Volans)); memcpy(&PID_Weak_InitStructure.hKp_Gain, &PID_Weak_InitStructure_Volans.hKp_Gain, sizeof(PID_Weak_InitStructure_Volans)); memcpy(&PID_ConstantPower.hKp_Gain, &PID_ConstantPower_Volans.hKp_Gain, sizeof(PID_ConstantPower_Volans)); memcpy(&PID_MotorSpd.hKp_Gain, &PID_MotorSpd_Volans.hKp_Gain, sizeof(PID_MotorSpd_Volans)); memcpy(&PID_IMax.hKp_Gain, &PID_IMax_Volans.hKp_Gain, sizeof(PID_IMax_Volans)); break; } } } /******************************************************************************* * Function Name : PID_Regulator * Description : Compute the PI(D) output for a PI(D) regulation. * Input : Pointer to the PID settings (*PID_Flux) Speed in int16_t format * Output : int16_t * Return : None *******************************************************************************/ /******************************PID 调节函数的说明******************************/ int16_t PID_Regulator(int16_t hReference, int16_t hPresentFeedback,PID_Struct_t *PID_Struct) { int16_t wError; int32_t wProportional_Term,wIntegral_Term, houtput_32; int32_t dwAux; // error computation wError= hReference - hPresentFeedback; //取得需要误差量 delta_e hKp_Gain * wError; // wP = Kp * delta_e hKi_Gain == 0) { PID_Struct->wIntegral = 0; } else { wIntegral_Term = PID_Struct->hKi_Gain * wError; // wI = Ki * delta_e ,本次积分项 dwAux = PID_Struct->wIntegral + wIntegral_Term; // 积分累积的调节量 = 以前的积分累积量 + 本次的积分项 if(dwAux > PID_Struct->wUpper_Limit_Integral) //dwAux为当前积分累积项,下面测试积分饱和度 { PID_Struct->wIntegral = PID_Struct->wUpper_Limit_Integral; // 超上限 } else if(dwAux < PID_Struct->wLower_Limit_Integral) //超下限 { PID_Struct->wIntegral = PID_Struct->wLower_Limit_Integral; } else { PID_Struct->wIntegral = dwAux; //不超限, 更新积分累积项为dwAux hKp_Divisor) + //不含微分环节的总调节量 wIntegral/PID_Struct->hKi_Divisor); if((houtput_32<0)&&(houtput_32hLower_Limit_Output)) //超下限 { return(PID_Struct->hLower_Limit_Output); } if((houtput_32>0)&&(houtput_32>=PID_Struct->hUpper_Limit_Output)) //测试输出是否饱和,超上限 { return(PID_Struct->hUpper_Limit_Output); } else { return houtput_32; //不超限。输出结果 houtput_32