?????? NXC?NXT - PowerPoint PPT Presentation

1 / 58
About This Presentation
Title:

?????? NXC?NXT

Description:

NXC NXT * * * * * * * * * ROBOLAB ROBOLAB was originally developed by Tufts University for LEGO for the first generation LEGO ... – PowerPoint PPT presentation

Number of Views:247
Avg rating:3.0/5.0
Slides: 59
Provided by: mac165
Category:
Tags: nxc | nxt | lego

less

Transcript and Presenter's Notes

Title: ?????? NXC?NXT


1
???
  • ?????? NXC?NXT

2
??????
  1. NXC-??LEGO?????C??
  2. BricxCC-?????????
  3. ???????
  4. ????
  5. ???
  6. ??
  7. ??I/O??

3
????
  • ?????? ??????? ??
  • A Study of Developing the Technological Curiosity
    Inventory and Its Application to LEGO Hands-on
    Learning.
  • ???? ???? ??
  • ?????? ?????? ????????
  • ?????????
  • Educational Robot tutorial and curriculum design
  • Mobile Robot
  • Robotarm

4
CAVE????
  • 2009?? ?????? NXC?NXT, ?? C?????LEGO NXT?????
  • 2008??CAVE ????? ??????, ???????????. ??C, Java,
    LabVIEW?????.
  • 20002007 ????? ???????

5
CAVE????
  • ???? Comprehensive LEGO Silver book  LEGO?????
  • ???? Darkside of  LEGO NXT LabVIEW killer apps.
  • ???? Java being leJOS on NXT
  • Work on I2C devices
  • ????????

6
????CAVE
  • Blog CAVE LEGO
  • Youtube allelujahnissin
  • Picasa allelujahnissin
  • facebook allelujahnissin

7
??????
  • ??????????????
  • ?????? LEGO NXT
  • PC-based robot
  • Robotarm
  • ??????

8
LEGO MindStorms NXT
9
  • NXT?RCX??

NXT
RCX
  • ????
  • ???
  • ???
  • ????
  • ???
  • I/O??
  • LCD
  • ????

1999 Hitachi H8/3292 ???? 8K ROM
32KRAM ????? 2 wire connector system
3????,3???? 43????? 3??? x 6 RCX 2.0?????
2005 32??ARM7????,8??????? 256 K?????, 64 K
RAM4 K?????, 512 B RAM USB 2.0 (PC NXT),?? 6
wire digital platform. 4????,3???? 64 x
100????????????? 3??? x 6 ?????
10
Mindstorms (NXT-G)
11
Robolab
12
RobotC
13
NXJ (Java)
14
LabVIEW
15
NXC?NXT-G??
NXT-G
NXC
???(BrixCC) 12??? ???? http//bricxcc.sourceforg
e.net/ ? ????? ?? ????
???? ???? ???? ??????? ???? ??? ??
??? 8??? ?????   ? ?? ?? ????
16
Programming interface
  • Graphical
  • Text based
  • NXT-G
  • MicroSoft
  • Robotic Developer Studio
  • National Instruments
  • LabVIEW NXT toolkit
  • NXC
  • RobotC
  • Java
  • Others PbLua, php

17
Brief comparison
LabVIEW
MSRDS
??
Java
NXC
NXT-G
????
18
NXC
  • Not eXactly C by John C. Hansen.
  • Bricx Command Center (FREE!)
  • C-based language
  • Highly integrated with 3rd party I/O devices.

19
  • NXT????

USB ???
???(??)
  • ??
  • USB
  • ??
  • ??????
  • ??

??
??/??
???
??
??/??
???(???)
20
Bricx Command Center
21
Important settings and interfaces
  • Preferences
  • compiler, font, code completion.
  • Direct control
  • Watching the brick
  • Brick Joystick
  • NXT Explorer
  • NXT Screen

22
First Robot
http//ldd.lego.com/
23
First Program
01- 02- 03- 04- 05- 06- 07- 08- 09- task main() OnFwd(OUT_A, 75) OnFwd(OUT_B, 75) Wait(4000) OnRev(OUT_AB, 75) Wait(4000) Off(OUT_AB)
24
  • F5 Compile
  • F6 Download
  • F7 Run

25
Macro
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- define MOVE 1000 define TURN 850 task main() OnFwd(OUT_BC,75) Wait(MOVE) OnRev(OUT_BC,75) Wait(TURN) Off(OUT_BC)
26
Repeat loop
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- define MOVE 1000 define TURN 850 task main() repeat(5) OnFwd(OUT_BC,75) Wait(MOVE) OnRev(OUT_BC,75) Wait(TURN) Off(OUT_BC)
27
Nested loop
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- 14- 15- 16- 17- 18- define MOVE 1000 define TURN 850 task main() repeat(2) PlayTone(440,50) Wait (1000) repeat (5) OnFwd(OUT_BC,75) Wait(MOVE) OnRev(OUT_BC,75) Wait(TURN) Off(OUT_BC)

28
Control Structure and Variable
29
Variable
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- task main() int a 3 while(a lt 5) OnFwd(OUT_BC,75) Wait(1000) PlayTone(440,50) a Off(OUT_BC)
30
  • while

01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- 14- 15- 16- 17- 18- 19- define MOVE_TIME 500 define TURN_TIME 360 task main() while(true) OnFwd(OUT_AC, 75) Wait(MOVE_TIME) if (Random(2) 0) OnRev(OUT_C, 75) else OnRev(OUT_A, 75) Wait(TURN_TIME)
31
  • do while

01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- 14- 15- 16- int move_time, turn_time, total_time task main() total_time 0 do move_time Random(1000) turn_time Random(1000) OnFwd(OUT_AC, 75) Wait(move_time) OnRev(OUT_C, 75) Wait(turn_time) total_time move_time total_time turn_time while (total_time lt 20000) Off(OUT_AC)
32
SENSORS
33
Touch sensor
  • ?? SetSensorTouch(S1)

33
34
01- 02- 03- 04- 05- 06- 07 08- 09- 10- 11- 12- 13- task main() SetSensor(S1,SENSOR_TOUCH) while(true) OnFwd(OUT_AC, 50) until (SENSOR(S1) 1) OnRev(OUT_AC, 50) Wait( 500) OnFwd(OUT_A, 50) Wait(1000)
35
Sound sensor
  • ?? SetSensorSound(S2)

35
36
01- 02- 03- 04- 05- 06- 07 08- 09- 10- 11- 12- 13- task main() SetSensor(S1,SENSOR_SOUND) while(true) If (SENSOR(S1) gt90) PlayTone(440, 50) Wait( 500)
36
37
Ultrasonic sensor
  • ??SetSensorLowspeed(S4)

37
38
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- 14- 15- 16- 17- 18- 19- 20- 21- 22- 23- 24- 25- 26- 27- 28- 29- define DISTANCE 15 //cm task main() SetSensorLowspeed(IN_4) while(true) OnFwd(OUT_AC,20) if(SensorUS(IN_4) lt DISTANCE) Off(OUT_AC) OnRev(OUT_AC,20) Wait(800) Off(OUT_AC) else if(SensorUS(IN_4) DISTANCE) Off(OUT_AC) PlayTone(440,50) Wait(1000) else if(SensorUS(IN_4) gt DISTANCE) Off(OUT_AC) OnFwd(OUT_AC,20) Wait(800) Off(OUT_AC)
38
39
Rotation sensor
??RotateMotor(OUT_Port , Speed , Degree)
01- 02- 03- 04- 05- 06- 07- 08- task main() int x RotateMotor(OUT_A, 75, 180) // ??180? x MotorTachoCount(OUT_A) NumOut(20, LCD_LINE3, x) Wait(3000)
Give a try! x 180?
40
Light sensor
  • ??SetSensorLight(S3)

40
41
01- 02- 03- 04- 05- 06- 07 08- 09- 10- 11- 12- 13- task main() SetSensorLight(S3) // SetSensor(S1,SENSOR_LIGHT) while(true) ClearScreen() TextOut(0,20,"Light is") NumOut(60,20,Sensor(S3)) if (Sensor(S3) gt40) PlayTone(440, 50) //beep Wait( 200) //0.2 sec
41
42
??? ???????
  • task
  • start
  • Precedes()
  • mutex Acquire() ? Release()
  • subroutine
  • sub FunctionName (data type varible)
  • inline function
  • inline int B( ?? )
  • statements
  • return x

43
  • Macro

????????? define ???????,???????? define
????????????
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- define turning \ OnRev(OUT_B, 75) Wait(3400)OnFwd(OUT_BC, 75) task main() OnFwd(OUT_BC, 75) Wait(1000) turning Wait(2000) turning Wait(1000) turning Off(OUT_BC)
44
??? ?????
  • NXC????????4??
  • 1.unregulated
  • 2.speed regulation
  • 3.synchronized
  • 4.tachometer-limited

45
  • ??? ???

01- 02- 03- 04- 05- 06- 07- 08- 09- 10- task main() OnFwd(OUT_AC, 75) Wait(500) Off(OUT_AC) Wait(1000) OnFwd(OUT_AC, 75) Wait(500) Float(OUT_AC)
Off() Float() Coast()
??Off()?,NXT????????????????????????????Float()??,
NXT??????????,????????????????????????????
46
  • ?????(unregulated)

OnFwd() OnRev()
47
  • ????(regulation)

OnFwdReg(???,??,????) OnRevReg (???,??,????)
48
  • ???????

OUT_REGMODE_IDLE OUT_REGMODE_SPEED OUT_REGMODE_S
YNC
49
  • ??????(speed regulation)

OnFwdReg(OUT_C, 40, OUT_REGMODE_SPEED)
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- task main() OnFwdReg(OUT_A, 40, OUT_REGMODE_IDLE) OnFwdReg(OUT_C, 40, OUT_REGMODE_SPEED) while(true) NumOut(10, LCD_LINE1, MotorActualSpeed(OUT_A)) NumOut(10, LCD_LINE2, MotorActualSpeed(OUT_C))
50
  • ????(synchronized)

OnFwdReg(OUT_AC, 40, OUT_REGMODE_SYNC)
51
  • ????IDLE?SPEED?SYNC

01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- 14- 15- 16- 17- task main() OnFwdReg(OUT_AC,50,OUT_REGMODE_IDLE) Wait(2000) Off(OUT_AC) PlayTone(4000,50) Wait(1000) ResetTachoCount(OUT_AC) OnFwdReg(OUT_AC,50,OUT_REGMODE_SPEED) Wait(2000) Off(OUT_AC) PlayTone(4000,50) Wait(1000) OnFwdReg(OUT_AC,50,OUT_REGMODE_SYNC) Wait(2000) Off(OUT_AC)
52
  • ??????????

OnFwdSync() OnRevSync()
OnFwdSync()?OnRevSync()???????? OnFwdSync(???,
??,?????)
0 ?? 50 ??????? 100 ???????????
53
01- 02- 03- 04- 05- 06- 07- 08- 09- 10- 11- 12- 13- 14- 15- 16- task main() PlayTone(5000,30) OnFwdSync(OUT_AC,50,0) Wait(1000) PlayTone(5000,30) OnFwdSync(OUT_AC,50,50)//?????50 Wait(1000) PlayTone(5000,30) OnFwdSync(OUT_AC,50,-50) //????-50 Wait(1000) PlayTone(5000,30) OnRevSync(OUT_AC,50, -100) //????,????-100 Wait(1000) Off(OUT_AC)
54
  • ?????(tachometer-limited)

RotateMotor(???,??,??)
55
01- 02- 03- 04- 05- 06- 07- 08- task main() RotateMotor(OUT_A, 50,360) //A???????? RotateMotor(OUT_A, 50,-360) //A???????? RotateMotor(OUT_A, -50,-360) //A???????? RotateMotor(OUT_C, 50,-360) //C???????? RotateMotor(OUT_C, -50,360) //C????????
56
  • ????-RotateMotorEx()

RotateMotorEx(???,??,????,?????,????,????) Rotat
eMotorEx(OUT_AC, 75, 180, 0, true, true)
57
3rd party sensors
58
??
  • Passion
  • Open mind
  • Hard Work
Write a Comment
User Comments (0)
About PowerShow.com