Presentation is loading. Please wait.

Presentation is loading. Please wait.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7.

Similar presentations


Presentation on theme: "Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7."— Presentation transcript:

1 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7

2 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 2Winter Quarter 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

3 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 3Winter Quarter 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

4 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 4Winter Quarter Things to Know Positive polarity from the motor port will control NS light Negative polarity from the motor port will control EW light 1 st and 3 rd pin of motor port are the connection points, the middle one should have no connection

5 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 5Winter Quarter The Handy Board

6 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 6Winter Quarter Stoplight Circuit Forward Biased Reverse Biased motor (0, 100);

7 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 7Winter Quarter Stoplight Circuit Forward Biased Reverse Biased motor (0, -100);

8 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 8Winter Quarter 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 ( )

9 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 9Winter Quarter 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

10 Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 10Winter Quarter 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 ( ) ) ;


Download ppt "Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7."

Similar presentations


Ads by Google