labview_nxt_tutorial
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
labview_nxt_tutorial [2017/07/31 17:17] – [Examples] yuhanghe | labview_nxt_tutorial [2017/08/15 15:47] (current) – [LabVIEW and LEGO MINDSTORMS NXT] yuhanghe | ||
---|---|---|---|
Line 3: | Line 3: | ||
**Author:** Yu Hang He **Email:** < | **Author:** Yu Hang He **Email:** < | ||
\\ | \\ | ||
- | **Date:** Last modified on 7/28/17 | + | **Date:** Last modified on <8/1/17> |
\\ | \\ | ||
**Keywords: | **Keywords: | ||
Line 30: | Line 30: | ||
* [[labview_nxt_tutorial# | * [[labview_nxt_tutorial# | ||
- | ==== Installation Guide ==== | + | ===== Installation Guide ===== |
If you have not download LabVIEW yet, [[labview_tutorial# | If you have not download LabVIEW yet, [[labview_tutorial# | ||
Line 37: | Line 37: | ||
\\ | \\ | ||
- | ==== NXT Module Basics ==== | + | ===== NXT Module Basics |
- | === Section 1.1: Robot Project Center === | + | ==== Section 1.1: Robot Project Center |
The Robot Project Center is a central hub for your robot project. To create a robot project, click on '' | The Robot Project Center is a central hub for your robot project. To create a robot project, click on '' | ||
Line 61: | Line 61: | ||
- | === Section 1.2: Connect NXT and NXT motor === | + | ==== Section 1.2: Connect NXT and NXT motor ==== |
Use a USB cable to connect your NXT brick to your computer. Turn on your NXT brick. Under '' | Use a USB cable to connect your NXT brick to your computer. Turn on your NXT brick. Under '' | ||
Line 75: | Line 75: | ||
You can test your motor by change the power level and then press '' | You can test your motor by change the power level and then press '' | ||
- | === Section 1.3: Hello World === | + | ==== Section 1.3: Hello World ==== |
This example will show you how to display '' | This example will show you how to display '' | ||
Line 109: | Line 109: | ||
{{ : | {{ : | ||
- | === Section 1.4: Executing Programs === | + | ==== Section 1.4: Executing Programs |
There are two different modes you can use to run your program: Direct mode and Remote mode. In Direct mode, you run the program from the computer and communicate with the NXT brick with either USB or Bluetooth. In Remote mode, you download the program to the NXT brick with USB or Bluetooth and the program runs directly on the NXT brick without any communication from the computer. | There are two different modes you can use to run your program: Direct mode and Remote mode. In Direct mode, you run the program from the computer and communicate with the NXT brick with either USB or Bluetooth. In Remote mode, you download the program to the NXT brick with USB or Bluetooth and the program runs directly on the NXT brick without any communication from the computer. | ||
Line 123: | Line 123: | ||
To run a program, turn on your NXT brick and connect it to your computer with USB cable. On Robot Project Center, under '' | To run a program, turn on your NXT brick and connect it to your computer with USB cable. On Robot Project Center, under '' | ||
- | === Section 1.5: Running NXT motor === | + | ==== Section 1.5: Running NXT motor ==== |
- | In this section, you will learn how to use LabVIEW to program a NXT motor to run for 5 seconds then brake. Create a new VI through Robot Project Center. On the block diagram, right click to open function palettes -> '' | + | In this section, you will learn how to use LabVIEW to program a NXT motor to run for 5 seconds then brake. Create a new VI through Robot Project Center. On the block diagram, right click to open function palettes -> '' |
\\ \\ | \\ \\ | ||
{{ : | {{ : | ||
Line 147: | Line 147: | ||
The program will set motor power at 75, wait for 5 seconds, then brake all motors. | The program will set motor power at 75, wait for 5 seconds, then brake all motors. | ||
- | ==== Examples ==== | + | ===== Examples |
- | === Section 2.1: Synchronizing Two Motors === | + | ==== Section 2.1: Synchronizing Two Motors |
Slight differences in NXT motors will cause them to rotate at different rates. This issue become apparent when using two NXT motors to drive in straight line. To solve this problem, you can implement a feedback control. NXT motors have built-in encoders. You can write a program that adjusts power levels to reflect the difference between two encoder readings. | Slight differences in NXT motors will cause them to rotate at different rates. This issue become apparent when using two NXT motors to drive in straight line. To solve this problem, you can implement a feedback control. NXT motors have built-in encoders. You can write a program that adjusts power levels to reflect the difference between two encoder readings. | ||
Line 157: | Line 157: | ||
If your motors are connected to ports A and B, then the power input of motors can be adjusted according to this: | If your motors are connected to ports A and B, then the power input of motors can be adjusted according to this: | ||
\\ \\ | \\ \\ | ||
- | '' | + | '' |
\\ | \\ | ||
- | '' | + | '' |
\\ \\ | \\ \\ | ||
- | The constant represent the target motor power you want to achieve, the difference between encoder values represent the possible errors, and the gain represent how much weight you want to place on the error, which is called proportional | + | The constant represent the target motor power you want to achieve, the difference between encoder values represent the possible errors, and the gain represent how much weight you want to place on the error, which is called proportional |
\\ \\ | \\ \\ | ||
Here is an example of how to implement proportional controller to synchronize two motors. | Here is an example of how to implement proportional controller to synchronize two motors. | ||
\\ \\ | \\ \\ | ||
- | {{ : | + | {{ : |
\\ \\ | \\ \\ | ||
+ | If motor B encoder is greater than motor A encoder that means motor B is running faster than motor A and the difference between 2 encoder values will be positive. After multiplying the proportional gain, this positive value will be added to power of motor A and subtract from power of motor B. Otherwise, power of motor A will be decreased and power of motor B will be increased instead. Through feedback control, the power of motors will constantly adjusting to reflect the difference in encoder readings. | ||
+ | ==== Section 2.2: Proportional Integral (PI) Controller ==== | ||
- | === Section 2.2: Proportional | + | Encoder function can be used to program NXT motors to rotate to desired position. However, at high power level, motor will overshoot desired position. Proportional |
- | + | \\ \\ | |
- | + | {{ : | |
- | ==== Final Words ==== | + | \\ \\ |
+ | Desired position from user input is the setpoint and encoder values are measured process variable. The difference between setpoint and encoder values represent error. The controller constantly adjust motor power, the control variable, to minimize error based on proportional and integral term. | ||
+ | ===== Final Words ===== | ||
- | This tutorial' | + | This tutorial' |
\\ | \\ | ||
\\ | \\ | ||
- | Speculating future work derived from this tutorial, includes <fill in the blank>. In the big picture, the problem of <fill in the blank> can be solved with this tutorial. | + | LabVIEW module for LEGO MINDSTORMS included help manual and examples, you can access them through toolbar on top of front panel or block diagram. Go to '' |
\\ | \\ | ||
\\ | \\ |
labview_nxt_tutorial.1501546639.txt.gz · Last modified: 2017/07/31 17:17 by yuhanghe