User Tools

Site Tools


labview_nxt_tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
labview_nxt_tutorial [2017/07/31 17:17] – [Examples] yuhanghelabview_nxt_tutorial [2017/08/15 15:47] (current) – [LabVIEW and LEGO MINDSTORMS NXT] yuhanghe
Line 3: Line 3:
 **Author:** Yu Hang He **Email:** <[email protected] **Author:** Yu Hang He **Email:** <[email protected]
 \\ \\
-**Date:** Last modified on 7/28/17+**Date:** Last modified on <8/1/17>
 \\ \\
 **Keywords:** LabVIEW, LEGO MINDSTORMS, NXT, NXT Motor **Keywords:** LabVIEW, LEGO MINDSTORMS, NXT, NXT Motor
Line 30: Line 30:
   * [[labview_nxt_tutorial#final_words|Final Words]]   * [[labview_nxt_tutorial#final_words|Final Words]]
  
-==== Installation Guide ====+===== Installation Guide =====
  
 If you have not download LabVIEW yet, [[labview_tutorial#installation_guide|follow this tutorial]] to install LabVIEW. **LabVIEW module for LEGO MINDSTORMS is currently only compatible with LabVIEW 2016 and previous editions.**  If you have not download LabVIEW yet, [[labview_tutorial#installation_guide|follow this tutorial]] to install LabVIEW. **LabVIEW module for LEGO MINDSTORMS is currently only compatible with LabVIEW 2016 and previous editions.** 
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 ''File'' in the upper left corner of LabVIEW Getting Started window-> ''New NXT/EV3'' -> ''Robot Project'' The Robot Project Center is a central hub for your robot project. To create a robot project, click on ''File'' in the upper left corner of LabVIEW Getting Started window-> ''New NXT/EV3'' -> ''Robot Project''
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 ''Choose NXT/EV3'', select ''Find NXT/EV3'' to display the Find NXT/EV3 dialog box. Use a USB cable to connect your NXT brick to your computer. Turn on your NXT brick. Under ''Choose NXT/EV3'', select ''Find NXT/EV3'' to display the Find NXT/EV3 dialog box.
Line 75: Line 75:
 You can test your motor by change the power level and then press ''Go'' button. Power level determines the speed and direction that NXT motor will turn. When unloaded, NXT motor's power level is proportional to its rotational speed, around 160 RPM at 100% power. NXT motor also has built-in encoder that has 360 counts per single revolution of motor.  You can test your motor by change the power level and then press ''Go'' button. Power level determines the speed and direction that NXT motor will turn. When unloaded, NXT motor's power level is proportional to its rotational speed, around 160 RPM at 100% power. NXT motor also has built-in encoder that has 360 counts per single revolution of motor. 
  
-=== Section 1.3: Hello World ===+==== Section 1.3: Hello World ====
  
 This example will show you how to display ''Hello World!'' message on the NXT brick screen.  This example will show you how to display ''Hello World!'' message on the NXT brick screen. 
Line 109: Line 109:
 {{ :yuhang:labview_nxt_motor:hello_world.png | Hello World!}} {{ :yuhang:labview_nxt_motor:hello_world.png | Hello World!}}
  
-=== 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 ''Choose NXT/EV3'', choose your NXT brick or use ''Find NXT/EV3'' to connect to your NXT brick. Check you are in Direct mode, then click run command on front panel or block diagram tool bar. The ''Hello World!'' message should display on your NXT brick screen for 1 second. To run a program, turn on your NXT brick and connect it to your computer with USB cable. On Robot Project Center, under ''Choose NXT/EV3'', choose your NXT brick or use ''Find NXT/EV3'' to connect to your NXT brick. Check you are in Direct mode, then click run command on front panel or block diagram tool bar. The ''Hello World!'' message should display on your NXT brick screen for 1 second.
  
-=== 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 -> ''I/O'' -> ''Move Moters''.+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 -> ''I/O'' -> ''Move Motors''.
 \\ \\  \\ \\ 
 {{ :yuhang:labview_nxt_motor:move_motor.png | Move Motors}} {{ :yuhang:labview_nxt_motor:move_motor.png | Move Motors}}
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:
 \\ \\  \\ \\ 
-''Motor A Power = constant gain * (Motor A Encoder - Motor B Encoder)''+''Motor A Power = constant gain * (Motor A Encoder - Motor B Encoder)''
 \\  \\ 
-''Motor B Power = constant gain * (Motor A Encoder - Motor B Encoder)''+''Motor B Power = constant gain * (Motor A Encoder - Motor B Encoder)''
 \\ \\  \\ \\ 
-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 control.+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 gain.
 \\ \\  \\ \\ 
 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.
 \\ \\  \\ \\ 
-{{ :yuhang:labview_nxt_motor:p_controller2.png | Proportional Controller}}+{{ :yuhang:labview_nxt_motor:p_controller3.png | Proportional Controller}}
 \\ \\  \\ \\ 
 +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 Integral (PIController === +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 integral controller can be implemented to accurately rotate NXT motors to desired position. Here is an exmple of PI controller. 
- +\\ \\  
- +{{ :yuhang:labview_nxt_motor:pi_controller.png | PI Controller}} 
-==== 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's objective was to <fill in the blank>Complete <choose: construction detailssource code and program descriptions> for <fill in the blank>. Once the concepts were conveyed the reader could <fill in the blank>.+This tutorial's objective was to introduce LabVIEW module for LEGO MINDSTORMS and demonstrate how to program NXT motorThe tutorial covers installation of LabVIEW modulehow to write program for NXT brick, and how to control NXT motor. Once the concepts were conveyed the reader could use LabVIEW module for LEGO MINDSTORMS to program NXT brick and motor.
 \\ \\
 \\ \\
-Speculating future work derived from this tutorialincludes <fill in the blank>In the big picture, the problem of <fill in the blankcan be solved with this tutorial.+LabVIEW module for LEGO MINDSTORMS included help manual and examplesyou can access them through toolbar on top of front panel or block diagramGo to ''Help'' -''Find Examples'' or ''MINDSTORMS Module Help''.
 \\ \\
 \\ \\
labview_nxt_tutorial.1501546639.txt.gz · Last modified: 2017/07/31 17:17 by yuhanghe