/* ==============================================================================
System Name: PMSM33
File Name: PMSM3_3.C
Description: Primary system file for the Real Implementation of Sensored
Field Orientation Control for a Three Phase Permanent-Magnet
Synchronous Motor (PMSM) using Resolver sensor
Originator: Digital control systems Group - Texas Instruments
Note: In this software, the default inverter is supposed to be DMC1500 board.
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20: Support both F280x and F281x targets
04-25-2005 Version 3.21: Move EINT and ERTM down to ensure that all initialization
is completed before interrupts are allowed.
================================================================================= */
// Include header files used in the main function
#include "target.h"
#if (DSP_TARGET==F2808)
#include "DSP280x_Device.h"
#endif
#if (DSP_TARGET==F2812)
#include "DSP281x_Device.h"
#endif
#include "IQmathLib.h"
#include "pmsm3_3.h"
#include "parameter.h"
#include "build.h"
#include <math.h>
// Prototype statements for functions found within this file.
interrupt void MainISR(void);
// Global variables used in this system
float32 VdTesting = 0; // Vd testing (pu)
float32 VqTesting = 0.25; // Vq testing (pu)
float32 IdRef = 0; // Id reference (pu)
float32 IqRef = 0.2; // Iq reference (pu)
float32 SpeedRef = 0.2; // Speed reference (pu)
float32 T = 0.001/ISR_FREQUENCY; // Samping period (sec), see parameter.h
float32 Ts = 0.001/RESOLVER_PWM_FREQUENCY; // PWM frequency, see parameter.h
float32 FreqExcitation = RESOLVER_EXCITATION_FREQUENCY*1000; // Excitation frequency (Hz)
float32 Amplitude = 1.0; // Peak value of excitation signal (pu)
float32 AngleExcitation = 0;
_iq SineRefSignal = 0; // Excitation signal (pu)
Uint16 IsrTicker = 0;
Uint16 BackTicker = 0;
int16 DlogCh1 = 0;
int16 DlogCh2 = 0;
int16 DlogCh3 = 0;
int16 DlogCh4 = 0;
volatile Uint16 EnableFlag = FALSE;
Uint16 SpeedLoopPrescaler = 10; // Speed loop prescaler
Uint16 SpeedLoopCount = 1; // Speed loop counter
// Instance a few transform objects
CLARKE clarke1 = CLARKE_DEFAULTS;
PARK park1 = PARK_DEFAULTS;
IPARK ipark1 = IPARK_DEFAULTS;
// Instance PID regulators to regulate the d and q synchronous axis currents,
// and speed
PIDREG3 pid1_id = PIDREG3_DEFAULTS;
PIDREG3 pid1_iq = PIDREG3_DEFAULTS;
PIDREG3 pid1_spd = PIDREG3_DEFAULTS;
// Instance a PWM driver instance
PWMGEN pwm1 = PWMGEN_DEFAULTS;
// Instance a Space Vector PWM modulator. This modulator generates a, b and c
// phases based on the d and q stationery reference frame inputs
SVGENDQ svgen_dq1 = SVGENDQ_DEFAULTS;
// Instance a enable PWM drive driver (only for DMC1500)
DRIVE drv1 = DRIVE_DEFAULTS;
// Instance a ramp controller to smoothly ramp the frequency
RMPCNTL rc1 = RMPCNTL_DEFAULTS;
// Instance a ramp generator to simulate an Anglele
RAMPGEN rg1 = RAMPGEN_DEFAULTS;
// Create an instance of resolver Module
RESOLVER speed1 = RESOLVER_DEFAULTS;
// Create an instance of bipolar ADC driver Module
ADCVALSB adc1 = ADCVALSB_DEFAULTS;
// Create an instance of resolver PWM driver Module
RESOLVER_PWM res_pwm1 = RESOLVER_PWM_DEFAULTS;
// Create an instance of DATALOG Module
DLOG_4CH dlog = DLOG_4CH_DEFAULTS;
void main(void)
{
// ******************************************
// Initialization code for DSP_TARGET = F2808
// ******************************************
#if (DSP_TARGET==F2808)
// Initialize System Control registers, PLL, WatchDog, Clocks to default state:
// This function is found in the DSP280x_SysCtrl.c file.
InitSysCtrl();
// Globally synchronize all ePWM modules to the time base clock (TBCLK)
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
// HISPCP prescale register settings, normally it will be set to default values
EALLOW; // This is needed to write to EALLOW protected registers
SysCtrlRegs.HISPCP.all = 0x0000; // SYSCLKOUT/1
EDIS; // This is needed to disable write to EALLOW protected registers
// Disable and clear all CPU interrupts:
DINT;
IER = 0x0000;
IFR = 0x0000;
// Initialize Pie Control Registers To Default State:
// This function is found in the DSP280x_PieCtrl.c file.
InitPieCtrl();
// Initialize the PIE Vector Table To a Known State:
// This function is found in DSP280x_PieVect.c.
// This function populates the PIE vector table with pointers
// to the shell ISR functions found in DSP280x_DefaultIsr.c.
InitPieVectTable();
// User specific functions, Reassign vectors (optional), Enable Interrupts:
// Waiting for enable flag set
while (EnableFlag==FALSE)
{
BackTicker++;
}
// Enable CNT_zero interrupt using EPWM1 Time-base
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWM1INT generation
EPwm1Regs.ETSEL.bit.INTSEL = 1; // Enable interrupt CNT_zero event
EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate interrupt on the 1st event
EPwm1Regs.ETCLR.bit.INT = 1; // Enable more interrupts
// Reassign ISRs.
// Reassign the PIE vector for EPWM1_INT to point to a different
// ISR then the shell routine found in DSP280x_DefaultIsr.c.
// This is done if the user does not want to use the shell ISR routine
// but instead wants to use their own ISR.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM1_INT = &MainISR;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable PIE group 3 interrupt 1 for EPWM1_INT
PieCtrlRegs.PIEIER3.all = M_INT1;
// Enable CPU INT3 for EPWM1_INT:
IER |= M_INT3;
#endif
// ******************************************
// Initialization code for DSP_TARGET = F2812
// ******************************************
#if (DSP_TARGET==F2812)
// Initialize System Control registers, PLL, WatchDog, Clocks to default state:
// This function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();
// HISPCP prescale register settings, normally it will be set to default values
EALLOW; // This is needed to write to EALLOW protected registers
SysCtrlRegs.HISPCP.all = 0x0000; // SYSCLKOUT/1
EDIS; // This is needed to disable write to EALLOW protected registers
// Disable and clear all CPU interrupts:
DINT;
IER = 0x0000;
IFR = 0x0000;
// Initialize Pie Control Registers To Default State:
// This function is found in the DSP281x_PieCtrl.c file.
InitPieCtrl();
// Initialize the PIE Vector Table To a Known State:
// This function is found in DSP281x_PieVect.c.
// This function populates the PIE vector table with pointers
// to the shell ISR functions found in DSP281x_DefaultIsr.c.
InitPieVectTable();
// User specific functions, Reassign vectors (optional), Enable Interrupts:
// Initialize EVA Timer 1:
// Setup Timer 1 Registers (EV A)
EvaRegs.GPTCONA.all = 0;
// Waiting for enable flag set
while (EnableFlag==FALSE)
{
BackTicker++;
}
// Enable Underflow interrupt bits for GP timer 1
EvaRegs.EVAIMRA.bit.T1UFINT = 1;
EvaRegs.EVAIFRA.bit.T1UFINT = 1;
// Reassign ISRs.
// Reassign the PIE vector for T1UFINT to point to a different
// ISR then the shell routine found in DSP281x_DefaultIsr.c.
// This is done if the user does not want to use the shell ISR routine
// but instead wants to use their own ISR.
EALLOW; // T
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
cIQmath.rar_dsp电机控制_三 闭环控制 电机_三闭环_永磁电机 (126个子文件)
pmsm3_3.c 37KB
resolver.c 7KB
SYMBOL.CDX 901KB
SYMBOL.CDX 560KB
FILE.CDX 3KB
FILE.CDX 3KB
F2812_EzDSP_RAM_lnk.cmd 5KB
F2808_EzDSP_RAM_lnk.cmd 4KB
SYMBOL.DBF 1.1MB
SYMBOL.DBF 493KB
FILE.DBF 3KB
FILE.DBF 2KB
SYMBOL.FPT 1.81MB
SYMBOL.FPT 806KB
FILE.FPT 6KB
FILE.FPT 4KB
DSP281x_SWPrioritizedIsrLevels.h 144KB
DSP281x_SWPrioritizedIsrLevels.h 144KB
IQmathLib.h 120KB
IQmathLib.h 120KB
DSP281x_ECan.h 47KB
DSP281x_ECan.h 47KB
DSP281x_Mcbsp.h 35KB
DSP281x_Mcbsp.h 35KB
DSP281x_Gpio.h 29KB
DSP281x_Gpio.h 29KB
DSP281x_Ev.h 24KB
DSP281x_Ev.h 24KB
DSP281x_SysCtrl.h 12KB
DSP281x_SysCtrl.h 12KB
f281xbmsk.h 9KB
f281xbmsk.h 9KB
DSP281x_Adc.h 9KB
DSP281x_Adc.h 9KB
DSP281x_Sci.h 8KB
DSP281x_Sci.h 8KB
DSP281x_PieVect.h 6KB
DSP281x_PieVect.h 6KB
DSP281x_Spi.h 6KB
DSP281x_Spi.h 6KB
resolver.h 6KB
DSP281x_PieCtrl.h 6KB
DSP281x_PieCtrl.h 6KB
DSP281x_CpuTimers.h 6KB
DSP281x_CpuTimers.h 6KB
f281xhall3.h 5KB
DSP281x_DefaultIsr.h 5KB
DSP281x_DefaultIsr.h 5KB
f281xpwm.h 5KB
f281xpwm.h 5KB
DSP281x_Device.h 5KB
DSP281x_Device.h 5KB
f281xbdcpwm.h 4KB
f281xqep_no_index.h 4KB
f281xpwmdac.h 4KB
f281xadc04b.h 4KB
f281xadc04b.h 4KB
f281xbldcpwm.h 4KB
f281xqep.h 4KB
f281xileg_vdc.h 4KB
f281xpwm_res.h 4KB
f281xpwm_res.h 4KB
DSP281x_Xintf.h 4KB
DSP281x_Xintf.h 4KB
DSP281x_Examples.h 3KB
DSP281x_Examples.h 3KB
f281xadc04u.h 3KB
speed_pr.h 3KB
f281xileg.h 3KB
f281xcap.h 3KB
dlog4ch.h 3KB
dlog4ch.h 3KB
DSP281x_DevEmu.h 3KB
DSP281x_DevEmu.h 3KB
volt_calc.h 3KB
pid_reg3.h 3KB
pid_reg3.h 3KB
svgen_mf.h 3KB
pmsm3_3.h 3KB
speed_fr.h 3KB
speed_est.h 3KB
parameter.h 3KB
DSP281x_GlobalPrototypes.h 2KB
DSP281x_GlobalPrototypes.h 2KB
svgen_dq.h 2KB
svgen_dq.h 2KB
rmp_cntl.h 2KB
rmp_cntl.h 2KB
DSP281x_XIntrupt.h 2KB
DSP281x_XIntrupt.h 2KB
rmp3cntl.h 2KB
rmp2cntl.h 2KB
f281x_en.h 2KB
f281x_en.h 2KB
vhzprof.h 2KB
rampgen.h 2KB
rampgen.h 2KB
ipark.h 2KB
ipark.h 2KB
park.h 2KB
共 126 条
- 1
- 2
资源评论
林当时
- 粉丝: 100
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功