DISPLAY and MOVE Day 2
description
Transcript of DISPLAY and MOVE Day 2
![Page 1: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/1.jpg)
DISPLAY and MOVEDay 2
Computer Programming through Robotics
CPST 410
Summer 2009
![Page 2: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/2.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 2
Course organization
Course home page (http://robolab.tulane.edu/CPST410/)
Hand out syllabi.Notice that Aug. 10 is the final day to turn
in the final project.Lab (Newcomb 442) will be open for
practice with 3-4 Macs, but you can bring your own laptop and all robots.
![Page 3: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/3.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 3
Phot
os
![Page 4: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/4.jpg)
Preliminaries
![Page 5: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/5.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 5
Update on robots
Are they all assembled?Who has a laptop?Start installing software.
![Page 6: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/6.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 6
Upgrade firmware on robot
Launch the Mindstorms NXT application on your laptop. Turn on the NXT brick. Connect the next brick to your laptop via the USB cable. From the Tools menu (at the top), select Update NXT
Firmware. In the Update NXT Firmware window, click 1.05 version
to highlight it. Click Download. Don't unplug it!
![Page 7: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/7.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 7
The first screen
![Page 8: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/8.jpg)
Hello World!
Kelly §3
![Page 9: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/9.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 9
The Tradition
The first program anyone writes displays 'Hello World!' on the screen.
Who are we to break with tradition?So let's get started …... with pseudo-code:
SPOT, I'd like you to display the words "Hello World!" on your LCD screen.
![Page 10: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/10.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 10
Start your first program
In the text box under Start New Program, type 'HelloWorld' -- the name for our first program --
and click on ‘Go >>’.
![Page 11: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/11.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 11
The palette
![Page 12: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/12.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 12
The DISPLAY block
Drag a DISPLAY block from the common column
into the 'Start' space
![Page 13: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/13.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 13
The DISPLAY block’s settings
![Page 14: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/14.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 14
The settings in detail
ActionImageTextDrawingReset
DisplayClear
File
Positionx (length)y (height)
![Page 15: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/15.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 15
Enter the text
Change your block’s action to Text and enter "Hello, world!" in the box. Note the x and y values, plus the appearance of the line number.
File > Save. Connect the robot to your laptop with the USB cable, if you
haven’t already done so.
![Page 16: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/16.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 16
The controller
Five buttons that turn orange when the mouse rolls over them:NXT windowDownload and run
selectedStopDownloadDownload and run
![Page 17: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/17.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 17
The NXT window: Comm tab
Look at the battery charge Tell me whenever it goes down under 25%, so I can recharge the
batteries.
If you are authorized: change the name to the name you choose (max 8 characters) and push the return key.
![Page 18: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/18.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 18
The NXT window: Memory tab
You can manually upload (and download) files from this screen, as well as delete them to free up memory.
![Page 19: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/19.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 19
Download and run the program
In the Controller, click the right arrow in the center (Download and run).
On the NXT brick, press the orange button.
![Page 20: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/20.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 20
What happened?
The text was displayed so quickly that you may not have seen it.
But that is easy to fix.New pseudo-code:
SPOT, I'd like you to display the words "Hello World!" on your LCD screen for 10 seconds.
![Page 21: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/21.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 21
The WAIT blocks
There are several ways to implement this pseudo-code, but the one we shall use here involves a TIME WAIT block.
Go to the application, click on the hourglass icon in the Common palette, and look at the WAIT blocks that spring out from it.
![Page 22: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/22.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 22
DISPLAY + WAIT
Drag out a TIME WAIT block (timer icon) from the hourglass, and drop it right after the DISPLAY block
![Page 23: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/23.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 23
The TIME WAIT block
Take a look at its settings,and enter the number of seconds to wait.Notice how this number appears on the block.
Save and download to the NXT brick.
![Page 24: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/24.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 24
Play time
Take about 10 minutes to vary the settings of the DISPLAY and TIME WAIT blocks and see what happens.
Obviously, you want to predict what will happen before the program runs.
![Page 25: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/25.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 25
Data hubs - skip!
The settings of the DISPLAY block can be changed from other parts of the program by revealing its data hub.
Put your cursor at the bottom of the DISPLAY block and try to pull down the indented line.
Running the cursor over each icon reveals the kind of information that it accepts.
![Page 26: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/26.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 26
The VARIABLE block - skip!
What Kelly describes does not work!To illustrate the usefulness of the data hub,
change to the Complete palette (the 3 interlocking squares at the bottom left).
Select the big orange plus sign (Data),pull out a suitcase (Variable), anddrop it in front of the DISPLAY block.Change its setting from Logic 1 to Number 1.
![Page 27: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/27.jpg)
The text-based language NXC
Hansen
![Page 28: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/28.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 28
PC users
Bricx Command Center 3.3http://bricxcc.sourceforge.net/
![Page 29: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/29.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 29
First look at BricxCC
Open BricxCC and move the Brick Command Center window to the left so that the Templates window is visible (see next slide).
![Page 30: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/30.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 30
Now go to the File menuand start a new program.
![Page 31: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/31.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 31
A basic program (p. 148)
A program must always have at least one task, followed by braces that contain the code that the task executes:task name()
{// the task's code is placed here
}
From the Templates window, click on the Programs box and then click Task…(){…}. [next]
![Page 32: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/32.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 32
Replace “name” with main, which is used for a task
that has no obvious name.
![Page 33: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/33.jpg)
Hello, world!
In NXC
![Page 34: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/34.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 34
NXC HelloWorld
Instead of blocks, NXC has functions.We need two, one to display the text and
the other to keep the text on the screen for a while.
![Page 35: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/35.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 35
TextOut
NXC supplies a function specifically to display text, TextOut.
This function asks you for 3 pieces of informationHow many pixels from the left the text begins,What line the text begins on,And the text itself.
This information is put between parentheses, with each piece separated by a comma. The text is also quoted:TextOut(0, LCD_LINE1, “Hello, world!”)
![Page 36: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/36.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 36
TextOut in BricxCC
In BricxCC, select “body” in the task, andIn the Templates window, open the
Drawing box and click on the topmost TextOut function. [see next]
![Page 37: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/37.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 37
![Page 38: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/38.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 38
Filling in TextOut in BricxCC
![Page 39: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/39.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 39
Wait
The function for keeping the text on the screen is Wait.
It measures time in milliseconds:Wait(10000)
In BricxCC, open the Timing box in the Templates window, and click on the Wait function. [see next]
![Page 40: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/40.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 40
Now replace “time(1 ms)”with 10000.
![Page 41: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/41.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 41
Wait(10000)
![Page 42: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/42.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 42
Compiling
Now go to the Compile menu and select Compile.If you did everything right, nothing much happens.
However, if you made a mistake, the compiler might catch it.It will find typos;It will find syntax errors; for instance, it expects that
every line of code must be terminated by a semi-colon.
![Page 43: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/43.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 43
Test the compiler
As an example,change LCD_LINE1 > LCD_LIN1leave off the semicolon after Wait(10000)
Compile and see what happens.Try some more.
![Page 44: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/44.jpg)
Summary
![Page 45: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/45.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 45
DISPLAY vs. TextOut
TextOut(0,LCD_LINE8,”test”)
![Page 46: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/46.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 46
TIME WAIT vs. Wait
Wait(1)
![Page 47: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/47.jpg)
Get Movin'
Kelly §4
![Page 48: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/48.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 48
The MOVE block
Start a new program and name it 'Move'.Drag a MOVE block (interlocking gears) onto the
working area.Look at its settings.
![Page 49: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/49.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 49
MOVE block settings
Ports: A, B, C (at top of NXT block). Direction: forwards (up), reverse (down), stop. Steering: if two motors are connected, dragging the control away from
center makes the robot go in a circle. Power: changes speed of a motor. Duration: unlimited, degrees, rotations, seconds
Degrees & rotations must be positive, but you can make them negative by changing Direction to reverse.
Rotations also allows fractions. Next Action: brake, coast
Brake applies the brakes for a quick, accurate stop that uses power. Coast disengages the motors. If the robot has inertia, it will keep moving.
![Page 50: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/50.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 50
Play time
Take about 10 minutes varying the settings of the MOVE block and see what happens.
Obviously, you want to predict what will happen before the program runs.
![Page 51: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/51.jpg)
Get reset
Kelly §24
![Page 52: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/52.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 52
Execute this program
SPOT, move forward 360 degrees (and coast) and wait 3 seconds.
SPOT, move forward 270 degrees (and coast) and wait 3 seconds.
Now, move forward 90 degrees and stop.
![Page 53: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/53.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 53
Results
How far should SPOT have moved?360° + 270° + 90° = 720° or 2 rotations
How far did SPOT actually move?Is that what you would expect from
watching SPOT execute the program?No, because SPOT coasted a little after the first
two movements, so it should be off.
![Page 54: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/54.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 54
Error correction
The NXT brick pairs motors and watches them to make sure that they spin at the same rate.
It also corrects for coasting errors, as we just saw.
![Page 55: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/55.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 55
The RESET MOTOR block
If you want to turn error correction off, drop a RESET MOTOR block after a MOVE block.
It resets the motors to 0, turning off the error correction.
Add the necessary RESET MOTOR blocks to the program, and see what happens.
![Page 56: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/56.jpg)
Outputs in NXC
Hansen pp. 153-4 (§7)
236ff (§10)
407ff (Appendix A)
![Page 57: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/57.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 57
Normal motor control
OnFwd(ports, power) - forwardOnRev(ports, power) - reverseCoast(ports) - turn off and coast
also called Float
Off(ports) - turn off and brakereset Block & Tacho, but not Rotation counters
![Page 58: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/58.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 58
Motor port outputs
Each motor port has an output constant OUT_A OUT_B OUT_C
They can be combined to run together: OUT_AB OUT_AC OUT_BC OUT_ABC
![Page 59: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/59.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 59
Challenge
SPOT, move forward for 5 seconds at 75% power, then do the same in reverse, and then stop.
![Page 60: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/60.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 60
movenorm.nxc
task main()
{OnFwd(OUT_AC, 75); // move forward at 75%
Wait(5000); // wait 5 secs
OnRev(OUT_AC, 75); // move backwards at 75%
Wait(5000); // wait 5 secs
Off(OUT_AC); // stop
}
![Page 61: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/61.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 61
Regulated motor control
The firmware can automatically adjust the power level if it is not being achieved due to friction or some other external influence (like trying to slow one wheel with your fingers)OnFwdReg(ports, power, regmode)OnRevReg(ports, power, regmode)
regmodeOUT_REGMODE_SPEED: turns on regulationOUT_REGMODE_IDLE: turns off regulation
same as OnFwd/OnRev
![Page 62: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/62.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 62
Challenge
SPOT, move forward for 5 seconds at 40% regulated power, then do the same in reverse, and coast to a stop.
While SPOT is moving, slow him down with your hand and see if the motors try to speed up.
![Page 63: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/63.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 63
movereg.nxc
task main(){
OnFwdReg(OUT_AC, 40, OUT_REGMODE_SPEED);Wait(5000); // wait 5 secsOnRevReg (OUT_AC, 40, OUT_REGMODE_SPEED);Wait(5000); // wait 5 secsCoast(OUT_AC); // roll to a stop
}
![Page 64: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/64.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 64
Synchronized motor control
The firmware can automatically adjust the power level to keep two motors running at the same speedOnFwdSync(ports, power, turnpct)OnRevSync(ports, power, turnpct)
turnpctthe percentage that the motors turn to one side or the
either, -100 or 100
![Page 65: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/65.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 65
Challenge
SPOT, move forward for 5 seconds at 40% synchronized power, then do the same in reverse but turning to the right, and then coast to a stop.
![Page 66: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/66.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 66
movesync.nxc
task main(){
OnFwdSync(OUT_AC, 40, 0); Wait(5000); // wait 5 secsOnRevSync(OUT_AC, 40, 50);Wait(5000); // wait 5 secsCoast(OUT_AC); // roll to a stop
}
![Page 67: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/67.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 67
Tachometer motor control
The rotation sensors built into the motors tell the firmware how fast and how far the motors have turned, information which can be used to control them.RotateMotor(ports, power, angle)
anglein degrees, positive or negative
![Page 68: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/68.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 68
Challenge
SPOT, move forward at 40% power for two rotations, then do the same in reverse, and coast to a stop.
![Page 69: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/69.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 69
moverot.nxc
task main(){
RotateMotor(OUT_AC, 40, 720);// the rotations take the place of waiting RotateMotor(OUT_AC, 40, -720);Coast(OUT_AC);
}
![Page 70: DISPLAY and MOVE Day 2](https://reader036.fdocuments.in/reader036/viewer/2022062423/568145aa550346895db2a162/html5/thumbnails/70.jpg)
7/1/09 Harry Howard, CPST 410, Tulane University 70
Next time
Whatever we didn’t finish for today.A project?Logic, sensors, calibration; Waiting, loops
Kelly §8-9, 23; §10-11