LabView Examples: Motors

Front Panel steering control
Front Panel steering control

These examples (ZIP) demonstrate motor control in LabVIEW.

Front Panel Steering Control

  • This example shows how to control the steering icon using the front panel.

Position Control

  • This example shows how to keep an object a set distance away from the robot.

Rotation Position Control

  • This example demonstrates how to control the rotation of a motor very accurately.  On the front panel, the user inputs the desired position (in degrees) of the motor. The user can also adjust the control gains, Kp and Ki which affects the input power of the motor. Kp is a proportional gain, it scales the difference between the motor’s current position and the desired position–this difference is known as the error. Ki is an integral gain, it scales the total accumulated error during the program. Play around with the gains to see what works the best.

Run for Distance

  • This program allows the user to input a desired distance for an NXT vehicle to move forward.

Run for Time

  • This example demonstrates controlling how long a motor will run.

Simple Movement

  • This example demonstrates some simple movements and motor functions.  The program goes forward until the touch sensor is pressed, brakes, then waits again for the touch sensor in order to go backwards.

Straight Steering

  • This example shows one way of compensating for differences in steering for a robot moving in a straight line.  By taking the difference in rotation between the two motors and multiplying by a gain, the program accounts for variations in motor distance.

Table Car

  • This “Table Car” will drive forward until its light sensor senses it is at the edge of the table.  Then, it will back up and turn randomly.  This process is repeated until the user aborts the program.

Straight Line Steering Alternative

  • This example shows another way of keeping the wheels at the same speed, even with differences in motors and environment.  By keeping track of the differences between rotation of each motor, and using that difference to adjust the motor power, this program ensures that the wheels rotate the same amount.

While Loop Motor Control

  • This program runs a motor using a “while loop” until a touch sensor is pressed.



The following two tabs change content below.


The Tufts Center for Engineering Education and Outreach (CEEO) in Boston, Massachusetts, is dedicated to improving engineering education in the classroom, from Kindergarten to college. The Center houses faculty, staff, and graduate students from engineering disciplines and the education department.

Latest posts by CEEO (see all)