LEGO NXT LabVIEW
© Copyright Paul Oh
Hands-on Lab:
LabVIEW – PID
In previous labs, the step response and the PID simulation of the LEGO DCP were performed.
The former provides a Labview framework to use the gains discovered from latter to achieved
PID closed-loop control.
Concept 1: Experimental PID control
Step 1: Create Front Panel and Initial Block Diagram
From your System Identification lab open the file nxtLabviewLegoDcpSystemId1_0.vi.
Save this program as nxtLabviewLegoDcpPid1_0.vi. This program provided the framework
to acquire, graphically display, and save to file the DCP’s angle. This program also allowed one
to command the motor-prop. Since Step Input is no longer needed, eliminate the toggle switch.
Add numeric controls to the Front Panel. These controls will allow one to set PID gains, the
desired angle. Also, add a numeric indicator to display the power going into the motor-prop
(Figure 1-1A left).
For the Block Diagram, delete the Case Structure that was associated with the toggle switch
(but keep the NXT motor Block). Blocks will be added, so re-arrange the Block Diagram to
provide suitable space (Figure 1-1A right).
Step 2: Create the error signal and proportional control
PID control works on the error signal. The error is the difference between the desired and actual
angle (in degrees). The proportional component of PID control scales this error. As such, add
Subtraction and Multiplication blocks (Figure 1-2A).
Figure 1-1A: Red ellipses show the numeric controls and indicators added to the Front Panel (left). Red arrow gathers
these blocks, to be used in next steps. NB: wires and blocks were slightly re-arranged, and the loop box was widened in
anticipation of the need to accommodate more blocks.