ni.com is experiencing intermittent service disruptions.

Support teams are actively working on the resolution.

Example Code

Converting an Analog Signal to a PWM Signal

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description
This VI takes an analog input and converts it to a pulse width modulated output.  This method uses software inputs, but it can be easily converted to incorporate real world values with DAQ.


Steps to Complete

Run the VI and modify the values on the slider to change the PWM output.  Change the loop iteration rate and the wait time to modify the period of the pulse width.  The default period is 1 second.

Requirements
Software
LabVIEW 2012 or compatible

Hardware
-

Additional Notes
This VI is written in LabVIEW 8.2, so LabVIEW 8.2 is required to run this VI.  It uses the wait function as a timing source, so there is some error associated with period timing.  This error will become more pronounced as period is reduced.

 

2017-10-30_16-54-36.jpg2017-10-30_16-54-24.jpg

Nick Keel
Product Manager - NI VeriStand and Model Interface Toolkit
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.