找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3480|回復(fù): 2
收起左側(cè)

DSP2833電機(jī)控制PWM程序

[復(fù)制鏈接]
ID:403425 發(fā)表于 2018-9-27 23:29 | 顯示全部樓層 |閱讀模式
電機(jī)控制

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;                        //直軸電壓標(biāo)幺值
  16. float Vq_testing = 0.25;                 //交軸電壓標(biāo)幺值
  17. float Id_ref = 0;                                //直軸電流給定,標(biāo)幺值
  18. float Iq_ref = 0.025;  //交軸電流給定,標(biāo)幺值

  19. //volatile _iq speed_ref =_IQ(0.01);                 //速度給定,標(biāo)幺值 電機(jī)速度=12000*speed_ref
  20. //volatile _iq position_ref =_IQ(0.0);                 //位置給定,標(biāo)幺值 位置給定=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黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
5956444spwm20170327.zip (914.41 KB, 下載次數(shù): 27)


回復(fù)

使用道具 舉報(bào)

ID:544733 發(fā)表于 2019-10-28 16:01 | 顯示全部樓層
好東西
回復(fù)

使用道具 舉報(bào)

ID:476093 發(fā)表于 2020-4-13 20:25 | 顯示全部樓層
是不是得用這種硬件來做啊
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表