![Page 1: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/1.jpg)
Advanced NXT-G Programming
John FieldFormer Software Group Manager
for MINDSTORMS® NXT
![Page 2: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/2.jpg)
Agenda
Benefits of MINDSTORMS Software v1.1
Complete Palette Overview
Datahubs and Wiring
Decision Making using Logic and Compare
Variables
Q & A
![Page 3: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/3.jpg)
Benefits of v1.1
Vista & Intel-based Mac support
Improved Performance on all OSes
Smaller Compiled Files (.rxe) on the NXT
Large Programs are easier to build
Lots of small features & bugs fixed
![Page 4: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/4.jpg)
PC Software Stack
fll.rbt
Blocks MyBlocks
MINDSTORMS Editor
Programs
MINDSTORMS Compiler
LabVIEW Engine
Fantom driver
VISA Engine
OS USB OS Bluetooth
MINDSTORMS.exe
Fantom.dll
![Page 5: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/5.jpg)
NXT Software Stack
fll.rxe
NXT VM
I/O Map
NXT FW
rxe files are the executable version of the rbt
NXT VM - Runs programs (now execute this block...)
NXT FW - Handles low level details (such as reading a sensor or handling Bluetooth)
I/O Map - Interface between them
![Page 6: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/6.jpg)
NXT Execution FlowRead sensor values and place in I/O Map
Hand control over to the VM
VM executes part of the rxe file
May read sensor values from I/O map
May update I/O map to tell motors to run
Motors look at the I/O map to determine what to do
Repeat
![Page 7: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/7.jpg)
CompletePalette
Common
Action
Sensor
Flow
Data
Advanced
![Page 8: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/8.jpg)
Move
Rec/Play
Sound
Display
Wait
Loop
Switch
Common
![Page 9: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/9.jpg)
Good for multiple motor operations.
NXT FW synchronizes the motors
Less susceptible to battery levels with turns
Move
![Page 10: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/10.jpg)
Motor
Sound
Display
Send Message
Motor*
Lamp*
Action
![Page 11: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/11.jpg)
Good for single motor operations.
Allows for fine grain control
Ramping
Motor Power
When should I use move with 1 motor?
Motor
![Page 12: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/12.jpg)
Touch
Sound
Light
Ultrasonic
NXT Buttons
Rotation
Timer
Receive Message
Sensor
Touch*
Rotation*
Light*
Temperature*
![Page 13: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/13.jpg)
Logic
Math
Compare
In Range
Random
Variable
Data
![Page 14: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/14.jpg)
Datahubs and Wires4 Data Wires
Number
Logic
Text
Broken
2 Types of Hubs
Input/Pass-through
Output Only
![Page 15: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/15.jpg)
You can move wires, but they don’t look selected.
Undo is your friend.
To find and fix all broken wires
Go to forums.nxtasy.org
Search for “broken wire”
Warning: You are getting to the edge of the software. The editor isn’t always
cooperative.
http://forums.nxtasy.org/index.php?showtopic=444&hl=broken%20wires&st=0
Wiring
![Page 16: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/16.jpg)
Decision using Logic
Go forward for 2 rotations or the robot is within a foot of an object.
Let’s build it!
![Page 17: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/17.jpg)
Decision using Switch
Print “above” to the display if either the sound or light sensor exceeds 50. Otherwise, print “below”.
Let’s take a look.
![Page 18: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/18.jpg)
Complex Decision
If the light sensor intensity is between
0-25: play a low tone
26-75: play a middle tone
76-100: play a high tone
Also, output the region to the display
Let’s take a look at this program.
![Page 19: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/19.jpg)
VariablesCreate in each program & My Block that needs access
Good for
Counting
Saving Rotations
Passing data to one or more MyBlocks
Edit:Define Variables...
![Page 20: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/20.jpg)
Count Claps
![Page 21: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/21.jpg)
Store Rotations
![Page 22: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/22.jpg)
Variable Scope
Variables with the same name are shared globally when a program is running
fll.rbtrotations
MyBlock1rotations
rotations
![Page 23: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/23.jpg)
Variable Scope
To avoid problems like this, use MyBlock1_rotations & MyBlock2_rotations
fll.rbt MyBlock1
MyBlock2
rotations
rotations
rotations
![Page 24: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/24.jpg)
Text
Number to Text
Keep Alive
File Access
Calibrate
Reset Motor
Advanced
Great Debugging Tools
![Page 25: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/25.jpg)
Without Reset Motors
180 coast 180-coast
Total360
![Page 26: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/26.jpg)
With Reset Motors
180 coast 180
Total360 + coast
![Page 27: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/27.jpg)
Favorites
thenxtstep.blogspot.com
LEGOEngineering.com - click Podcasts
forums.nxtasy.org
thefieldhousehold.com/Web/NXT.html
![Page 29: Advanced NXT-G Programming · NXT Execution Flow Read sensor values and place in I/O Map Hand control over to the VM VM executes part of the rxe file May read sensor values from](https://reader033.vdocument.in/reader033/viewer/2022050100/5f3ff07c4772cf780649007a/html5/thumbnails/29.jpg)
Q & A