Microchip
直播中

h1654155275.6260

7年用户 217经验值
私信 关注
[问答]

如何获得正弦波调制的PWM

大家好!有人能指出一些关于如何获得正弦波调制的PWM的应用说明或示例代码(请参阅附图)。我正在尝试设置一个PWM来控制一个单相逆变器。我应该为此使用PWM发生器,还是应该结合数字输出使用定时器?我真的不知道怎样在dsPIC上得到这个结果。至于正弦波实现,我打算使用一个查找表来提高速度,因为我理解sin(x)的计算要求很高。一些技术细节:-dsPIC33EP64GS506-时钟速率:120MHz,60MIPS-PWM f频率应为20-50kHz -正弦波频率为50赫兹,谢谢!

以上来自于百度翻译


      以下为原文

    Hello everyone!

Can someone please point out to some application notes or example codes on how to get a PWM with a sine wave modulation (please see attached figure). I'm trying to set up a PWM to control a single-phase inverter.

Should I use a PWM generator for that purpose, or should I use a timer in a combination with a digital output? I really don't have a clue how to get this on a dsPIC. As for the sine wave implementation, I plan to use a look-up table for the sake of speed, as I understand that evaluation of sin(x) is computationally quite demanding.

Some technical details:
- dsPIC33EP64GS506
- Clock rate: 120 MHz, 60 MIPS
- PWM frequency should be 20-50 kHz
- Sine wave frequency is 50 Hz

Thank you in advance!
   Attached Image(s)

回帖(17)

李明烨

2019-6-6 12:45:27
亲爱的DarioG,谢谢你的回答!为什么我要更新一个定时IRQ内的占空比?我的意思是,我可以使用PWM IRQ来更新占空比,例如,在每个PWM周期结束时?我不明白为什么我必须使用计时器。

以上来自于百度翻译


      以下为原文

    Dear DarioG,
 
Thank you for your answer!
 
Why should I update the duty cycle inside a timed IRQ? I mean, can I update the duty cycle using the PWM IRQ, e.g., at the end of the each PWM period? I don't understand why do I have to use a timer.
 
M.
举报

张娜

2019-6-6 12:58:13
嗯,因为(除了可能的智能硬件模块)在其简单的设计中,PWM周期将比正弦波周期快得多……

以上来自于百度翻译


      以下为原文

    Well, because (apart from possible smart hardware modules)
in its simple design, the PWM period will be much faster than the sinewave period...
举报

李明烨

2019-6-6 13:16:08
AHA,所以计时器只是用来减少计算工作量?例如,在20kHz PWM和50Hz正弦波时,我将有400个间隔,也许只有40个间隔就足以仿真50Hz正弦波,这也取决于输出滤波器。我做对了吗?

以上来自于百度翻译


      以下为原文

    Aha, so the timer is just used to reduce the computation effort? E.g., at 20 kHz PWM and 50 Hz sine wave, I would have 400 intervals, and maybe it's sufficient to have only 40 intervals to emulate a 50-Hz sine wave, which also depends on the output filter. Did I get this right?
举报

李涛

2019-6-6 13:26:04
对于256微步进,我的表用了500字节存储0-90度,我用它来控制步进电机。由于cos和sin是动态的,所以计时器用来重新加载占空比。更多的间隔会使波形更平滑。irqs是最好的方法,因为你知道它会被同时调用。精确的时间加上你可以做其他事情,比如闪光灯。

以上来自于百度翻译


      以下为原文

    For 256 micro-stepping my table took 500 bytes storing 0-90 degrees which I use to control a stepper motor.
 
 
The timer is used to re-load the duty cycle since cos and sin are dynamic.
More intervals will make the wave smoother.
 
irqs are is the best way to go since you know it will be called at the same precise time plus you can do other stuff like flashing a led.
 
 
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分