Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stop Light Lab 7 Winter Quarter.

Similar presentations


Presentation on theme: "Stop Light Lab 7 Winter Quarter."— Presentation transcript:

1 Stop Light Lab 7 Winter Quarter

2 What We Will Learn Real-time programming techniques
Re-introduction to Interactive C and the Handy Board Simple motor port functions for traffic light control Instructor: In this lab, we will introduce some real-time programming techniques, along with some re-introduction to Interactive C and the Handyboard. We will use simple motor port functions to achieve open loop control of traffic lights at an intersection. Winter Quarter

3 Problem Statement Make the Handy Board control the stoplight at a intersection of two roads, one running North and South (NS), the other East and West (EW). The stoplight should be operated by Motor Ports 1-3 and should follow normal operation…meaning exactly one light (either EW or NS) should be red at any time. Follow this standard pattern: Red – 6 seconds Green – 4 seconds Yellow – 2 seconds Winter Quarter

4 Things to Know Positive polarity from the motor port will control NS light Negative polarity from the motor port will control EW light 1st and 3rd pin of motor port are the connection points, the middle one should have no connection Winter Quarter

5 The Handy Board Instructor:
This is a photo of the HandyBoard controller. The motor ports are in the bottom left corner, and are labelled 0 through 3. The LED’s next to them light up depending on whether the port is on and the direction the motor is supposed to go. Winter Quarter

6 + - Stoplight Circuit Forward Biased Reverse Biased motor (0, 100);
Instructor: The stop light circuit consists of two LED’s in parallel with each other but opposite directions and a current limiting resistor in series with the two LED’s. When the HandyBoard executes the command shown, the one LED will be forward biased and turn on, while the other LED will be reverse biased and turn off. Winter Quarter

7 - + Stoplight Circuit motor (0, -100); Reverse Biased Forward Biased
Instructor: When the same command is executed but in the negative direction, the current will flow in the other direction, reversing which LED is on and which is off. Winter Quarter

8 Some Tips on How To Modify Your Code
Modify functions to use Handy Board "motor" function in addition to or in place of "printf" Remember that if you use "printf", the display screen is only 32 characters long Remove any #include statements Move function bodies from below main ( ) to above main ( ) Instructor: You should have code already written that can perform this type of control. You should modify your functions to use the HandyBoard motor functions in addition to or in place of the printf commands. If you choose to leave the printf commands in, remember that the display screen is only 32 characters long. Since the Interactive C does not use #include statements, remember to remove them from the code. Interactive C also does not use function prototypes, so move the function bodies from below the main function to above the main function. Winter Quarter

9 Some More Tips on How To Modify Your Code
Replace any "do…while" loops with "while" loops Replace use of UNIX "time" function with use of Handy Board "seconds" function for computing elapsed time Remember that Handy Board "sleep" function requires a floating point parameter Instructor: Replace any do.. While loops with while loops since Interactive C does not recognize the do.. While command. Also, replace the UNIX time function with the HandyBoard seconds function for computer elapsed time. Remember that the HandyBoard sleep function requires a floating point parameter unlike the UNIX version. Winter Quarter

10 Examples of Useful IC Functions
Pause for two seconds sleep (2.0) ; Turn motor port 1 on full power motor (1, 100) ; Turn motor port 1 off motor (1, 0) ; Wait for the "start" button while (!start_button ( ) ) ; Instructor: Here are some useful Interactive C commands. Winter Quarter


Download ppt "Stop Light Lab 7 Winter Quarter."

Similar presentations


Ads by Google