找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3367|回复: 2
打印 上一主题 下一主题
收起左侧

DSP2833电机控制PWM程序

[复制链接]
跳转到指定楼层
楼主
ID:403425 发表于 2018-9-27 23:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
电机控制

DSP2833源程序如下:
  1. #include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
  2. #include "DSP2833x_Examples.h"   // DSP2833x Examples Include File
  3. #include "clarke.h"
  4. #include"park.h"
  5. #include"ipark.h"
  6. #include"svgen_dq.h"
  7. #include"DSP2833x_EPwm.h"
  8. #include"IQmathLib.h"
  9. #include"F28335_epwm.h"
  10. Uint16    *ExRamStart = (Uint16 *)0x100000;
  11. //void EPwmSetup();
  12. #define SYSTEM_FREQUENCY 150
  13. #define ISR_FREQUENCY 10
  14. Uint16  i;

  15. float Vd_testing = 0;                        //直轴电压标幺值
  16. float Vq_testing = 0.25;                 //交轴电压标幺值
  17. float Id_ref = 0;                                //直轴电流给定,标幺值
  18. float Iq_ref = 0.025;  //交轴电流给定,标幺值

  19. //volatile _iq speed_ref =_IQ(0.01);                 //速度给定,标幺值 电机速度=12000*speed_ref
  20. //volatile _iq position_ref =_IQ(0.0);                 //位置给定,标幺值 位置给定=50*position_ref

  21. extern PWMGEN pwm1;


  22. void main(void)
  23. {
  24. // Step 1. Initialize System Control:
  25. // PLL, WatchDog, enable Peripheral Clocks
  26. // This example function is found in the DSP2833x_SysCtrl.c file.
  27.    InitSysCtrl();

  28. // Step 2. Initalize GPIO:
  29. // This example function is found in the DSP2833x_Gpio.c file and
  30. // illustrates how to set the GPIO to it's default state.
  31. // InitGpio();  // Skipped for this example
  32.    InitXintf16Gpio();        //zq

  33. // Step 3. Clear all interrupts and initialize PIE vector table:
  34. // Disable CPU interrupts
  35.    DINT;

  36. // Initialize the PIE control registers to their default state.
  37. // The default state is all PIE interrupts disabled and flags
  38. // are cleared.
  39. // This function is found in the DSP2833x_PieCtrl.c file.
  40.    InitPieCtrl();

  41. // Disable CPU interrupts and clear all CPU interrupt flags:
  42.    IER = 0x0000;
  43.    IFR = 0x0000;

  44. // Initialize the PIE vector table with pointers to the shell Interrupt
  45. // Service Routines (ISR).
  46. // This will populate the entire table, even if the interrupt
  47. // is not used in this example.  This is useful for debug purposes.
  48. // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  49. // This function is found in DSP2833x_PieVect.c.
  50.    InitPieVectTable();

  51.    IER |= M_INT3;

  52. // Enable EPWM INTn in the PIE: Group 3 interrupt 1-6
  53.    PieCtrlRegs.PIEIER3.bit.INTx1 = 1;


  54. // Enable global Interrupts and higher priority real-time debug events:
  55.    EINT;   // Enable Global interrupt INTM
  56.    ERTM;   // Enable Global realtime interrupt DBGM

  57. // Interrupts that are used in this example are re-mapped to
  58. // ISR functions found within this file.

  59. // Step 4. Initialize the Device Peripheral. This function can be
  60. //         found in DSP2833x_CpuTimers.c
  61.   // InitCpuTimers();   // For this example, only initialize the Cpu Timers

  62. // Configure CPU-Timer 0, 1, and 2 to interrupt every second:
  63. // 150MHz CPU Freq, 1 second Period (in uSeconds)

  64.    //ConfigCpuTimer(&CpuTimer0, 150, 1000000);
  65.    //ConfigCpuTimer(&CpuTimer1, 150, 1000000);
  66.    //ConfigCpuTimer(&CpuTimer2, 150, 1000000);
  67. //        StartCpuTimer0();
  68.   
  69. //        EPwmSetup();
  70.         pwm1.init(&pwm1);
  71. ……………………

  72. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
5956444spwm20170327.zip (914.41 KB, 下载次数: 27)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:544733 发表于 2019-10-28 16:01 | 只看该作者
好东西
回复

使用道具 举报

板凳
ID:476093 发表于 2020-4-13 20:25 | 只看该作者
是不是得用这种硬件来做啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表