Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

multitasking

Multitasking means doing more than one thing at a time. You use multitasking in a program to make your robot perform two (or more) independent tasks simultaneously. For example, your program could have one section to control the robot’s navigation and a separate section to collect sensor data.

In NXT-G, multitasking is accomplished using multiple Sequence Beams. Figure 17-1 shows an example based on the AroundTheBlock program introduced in Chapter 4. The blocks on the Sequence Beam at the top of the program move the TriBot around a square, and the blocks on the Sequence Beam at the bottom continually display the motor position.

When you run this program, the NXT will start both Loop blocks and then rapidly switch between running the code on each Sequence Beam. The computer inside the NXT can’t really do more than one thing at a time, but it can switch between the two tasks quickly enough to perform both tasks successfully. The result is that the TriBot moves around the square while the display shows how far the robot has moved.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint