收藏 分享(赏)

基于TMS320F28069的SPWM波形实现.doc

上传人:精品资料 文档编号:9071618 上传时间:2019-07-22 格式:DOC 页数:17 大小:363.14KB
下载 相关 举报
基于TMS320F28069的SPWM波形实现.doc_第1页
第1页 / 共17页
基于TMS320F28069的SPWM波形实现.doc_第2页
第2页 / 共17页
基于TMS320F28069的SPWM波形实现.doc_第3页
第3页 / 共17页
基于TMS320F28069的SPWM波形实现.doc_第4页
第4页 / 共17页
基于TMS320F28069的SPWM波形实现.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

1、基于TMS320F28069的SPWM波形实现李健-3班-15号摘要:本报告介绍了正弦脉宽调制(SPWM)的原理,包括规则采样法等。并采用TMS320F28069芯片,通过CCSV4.2.1软件进行程序下载和调试,在示波器界面上观察所得到的波形。最终,这次实验通过了老师的验收!关键词:正弦脉宽调制;规则采样法;SPWM波形Abstract: This report introduces the principle of sine pulse width modulation (SPWM), including Regular Sampling method, etc. And uses the

2、 TMS320F28069 chip, through CCSV4.2.1 software to download program and debug, observe waveform on the interface of oscillograph. In the end, this experiment was admitted by our teacher!Key words: sine pulse width modulation; Regular Sampling method; SPWM waveform1、 SPWM 原理在进行脉宽调制时, 使脉冲系列的占空比按正弦规律来安排

3、。当正弦值为最大时,脉宽最大,脉冲之间的间隔最小;当正弦值较小时,脉宽较小,脉冲之间的间隔较大。通过正弦波脉宽调制输出后的电压脉冲系列可以使电机电流中的高次谐波成分大大减少。SPWM开关点的计算从原理上讲,应该根据正弦参考控制波与三角载波进行比较后的交点来确定,确定交点的方法有硬件法和软件法。SPWM方法有很多种。其中,软件法又可以分为表格法、随时计算法和实时计算法。本实验采用实时计算法中的采样型SPWM 算法。它是根据正弦参考控制波与三角载波进行比较后产生SPWM控制开关信号的基本原理,推导出SPWM开关点的算法。采样型SPWM有自然采样法和规则采样法两种。自然采样法在计算SPWM波的脉宽时

4、要解超越方程,这需要花费较多的时间,因此自然采样法不适合用于实时控制。2、 规则采样法自然采样法的主要问题是SPWM 波形每一个脉冲的起始和结束时刻t A和t B对于三角载波的中心线不对称,因而求解困难。工程上实用的方法要求计算简单,误差不是很大,因此对自然采样法进行一些近似处理,得出了各种规则采样方法(Regular Sampling method)。2.1称规则采样法 I这种方法是在三角载波的每一个周期的正峰值时刻找出正弦调制波上的对应点如图1所示 D 点,求出此处的电压值 urd 。 图1 称规则采样法I用此电压值对三角载波进行采样,得A、B 两点。就认为它们是 SPWM 波形中脉冲的生

5、成时刻,A 、B 区间就是脉宽时间t 2。SPWM波形的每一个脉冲的起始和结束时刻t A和t B对于三角载波的中心线是对称的(t 1=t3)。所以称为对称规则采样法。对称规则采样法I 的计算公式为:脉宽时间: (1)DctwMTt12sin间歇时间: (2)231ttc从上述计算公式可以看出,对称规则采样法I的计算明显比自然采样法要简单,但从图 2中可以看出输出脉冲宽度明显减小,从而造成控制误差。这是由于采样电压水平线与三角载波的交点都处于正弦调制波的同一侧造成的。为减小误差提出了对称规则采样法II。2.2称规则采样法 II如图2所示,仍然在三角载波的固定时刻找到正弦调制波上的采样电压值,但所

6、取的不是三角载波的正峰值而是负峰值,图中E 点,采样电压为u re 。图2 称规则采样法II在三角载波上由ure 水平线截得A 、B两点,从而确定了脉宽时间 t2 由于 -void InitFlash();void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);void update_sin(void);void PieCntlInit(void);void PieVectTableInit(void);void InitEPwmTimer(void);interrupt void epwm2_time

7、r_isr(void);/%/ VARIABLE DECLARATIONS - GENERAL/%/ Used for running BackGround in flash and the ISR in RAMextern Uint16 RamfuncsLoadStart, RamfuncsLoadEnd, RamfuncsRunStart;#define PWM2_INT_ENABLE 1/定义初值Uint32 N=400; /载波比float M=0.8; /调制度Uint32 i=1; /采样计数 /预存正弦值表float sin400= 0, 0.015707, 0.031411,

8、0.047106, 0.062791, 0.078459, 0.094108, 0.109734, 0.125333, 0.140901, 0.156434, 0.171929, 0.187381, 0.202787, 0.218143, 0.233445, 0.24869, 0.263873, 0.278991, 0.29404, 0.309017, 0.323917, 0.338738, 0.353475, 0.368125, 0.382683, 0.397148, 0.411514, 0.425779, 0.439939,0.45399, 0.46793, 0.481754, 0.495

9、459, 0.509041, 0.522499, 0.535827, 0.549023, 0.562083, 0.575005, 0.587785, 0.60042, 0.612907, 0.625243, 0.637424, 0.649448, 0.661312, 0.673013, 0.684547, 0.695913, 0.707107, 0.718126, 0.728969, 0.739631, 0.750111, 0.760406, 0.770513, 0.78043, 0.790155, 0.799685, 0.809017, 0.81815, 0.827081, 0.835807

10、, 0.844328, 0.85264, 0.860742, 0.868632, 0.876307, 0.883766, 0.891007, 0.898028, 0.904827, 0.911403, 0.917755, 0.92388, 0.929776, 0.935444, 0.940881, 0.946085, 0.951057, 0.955793, 0.960294, 0.964557, 0.968583, 0.97237, 0.975917, 0.979223, 0.982287, 0.985109, 0.987688, 0.990024, 0.992115, 0.993961, 0

11、.995562, 0.996917, 0.998027, 0.99889, 0.999507, 0.999877, 1.0, 0.999877, 0.999507, 0.99889, 0.998027, 0.996917, 0.995562, 0.993961, 0.992115, 0.990024, 0.987688, 0.985109, 0.982287, 0.979223, 0.975917, 0.97237, 0.968583, 0.964557, 0.960294, 0.955793,0.951057, 0.946085, 0.940881, 0.935444, 0.929776,

12、0.92388, 0.917755, 0.911403, 0.904827, 0.898028, 0.891007, 0.883766, 0.876307, 0.868632, 0.860742, 0.85264, 0.844328, 0.835807, 0.827081, 0.81815, 0.809017, 0.799685, 0.790155, 0.78043, 0.770513, 0.760406, 0.750111, 0.739631, 0.728969, 0.718126, 0.707107, 0.695913, 0.684547, 0.673013, 0.661312, 0.64

13、9448, 0.637424, 0.625243, 0.612907, 0.60042, 0.587785, 0.575005, 0.562083, 0.549023, 0.535827, 0.522499, 0.509041, 0.495459, 0.481754, 0.46793,0.45399, 0.439939, 0.425779, 0.411514, 0.397148, 0.382683, 0.368125, 0.353475, 0.338738, 0.323917, 0.309017, 0.29404, 0.278991, 0.263873, 0.24869, 0.233445,

14、0.218143, 0.202787, 0.187381, 0.171929, 0.156434, 0.140901, 0.125333, 0.109734, 0.094108, 0.078459, 0.062791, 0.047106, 0.031411, 0.015707, 0, -0.015707, -0.031411, -0.047106, -0.062791, -0.078459, -0.094108, -0.109734, -0.125333, -0.140901,-0.156434, -0.171929, -0.187381, -0.202787, -0.218143, -0.2

15、33445, -0.24869, -0.263873, -0.278991,-0.29404, -0.309017, -0.323917, -0.338738, -0.353475, -0.368125, -0.382683, -0.397148, -0.411514,-0.425779, -0.439939,-0.45399, -0.46793, -0.481754, -0.495459, -0.509041, -0.522499, -0.535827, -0.549023, -0.562083, -0.575005,-0.587785, -0.60042, -0.612907, -0.62

16、5243, -0.637424, -0.649448, -0.661312, -0.673013, -0.684547, -0.695913, -0.707107, -0.718126, -0.728969, -0.739631, -0.750111, -0.760406, -0.770513, -0.78043, -0.790155, -0.799685,-0.809017, -0.81815, -0.827081, -0.835807, -0.844328, -0.85264, -0.860742, -0.868632, -0.876307, -0.883766, -0.891007, -

17、0.898028, -0.904827, -0.911403, -0.917755, -0.92388, -0.929776, -0.935444, -0.940881, -0.946085,-0.951057, -0.955793, -0.960294, -0.964557, -0.968583, -0.97237, -0.975917, -0.979223, -0.982287, -0.985109,-0.987688, -0.990024, -0.992115, -0.993961, -0.995562, -0.996917, -0.998027, -0.99889, -0.999507

18、, -0.999877, -1.0, -0.999877, -0.999507, -0.99889, -0.998027, -0.996917, -0.995562, -0.993961, -0.992115, -0.990024, -0.987688, -0.985109, -0.982287, -0.979223, -0.975917, -0.97237, -0.968583, -0.964557, -0.960294, -0.955793, -0.951057, -0.946085, -0.940881, -0.935444, -0.929776, -0.92388, -0.917755

19、, -0.911403, -0.904827, -0.898028, -0.891007, -0.883766, -0.876307, -0.868632, -0.860742, -0.85264, -0.844328, -0.835807, -0.827081, -0.81815,-0.809017, -0.799685, -0.790155, -0.78043, -0.770513, -0.760406, -0.750111, -0.739631, -0.728969, -0.718126,-0.707107, -0.695913, -0.684547, -0.673013, -0.661

20、312, -0.649448, -0.637424, -0.625243, -0.612907, -0.60042, -0.587785, -0.575005, -0.562083, -0.549023, -0.535827, -0.522499, -0.509041, -0.495459, -0.481754, -0.46793, -0.45399, -0.439939, -0.425779, -0.411514, -0.397148, -0.382683, -0.368125, -0.353475, -0.338738, -0.323917, -0.309017, -0.29404, -0

21、.278991, -0.263873, -0.24869, -0.233445, -0.218143, -0.202787, -0.187381, -0.171929, -0.156434, -0.140901, -0.125333, -0.109734, -0.094108, -0.078459, -0.062791, -0.047106, -0.031411, -0.015707;/%/ MAIN CODE - starts here/%void main(void) /初始化系统及各个外设/=/ INITIALISATION - General/=DeviceInit(); / Devi

22、ce Life support / 初始化PIE 控制寄存器PieVectTableInit(); / 初始化PIE中断向量表EALLOW; PieVectTable.EPWM2_INT = /中断函数入口EDIS; InitEPwmTimer(); / 赋值中断函数地址IER|= M_INT3; / 使能CPU级第三组中断PieCtrlRegs.PIEIER3.bit.INTx2 = PWM2_INT_ENABLE; / 使能PIE中断,TB定时器中断位于INT3.2EINT; / 开全局中断ERTM; / 开实时中断while(1)/ Only used if running from F

23、LASH/ Note that the variable FLASH is defined by the compiler (-d FLASH)/#ifdef FLASH/ Copy time critical code and Flash setup code to RAM/ The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart/ symbols are created by the linker. Refer to the linker files. /MemCopy(/ Call Flash Initialization

24、 to setup flash waitstates/ This function must reside in RAM/ InitFlash(); / Call the flash wrapper init function/#endif /(FLASH)/-#define period 4000 / 20kHz when PLL is set to 0x10(80MHz) / Time-base registersvoid InitEPwmTimer()EALLOW;SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; / 停止TB 计数EDIS;EPwm2Regs

25、.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; EPwm2Regs.TBCTR = 0; / 禁止TB 计数EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;EPwm2Regs.TBCTL.bit.PHSEN = 0;EPwm2Regs.TBPHS.half.TBPHS = 0;/ Setup shadow register load on ZEROEPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;EPwm2Regs.CMPCTL.bi

26、t.SHDWBMODE = CC_SHADOW;EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;/ load on CTR=ZeroEPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;/ load on CTR=Zero/ Set Compare valuesEPwm2Regs.CMPA.half.CMPA = 0; / Set duty 0% initially/ Set actionsEPwm2Regs.AQCTLA.bit.ZRO = AQ_SET;EPwm2Regs.AQCTLA.bit.CAU = AQ_

27、CLEAR; / Set PWM2A on event A, up countEPwm2Regs.TBPRD = period; / 设置采样周期EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; / 中断使能选择EPwm2Regs.ETSEL.bit.INTEN = PWM2_INT_ENABLE; / 使能中断EPwm2Regs.ETPS.bit.INTPRD = ET_1ST; EALLOW;SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; / 使能定时器TB 计数EDIS; /=/ Forever LOOP/=/ Just sit and loop forever:/ No interrups needed in this example./ PWM pins can be observed with a scope.void update_sin()if(i=1) interrupt void epwm2_timer_isr(void)update_sin();EPwm2Regs.ETCLR.bit.INT = 1;PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;2、调试过程片段

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报