Download presentation
Presentation is loading. Please wait.
Published byAlexandro Huish Modified over 10 years ago
1
Lego Mindstorms and NXT-G Magnus Eriksson, Mid Sweden University 2012 Based on a presentations by National Instruments and Pavel Petrovič
2
Först några påminnelser… Bråttom att registrera sig! (Portal.miun.se) Kursmaterial finns i Lärplattformen 2 (Moodle), som du hittar via portal.miun.se Projektgrupperna kommer att ändras lite - högst 7 studenter i varje Kursens deadlines framgår av schemat Börja fundera på en intelligent produkt med realistisk marknad redan nu!
3
3 Lego Mindstorms can be used for rapid prototyping of intelligent and sensor- based systems Rubik’s cube solver
4
Pen-Drawer Robot
5
The NXT2.0 unit (Motor ports) (Sensor ports)
6
Motors and Sensors
7
7 Built-in rotation sensors (“servo”) NXT Motors
8
The NXT2.0 Unit – an embedded system 64K RAM, 256K Flash 32-bit ARM7 microcontroller 100 x 64 pixel LCD graphical display Sound channel with 8-bit resolution Bluetooth wireless communications Stores multiple programs – Programs selectable using buttons
9
LEGO Mindstorms for NXT (NXT-G) NXT-G graphical programming language Based on the LabVIEW programming language G Program by drawing a flow chart
10
NXT-G PC program interface Toolbar Workspace Configuration Panel Help & Navigation Controller Palettes TutorialsWeb Portal Sequence Beam
11
NXT-G tools Pointer tool: move blocks, select blocks Pan tool: move within workspace Comment tool: add notes to your code
12
Intro to NXT-G: Palettes Common:Complete:Custom: MostAll blocksDownloa Own blocks commonly used blocks
13
Writing a Basic Program Drag and drop block(s) on sequence beam Manipulate Configuration Panel & Download
14
Intro to NXT-G: Controller Download & Run Selection Download & Run NXT Window Download Stop
15
NXT Rotation Sensor Built in to motors Measure degrees or rotations Reads + and - Degrees: accuracy +/- 1 1 rotation = 360 degrees
16
Viewing Sensors Connect sensor Turn on NXT Choose “View” Select sensor type Select port
17
NXT Sound Sensor Sound sensor can measure in dB and dBA – dB: in detecting standard [unadjusted] decibels, all sounds are measured with equal sensitivity. Thus, these sounds may include some that are too high or too low for the human ear to hear. – dBA: in detecting adjusted decibels, the sensitivity of the sensor is adapted to the sensitivity of the human ear. In other words, these are the sounds that your ears are able to hear. Sound Sensor readings on the NXT are displayed in percent [%]. The lower the percent the quieter the sound. http://mindstorms.lego.com/Overview/Sound_Sensor.aspx
18
Challenge: Stop with sound Program your NXT car to drive until you yell “Stop”
19
Example Program: Stop with Sound
20
NXT Ultrasonic/Distance Sensor Measures distance/proximity Range: 0-255 cm Precision: +/- 3cm Can report in centimeters or inches http://mindstorms.lego.com/Overview/Ultrasonic_Sensor.aspx
21
Challenge: Parking NXT Program your NXT car to drive forward until you “find a parking spot” (hit a touch sensor) The car should then turn into the spot, and stop when it gets close enough to wall.
22
Example Program: Parking NXT
23
A note about NXT memory Memory space is limited! To clear space, use NXT window Show and delete system files for more space
24
NXT Structure: Loops
25
Challenge: Stay on Table Program your NXT to stay on the table
26
Example Program: Stay on Table
27
NXT Structure: Switch
28
Challenge: Remote Control Program car to drive while the touch sensor is pushed and stop while the touch sensor is released
29
Example Program: Remote Control
30
NXT Sound NXT can play sound files or notes Sounds take up more memory space
31
NXT Display Display images, text, or drawings Choose location on display screen 100 x 64 pixels (up to 7 lines of text) Graphics take up memory space
32
Challenge: Say Hello Have the NXT say hello using sound and the display screen Don’t forget – the program ends after the last block. You may need a wait for to see the display. Caution: one of the options in the configuration panel is Clear – use it to clear screen. Otherwise, uncheck the box!
33
Example Program: Say Hello
34
My Blocks Create custom blocks Saved in custom palette Download blocks from the web
35
Creating My Blocks Write the code for the My Block
36
Creating My Blocks Select all the blocks to be used for My Block
37
Creating My Blocks Choose “Create My Block” on toolbar Or, go to the Edit menu and select “Make a new My Block”
38
Creating My Blocks Name My Block Add a description
39
Creating My Blocks Create a custom icon
40
Creating My Blocks My Block appears in Custom Palette
41
Signal flows and variables
42
42 An advanced program
43
43 Multi-treading
44
LEGO Mindstorms 3.0 EV3
45
Getting started with mindstorms EV3 https://www.youtube.com/watch?v=vv5X3zzkBk4
46
46 Master-slave: only master initiates communication Master can connect up to 3 slaves Optional acknowledgement, request reply Mailboxes #1-10 Sending: – Master: NXTCommBTWrite(slave, mailbox) – Slave: NXTMessageWrite(mailbox) Receiving: both sides NXTMessageRead() Unreliable & Quite complex, but does not block NXT BlueTooth Protocol Silvian Toledo: http://www.tau.ac.il/~stoledo/lego/btperformance.html
47
47 LEGO Digital Designer ldd.lego.com CAD-verktyg – Eventuellt för Civing Teknisk design
48
48 Pneumatics För Civing Teknisk design
49
49 NXT Non-standard sensors: HiTechnic.com Compass Gyroscope Accellerometer/tilt sensor, Color sensor IRSeeker Prototype board with A/D converter for the I2C bus För Elektroniksystemstudenter
50
50 Issues of the standard firmware För datateknikstudenter Only one data type Unreliable bluetooth communication Limited multi-tasking Complex motor control Simplistic memory management Not suitable for large programs Not suitable for development of own tools or blocks
51
Other programming languages and environments – Java leJOS – Microsoft Robotics Studio – RobotC – NXC - Not eXactly C – NXT Logo – Lego NXT Open source firmware and software development kit För datateknikstudenter
52
leJOS A Java Virtual Machine for NXT Freely available – http://lejos.sourceforge.net/ Replaces the NXT-G firmware LeJOS plug-in is available for the Eclipse free development environment Faster than NXT-G För datateknikstudenter
53
Example leJOS Program sonar = new UltrasonicSensor(SensorPort.S4); Motor.A.forward(); Motor.B.forward(); while (true) { if (sonar.getDistance() < 25) { Motor.A.forward(); Motor.B.backward(); } else { Motor.A.forward(); Motor.B.forward(); } För datateknikstudenter
54
54 NXT Logo example: line-following to "follow [] [ setsensor 3 5 128 motor 0 "onrev 40 while ["true] [ while [ge? sensor 3 59] [] motor 0 "float 0 motor 2 "onrev 40 wait 50 while [lt? sensor 3 60] [] motor 2 "float 0 motor 0 "onrev 40 ] För datateknikstudenter
55
Gruppindelning
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.