Example Code

PID Control Reference Example for LabVIEW FPGA

Code and Documents



This example shows how to do simple PID control of a PWM output using an analog input as feedback.

This example has two parts.  A host VI and a FPGA VI.  The FPGA VI does all of the PID control.  It reads an analog feedback sensor in volts, does PID control, and generates a PWM output signal at a base frequency.  It also has a digital line output that tells direction.  The host VI simply initializes the FPGA VI, reads data back, and displays everything in nominal form.

Note:  Currently, the speed of the PID loop and the PWM generation loop are programmed to always be the same.  If you need to run your PWM generation loop faster than the PID loop, you can change this by modifying the PID Loop Rate (Ticks) in the host.

Note:  This was designed for 783x R Series boards and uses LabVIEW 8.5, LabVIEW FPGA 8.5, and the PID Toolkit.

**The accompanying code represents a very specific use case for NI products. For more general examples, please refer to ni.com/examples, the LabVIEW Example Finder, or the NI driver help files that come with every NI driver.


This reference application was created by the NI Systems Engineering group. 

We do not regularly monitor Reader Comments posted on this page.

Please submit your feedback in the Reference Design discussion forum so that we can improve this component for future applications. 

Please direct support questions to NI Technical Support.

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