Example Code

Software Pulse Width Modulation (PWM)

Code and Documents

Attachment

This VI should be used as a subVI. It generates a point by point software pulse width modulation signal. This signal will be correct to the degree that the external loop iteration time is constant. This will not be more accurate than the capabilities of the software in the operating system.

This VI can also be used in a for loop to prepare for use on hardware and will be as accurate as the hardware. For this to work properly the units of cycle time and minimum pulse width don't matter as long as they are the same.

This VI allows you to view the total count of the true and false values and reset the count at any time. With continuous set to true it will start from zero and keep the modulation at the duty cycle value. With continuous set to false it will reset to the new duty cycle and assume that it was previously at that duty cycle.

Software PWM PtByPt LV82.JPG

Vince M
Applications Engineer

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

Comments
Mohammed_Kandeel
Member
Member
on

Hello if i want to show the signal on waveform graph what should i do ?

Contributors