Continually re evaluates that condition Which kind of loop have we been using

Continually re evaluates that condition which kind of

This preview shows page 7 - 9 out of 9 pages.

Continually re-evaluates that condition Which kind of loop have we been using so far? Control: Decisions, Loops, and Variables 41 Loops in LabVIEW NXT • Recall: NXT Robotics >> NXT Programming >> Structures >> While Loop The blue i is the iteration counter – It increments by 1 each time EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame the loop is executed The green stop is the Terminal Condition Control: Decisions, Loops, and Variables 42
Image of page 7
9/5/2011 8 Loops in LabVIEW NXT How do we make a counter-controlled loop? EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame Caution: the iteration counter starts at 0, not 1 The above while loop would run 6 times Control: Decisions, Loops, and Variables 43 Conditional Controlled Loops EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame Control: Decisions, Loops, and Variables 44 We’ll talk about Conditional Controlled Loops in Learning Center this week Finite State Machines One way to program multiple decisions is with a Finite State Machine (FSM) – This is like a “playbook” of actions for your robot – Each “play” is a set of actions for your robot to execute (or a feature your pet should show!) – At the end of each “play” the robot makes another EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame At the end of each play , the robot makes another decision to determine the next play Control: Decisions, Loops, and Variables 45 Finite State Machine as a Playbook A Finite State Machine is like a football team’s playbook If yards remaining 2 Fourth down EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame 46 Finite State Machines Run Punt First down Play completes If yards remaining < 2 Example: iPhone Screen Displays to “Open” iPhone desktop displayed Front Button is pushed Start (phone is in “sleep” mode) Finger swiped across screen Front Button is pushed EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame Finite State Machines 47 phone No touch recognized for 30 seconds Selected sub- program Screen is not touched Sub-program selected Example: Finite State Machine “Line follower” as a finite state machine: “Turn Light sensor reads high value EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame This is a very basic, incomplete example… Finite State Machines 48 Turn Right” state “Turn Left” state Light sensor reads low value
Image of page 8
9/5/2011 9 Example: Finite State Machine A finite state machine requires a place to start, and a place to finish up! Light sensor reads high value Start (read Light) EG 10111/10112 Introduction to Engineering Copyright © 2011 University of Notre Dame Finite State Machines 49 Turn Right” sub-plan “Turn Left” sub-plan Light sensor reads low value Stop (Turn off all motors and sensors) (what should be the reason here?) Light sensor reads low value LEGO Pet as a Finite State Machine
Image of page 9

You've reached the end of your free preview.

Want to read all 9 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture