LabVIEW (NXT)

advertisement
Exercise 1:
Install PC Software & NXT Firmware
• Install FTC Software 2010 CDs
(LabVIEW + MINDSTORMS software + FTC Toolkit)
• Upgrade NXT firmware to 1.28
(LabVIEW >> Tools >> NXT Tools >> NXT Terminal >> Update Firmware)
1
LabVIEW: NXT & Tetrix
Training & Exercises
Overview
•
•
•
•
•
•
•
NXT Review
NXT-G  LabVIEW
General Programming
LabVIEW (NXT)
LabVIEW (Tetrix)
Resources
Learn More
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
3
NXT Hardware
• Inputs (to NXT Brick)










• Outputs (from NXT Brick)
Touch Sensor
Sound Sensor
Light Sensor
Ultrasonic Sensor
Rotation Sensor
NXT Buttons
Temperature Sensor (Legacy)
Read Bluetooth Messages
(Read Files)
NEW: IR Sensor
NXT Review NXT-G  LV
Gen. Prog.
LV NXT






LV Tetrix
Motor
Sound
Display
Lamp (Legacy)
Write Bluetooth Messages
(Write Files)
Resources
4
NXT-G Environment
Palettes
Workspace
Block
Download Options
Configuration Panel
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Help
Resources
5
LabVIEW Environment
Constants
(Inputs)
VI
(Block)
Block
Diagram
Palettes
Workspace
Block
Download Options
Configuration Panel
NXT Toolkit Palette
Context Help Window
NXT Review NXT-G  LV
Help
NXT Terminal Window
Gen. Prog.
LV NXT
LV Tetrix
Resources
6
General Programming
• Data Types
Numeric
 Boolean
 String
 Ring

• Dataflow
• Loops
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
7
Data Types: Numeric
• Whole Numbers (0,2,-10, …)
• Decimal Numbers (2.2, 12.3, -15.1, …)

Which takes up more memory?
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
8
Data Types: Boolean
• For Example:
On/Off
 Yes/No
 True/False

NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
9
Data Types: String
• Grouping of Characters
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
10
Data Types: Ring
• List of Predefined Items User Can Select
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
11
Dataflow
• Sequence Beam
• Sequence Flow In/Out
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
12
Loops
• Repeat Code
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
13
LabVIEW (NXT)
•
•
•
•
•
•
•
•
Context Help Window
User Documentation
Constants
Case Structures
Variables
Real Time User Interaction with Brick
Program Download Options
Debugging
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
14
Context Help Window
• Help >> Show Context Help
• Terminals
Required
 Recommended
 Optional

NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
15
User Documentation
• Labels (attached)

Right-click >> Show >> Label
• Free Labels (unattached)

Double click
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
16
Constants
• Configuration Panel
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
• Block Diagram
LV Tetrix
Resources
17
Case Structures
• Switch (NXT-G)
• Case Structure
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
18
Variables
• Variable (NXT-G)
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
• Local Variable
LV Tetrix
Resources
19
Exercise 2: (NXT) Motor
• Task:

Move robot in a square using Move Motor and
Timing VIs
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
20
Exercise 3: (NXT) Motor + Light Sensor
• Task:

Move robot inside a square outlined by tape using
Light Sensor
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
21
Real Time User Interaction with Brick
•
•
•
•
Front Panel
Controls
Indicators
Plotting Data
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
22
Program Download Options
• NXT Terminal (Tools >> NXT Tools >> NXT Terminal)
Compile and Download
 Compile, Download, and Run
 Debug

• Front Panel linked to running code

Abort
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
23
Exercise 4:
(NXT) Motor + Light Sensor + Front Panel
• Task:
Alter Exercise 3: (NXT) Motor + Light Sensor
 Put light detection threshold value on Front Panel
 Put turn degrees on Front Panel

NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
24
Debugging
• Debug (download option)
• Broken “Run” Arrow in LabVIEW
• Context Help
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
25
Demo 3: Direct Commands
• Task:





Scan for all Available NXT Bricks
User Selects One Brick to Connect
Query Brick for All of Its Files
Remotely Start One Program
Remotely Stop the Program
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
26
LabVIEW (Tetrix)
• New Hardware Items
• Tetrix VIs
• Additional Need-to-know
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
27
New Tetrix Hardware Items
•
•
•
•
•
•
DC Motors
Motor Controller
Servos
Servo Controller
Touch Mux
Compass
NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
28
Tetrix VIs (formerly FTC)
NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
29
FTC Tools
30
Additional Need-to-know
NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
31
Exercise 5:
4 Tetrix Motors + 2 NXT Motors
• Task:
Move Robot in a Square
 Open/Close Claws Every 5 seconds

NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
32
Demo 4: ConstantSpeedGodz
• Task:
Constant Speed
 Dead Zone Implementation
 Sound File
 Controller Station

NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
33
Resources
•
•
•
•
“If You Forget Everything Else”
Help
Examples
Big Differences
NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
34
“If You Forget Everything Else”
•
•
•
•
•
•
•
When in doubt, Right-click.
Constants = Inputs (on Block Diagram)
Controls = Inputs (on Front Panel)
Indicators = Outputs (on Front Panel)
Palettes (Right-click on Block Diagram, Front Panel)
Context Help (“?”, CTRL + H, Help >> Show Context Help)
NXT Terminal (Tools >> NXT Tools >> NXT Terminal)
NXT Review
NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
35
Help
•
•
•
•
Right-click
Context Help (“?”, CTRL + H, Help >> Show Context Help)
LabVIEW Help (Help >> Search the LabVIEW Help… >> Search: “NXT”)
PDF Manuals (C:\Program Files\National Instruments\LabVIEW 2009\manuals)



NXT_Getting_Started
NXT_Advanced_Programming_Guide
FTC_Getting_Started
• LabVIEW for LEGO MINSTORMS NXT (by Michael Gasperi)
• www.ni.com/academic/mindstorms/
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
36
Examples
• NXT

www.ni.com >> Search: “nxt example”
• Tetrix

C:\Program Files\National Instruments\LabVIEW 2009\examples\FTC Toolkit
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
37
Big Differences: NXT-G & LabVIEW
•
•
•
•
•
•
•
•
•
Sequence Beam vs. Sequence Flow In/Out
Front Panel
Debug in Real Time (download option)
Direct Commands
Data Logging
Arrays, Clusters
Numeric, Boolean, String Manipulation
Mathematical Processing
…
Questions?
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
38
Learn More
• Tool Selection Window
• Arrays

•
•
•
•
•
Graphs
Clusters
Write/Read to File
Flat Sequence Structure
How to Remotely Control your NXT with LabVIEW
Latching/Switching Booleans
NXT Review NXT-G  LV
Gen. Prog.
LV NXT
LV Tetrix
Resources
39
Download