LabVIEW由三角波产生PWM

简介: LabVIEW由三角波产生PWM

LabVIEW由三角波产生PWM


此代码组件演示如何使用锯齿波生成PWM 信号。该示例将正弦波与三角波形进行比较。产生的PWM信号是比较器的输出。


此代码设计为在单周期定时循环中运行,但也包含一个时钟deriver,允许代码以基本时钟频率的整数分数运行(由“除数”控件定义)。还有一个布尔值来重置时钟deriver。下图显示了与5kHz正弦波一起使用的PWM发生器的示例以及与之配合的框图。附件包括PWM发生器模块本身以及其在单周期定时循环中的使用示例。


如果将直流信号馈送到比较器,则输出为PWM信号,其占空比恒定等于直流信号与三角波峰值之比。如果将其他模拟波形发送到比较器,PWM输出会变化以对应于模拟波形。


此代码可以通过用各种版本的锯齿查表替换三角波来扩展到不同版本的PWM发生器。


注意:“TriangleWavePWMGentest.vi”中的测试代码用于演示块在基于 Windows 的系统上的行为。如果不进行一些更改,它不会直接编译为FPGA。但是,“simpleFPGA test.vi”中的代码将编译并生成一个指示器,该指示器在0.5Hz的PWM范围内循环。


执行代码的步骤


LabVIEW 开发环境


打开TrianglePWM.lvproj文件


打开TriangleWavePWMGenTest.vi


运行 VI


请注意,正确的PWM波是从顶部图上的两个信号生成的。


LabVIEWFPGA


更新 FPGA 目标以匹配配置


编译并运行简单Simple FPGA Test.vi


要求


LabVIEW2010 FPGA 模块 “或兼容”


Thiscomponent of code shows how to use a sawtooth to generate a PWM signal. The example compares a sinewave to a trianglewaveform. The PWM signal generated isthe output of the comparator.


Description


This codehas been designed to run in a single-cycle timed loop, but also contains aclock deriver that allows the code to run at an integer fraction of the baseclock frequency (defined by the "Divisor" control). There is also a boolean to reset the clockderiver. The following images shows anexample of the PWM generator being used with a 5kHz sinewave as well as theblock diagram to go with it. Theattached files include the PWM generator block itself as well as an example ofits use in a single-cycle timed loop.


If a DCsignal is fed to the comparator, the output is a PWM signal with a constantduty cycle that is equal to the ratio of the DC signal to the peak value of thetriangle wave. If some other analogwaveform is sent to the comparator, the PWM output varies to correspond to theanalog waveform.


This codecould be extended to a different version of a PWM generator by replacing thetriangle wave with various versions of a sawtooth look-up table.


NOTE: thetest code in "TriangleWavePWMGen test.vi" is to demonstrate thebehavior of the block on a Windows-based system. It won't directly compile to FPGA withoutsome changes. However, the code in"simple FPGA test.vi" will compile and will generate an indicatorthat cycles through the PWM range at 0.5Hz.


Steps toExecute Code


LabVIEWDevelopment Environment


Open theTrianglePWM.lvproj file


Open theTriangleWavePWMGenTest.vi


Run theVI


Noticethat the correct PWM wave being generated from the two signals on the top plot.


LabVIEWFPGA


Updatethe FPGA target to match your configuration


Compile andrun the Simple FPGA Test.vi


需要说明的是,上述的例程和文档,都是可以下载的,双击即可打开,其中压缩文件是可以采用粘贴复制的方式,拷贝到硬盘上。这不是图片,各位小伙伴看到后尝试一下,这个问题就不用加微信咨询了。有关LabVIEW编程、LabVIEW开发等相关项目,可联系们。附件中的资料这里无法上传,可去公司网站搜索下载。


LabVIEW程序,如下附件所示。

相关文章
|
1月前
|
传感器 芯片
毕业设计 基于51单片机霍尔电机转速测量温度PWM调速设计
毕业设计 基于51单片机霍尔电机转速测量温度PWM调速设计
|
8月前
|
编解码 网络性能优化 芯片
如何用51单片机实现pwm调光+呼吸灯(超详细+源码)
如何用51单片机实现pwm调光+呼吸灯(超详细+源码)
546 0
如何用51单片机实现pwm调光+呼吸灯(超详细+源码)
|
9月前
|
C语言
圆曾经的小车梦,造一台智能小车(四)之QT上位机控制小车
圆曾经的小车梦,造一台智能小车(四)之QT上位机控制小车
183 0
|
11月前
单片机-蓝桥杯 用光敏电阻测量光照强度并显示在数码管上。
单片机-蓝桥杯 用光敏电阻测量光照强度并显示在数码管上。
184 1
|
11月前
【单片机】数码管矩阵显示
【单片机】数码管矩阵显示
67 0
LabVIEW控制Arduino实现PWM呼吸灯(基础篇—5)
利用LIAT中的模拟I/O函数库,通过LabVIEW和Arduino Uno控制板实现LED灯亮度的调节,产生灯会呼吸的效果。
OpenMV输出PWM,实现对舵机控制
OpenMV输出PWM,实现对舵机控制
1610 0
|
机器学习/深度学习 传感器 算法
基于Matlab实现升余弦滚降滤波器冲激响应的产生、基带脉冲成形以及绘制基带信号眼图
基于Matlab实现升余弦滚降滤波器冲激响应的产生、基带脉冲成形以及绘制基带信号眼图
labview图形显示正弦曲线信号发生器频率幅值相位数字示波器滤波器频谱分析
labview图形显示正弦曲线信号发生器频率幅值相位数字示波器滤波器频谱分析
281 0
|
传感器 前端开发 机器人
基于单片机的智能循迹避障小车STC89C52红外对管L298N驱动PWM波控制速度
利用红外对管检测黑线与障碍物,并以STC89C52单片机为控制芯片控制电动小汽车的速度及转向,从而实现自动循迹避障的功能。其中小车驱动由L298N驱动电路完成,速度由单片机输出的PWM波控制。
248 0