⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inv_pid.c

📁 SVPWM算法的DSP源码已通过硬件验证
💻 C
字号:
// TI File $Revision: /main/2 $
// Checkin $Date: March 18, 2009   15:48:25 $
//###########################################################################
//
// FILE:   pv20k_Pid.c
//
// TITLE:  
//
// ASSUMPTIONS:
//
//   This program requires the DSP2803x header files.
//
//   Make sure the CPU clock speed is properly defined in
//   DSP2803x_Examples.h before compiling this example.
//
//    $Boot_Table:
//
//    While an emulator is connected to your device, the TRSTn pin = 1,
//    which sets the device into EMU_BOOT boot mode. In this mode, the
//    peripheral boot modes are as follows:
//
//      Boot Mode:       EMU_KEY        EMU_BMODE
//                       (0xD00)	     (0xD01)
//      ---------------------------------------
//      Wait             !=0x55AA        X
//      I/O              0x55AA	         0x0000
//      SCI              0x55AA	         0x0001
//      Wait             0x55AA	         0x0002
//      Get_Mode         0x55AA	         0x0003
//      SPI              0x55AA	         0x0004
//      I2C              0x55AA	         0x0005
//      OTP              0x55AA	         0x0006
//      eCANA            0x55AA	         0x0007
//      SARAM            0x55AA	         0x000A	  <-- "Boot to SARAM"
//      Flash            0x55AA	         0x000B
//      Wait             0x55AA          Other
//
//   Write EMU_KEY to 0xD00 and EMU_BMODE to 0xD01 via the debugger
//   according to the Boot Mode Table above. Build/Load project,
//   Reset the device, and Run example
//
//   $End_Boot_Table
//
//
// Description:
//
//   This example sets up the PLL in x12/2 mode.
//
//   For 60 MHz devices (default)
//   (assuming a 10Mhz input clock).
//
//###########################################################################
// $TI Release: DSP2803x C/C++ Header Files V1.10 $
// $Release Date: July 27, 2009 $
//###########################################################################

#include	"DSP280x_Device.h"
#include	"DSP280x_Examples.h"    // Device Headerfile and Examples Include File
#include "IQmathLib.h"
#include  "Global.h"



void vPid(void)
{   
    
    
	int32	lPidTemp;
	Uint16	uiPidTemp;
    
	                  
	                  
	PidRegs.lPidEk = (int32)OutputVar.uiTargetVolt - (int32)OutputVar.uiRealVolt;
	
	// PID输入:目标电压和反馈电压的差值
   // PidRegs.lPidEk = (int32)OutputVar.uiTargetVolt - 180;
	if(( abs(PidRegs.lPidEk) < SetPara.uiErrGap)&&(abs(PidRegs.lPidEk) > 0))
	{
		// Pid control
		lPidTemp = (PidRegs.lKp * PidRegs.lPidEk + PidRegs.lKi * PidRegs.lPidEk1 + PidRegs.lPidEk2) >> 7;
	}
	else if(abs(PidRegs.lPidEk) >= SetPara.uiErrGap)
	{
		// Only P control
		lPidTemp = (PidRegs.lKp * PidRegs.lPidEk) >> 7;
	}
    else if(abs(PidRegs.lPidEk) == 0 )
	{
		lPidTemp = 0 ;
	}
	uiPidTemp = (Uint16)lPidTemp + OutputVar.uiCurrVolt;//PID输出
	uiPidTemp = (uiPidTemp > OutputVar.uiPidOutMax) ? OutputVar.uiPidOutMax : uiPidTemp;
	OutputVar.uiCurrVolt = (uiPidTemp > OutputVar.uiPidOutMin) ? uiPidTemp : OutputVar.uiPidOutMin;
    
	// reserve ek
	PidRegs.lPidEk1 = PidRegs.lPidEk;
	PidRegs.lPidEk2 = PidRegs.lPidEk1;
}


//-----------------------------------End of file------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -