Lab 5b: Traffic Stoplight. BYU CS 124RBX4302 Program a pedestrian traffic light for a street with a crosswalk. Use the large red, yellow, and green LEDs.

Slides:



Advertisements
Similar presentations
FSM Word Problems Today:
Advertisements

Chung-Ta King National Tsing Hua University
Lab7: Introduction to Arduino
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
Photos and Sensor Instructions
Understanding the Purpose of Pavement Markings
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
Chapter 221 Chapter 22: Fundamentals of Signal Timing: Actuated Signals Explain terms related to actuated signals Explain why and where actuated signals.
VHDL revision 15a1 VHDL revision. VHDL revision 15a2 Q1 A clocked 4-to-2-bit encoder circuit (with synchronous reset) has the following interfaces: RESET:
LAB 3 – Review of the Assignment. -- Clarifications Vikram Murali. TA : CSE 140L Prof. CK Cheng.
EE 316 Computer Engineering Junior Lab Project 1: Traffic Light Controller.
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design 8.5 Finite State Machine.
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Blinky Lab 3: Blinky Lab Modify the blinky.asm assembly program to blink the LaunchPad red LED quickly on and off at exactly 10 second intervals. Calculate.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7.
2015 Traffic Signals 101 Topic 7 Field Operations.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Lab 7b: Morse Code II
Lesson 2.2 Traffic Signals  Today’s Objectives: 1. Explain what to do at a green, yellow, and red light. 2. Describe the action to take when you approach.
Eric goes to the store. Eric and Mary Jane are leaving the school.
LAB 7: WDT+ and Low-Power Optimization
ELEC 1041 Digital Electronics Tutorial: Word Problems
Stop Sign This is a traffic sign. This means to stop. It helps us be safe when driving.
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
Chapter 8 – Stacks
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
The Green Cross Code is a set of steps to help you cross the road. Remembering the Green Cross Code when you cross the road will help you get to the other.
Chapter 20: Actuated Signal Control and Detection
LAB 8: Program Design Pattern and Software Architecture
Implementing software in IEC Languages in IEC IEC uses the following languages Instruction List – Assembly level programming using.
Microprocessors 1 MCS-51 Interrupts.
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
Lab 4: MSP430 Microarchitecture
Conclusion Speech. Content Organization Pronunciation Handwriting.
ECE Lecture 1 1 L15 –I/O Part II Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Lecture 4 General-Purpose Input/Output NCHUEE 720A Lab Prof. Jichiang Tsai.
Traditionally ladder logic programs have been written by thinking about the process and then beginning to write the program. This always leads to programs.
Traffic Lights Green Light- GO – You can proceed only if the intersection is clear. When approaching a green light, check traffic to the left, right, and.
A stop sign is a traffic sign that stands for coming to a complete stop at an intersection or end of the road.
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
BYU CS/ECEn 124Lab 2 - FSM Lab1 Lab 2 – Finite State Machine Using the Digital State Machine Simulator, create five different machine configuration files.
Chapter 2 Signs, Signals, and Roadway Markings Start working on the Start working on the 8 questions on page 39! 8 questions on page 39!
PLC programming Part 3: Problems with solutions. Topics  Every problem is devided into three parts:  Technology description contains the general properties.
Introduction In this lab , we will learn
STREET SIGNS & TRAFFIC SYMBOLS WHAT THEY MEAN & WHAT TO DO
EECE6017C Lab 1 Introduction to Altera tools and Circuit Simulation
Lesson Outline Interrupts Admin Assignment #9 due next lesson
The Simulation of Traffic Patterns and Optimizing Traffic Lights
Drive Right Chapter 2 Unit 1
S04: MSP430 Microarchitecture
Revision Name __________ Student number______
Quiz 4.1 Four LEDs are attached to Port 4, bits 0 thru 3. Indicate which LEDs are ON/OFF after each instruction is executed. P4.7 P4.6 P4.5 P4.4 P4.3.
ELEC 1041 Digital Electronics Tutorial: Word Problems
* Topic 7 Field Operations
CS4101 Introduction to Embedded Systems Lab 4: Interrupt
Advisor: Prof. Gandhi Puvvada
Industrial Electronics
Advisor: Prof. Gandhi Puvvada
Traffic light programming challenges
Raspberry Pi with Pibrella
Red lights, yellow lights, and green lights
Presentation transcript:

Lab 5b: Traffic Stoplight

BYU CS 124RBX4302 Program a pedestrian traffic light for a street with a crosswalk. Use the large red, yellow, and green LEDs for the car traffic and the smaller red and green LEDs along with the orange LED for pedestrians. Four traffic light states (Green, Yellow, Red, and Pedestrian) are used to allow pedestrians to safely cross a busy street as well as calm the traffic.

BYU CS 124RBX4303 RBX430-1 Hookups Car Stop LED Car Caution LED Pedestrian Waiting LED Car Go LED Pedestrian Stop LED Pedestrian Walk LED

GreenYellowRed Green (10 seconds minimum) YellowPedestrian Traffic Light Patterns BYU CS 124RBX4304 Turn on green car and pedestrian red LED for 20 seconds. Turn on yellow car LED for 5 seconds. No pedestrian signal. Turn on red car LED for 5 seconds. Turn on yellow car LED for 5 seconds. Move to pedestrian sequence. Turn on red car LED and turn off pedestrian red and orange LEDs. Turn on pedestrian green LED for 5 seconds, toggle every second for 6 seconds, and then rapidly toggle every 1/5 second for 4 seconds. Normal traffic light cycle time should be 30 seconds (  1/2 second). Pedestrian traffic light cycle time should be seconds (depending on when button is pressed). Turn on green car and pedestrian red LED for 20 seconds. BONUS: If pedestrian LED after 10 seconds, move to yellow. Car Ped Car Ped Red pedestrian LED on during Normal cycle.

Traffic States/LEDs BYU CS 124RBX4305 Car LEDs (Large) Pedestrian LEDs (Small) StateTime GreenOrangeYellowRedGreenRed 1 = GREEN20s OnOn/OffOff On 2 = YELLOW5s OffOn/OffOnOff On 3 = RED5s OffOn/OffOffOnOffOn 4a = PEDESTRIAN5s OffOn/OffOffOnONOff 4b = PEDESTRIAN6 × 1s OffOn/OffOffOnBlinkOff 4c = PEDESTRIAN20 × 1/5s OffOn/OffOffOnBlinkOff Normal Cycle (1-3) = 30 seconds Pedestrian Cycle (1, 2, 4) = 40 seconds

Button Inputs Polling Interrupts BYU CS 124RBX4306 bic.b #0x0f,&P1DIR ; set P1.0-3 as input bis.b #0x0f,&P1OUT ; select pull-up bis.b #0x0f,&P1REN ; enable pull-ups on P1.0-3 mov.b &P1IN,r13 ; sample buttons (0 => pressed) and.b #0x0f,r13 ; mask least significant nybble xor.b #0x0f,r13 ; button pressed? jeq off ; n bis.b #0x01,&P4OUT ; y, turn on green LED off: bic.b #0x0f,&P1SEL ; select GPIO bic.b #0x0f,&P1DIR ; configure P1.0-3 as Inputs bis.b #0x0f,&P1OUT ; use pull-ups bis.b #0x0f,&P1REN ; enable pull-ups bis.b #0x0f,&P1IES ; trigger on high to low transition bis.b #0x0f,&P1IE ; P1.0-3 interrupt enabled bic.b #0x0f,&P1IFG ; P1.0-3 IFG cleared ; Port 1 ISR P1_ISR: bic.b #0x0f,&P1IFG ; clear P1.0-3 Interrupt Flag bis.b #0x01,&P4OUT ; turn on green LED reti.sect ".int02" ; P1 interrupt vector.word P1_ISR

Traffic Light Algorithm 1.Turn the large green car LED and small red pedestrian LED on for 20 seconds. 2.Turn off the large green car LED and turn on the yellow car LED for 5 seconds. If the orange LED is off, move to the red state by turning the yellow car LED off and the red car LED on for 5 seconds. 3.Else, turn the orange and small red pedestrian LEDs off and small green pedestrian LED and red car LED on. After 5 seconds, toggle small green LED on and off for 6 seconds at 1 second intervals. Finish by toggling small green LED on and off for 4 seconds at 1/5 second intervals. 4.Repeat the traffic stoplight cycle. BONUS VARIATION: Immediately move from green state to yellow state if the orange LED is on and at least 10 seconds has expired. BYU CS 124RBX4307

BYU CS 124Blinky Lab8 1 pointYour traffic stoplight program source code contains header comments that include your name and a declaration that the completed assignment is your own work. 1 pointThe assembler directive.equ is used to define all delay counts and constants. 2 pointsAll software timing delays are implemented using an assembly subroutine that delays in 1/10 second increments. All subroutines are implemented using a callee-save protocol. 4 pointsYour traffic stoplight machine correctly implements the traffic algorithm. 1 pointPressing any button at any time turns on the orange LED. The pedestrian sequence only occurs at the end of the yellow state and the orange LED is on (within 1/10 second.) 1 pointThe total traffic light cycle time (without a button press) is 30 seconds with less than a 1/2 second error. Traffic Lab Requirements

BYU CS 124Blinky Lab9 +1 point Passed off with a TA at least one day early. (No timestamps please!) +1 pointIf the orange pedestrian LED is on and at least 10 seconds has expired in the Green State, immediately move to Yellow State. +1 pointThe number of 1/10 second delays is passed to the timing subroutine on the stack. +1 pointInterrupts are used to respond to a button being pressed rather than polling. The orange LED holds the state of the pedestrian request to cross the street. -1 pointFor each school day late. (Timestamps may be used to verify completion time.) Traffic Lab Bonus

Steps to Success! 1.Program the Green/Red states using a 1/10 second, callee-save delay subroutine. Test. 2.Add the Yellow state to complete a normal cycle. Test. 3.Modify your delay subroutine to continuously sample the switches. Turn on the orange LED when any switch is pressed. (Note: you will need to adjust your delay subroutine constants to compensate for the new instructions.) Test. 4.At the end of the Yellow state, jump to a Pedestrian state if the orange LED is on. Program a simple Pedestrian state with the small green LED and large red LED on for 5 seconds. Test. 5.Finally, finish the Pedestrian state with the small green LED toggling on and off at 1 second intervals for 6 seconds, following by the small green LED rapidly toggling on and off for 4 seconds at 1/5 second intervals. 6.Work on bonus material AFTER completing the lab requirements! BYU CS 124RBX43010

BYU CS 124RBX43011

Traffic Light Algorithm 1.Turn the large green car LED and small red pedestrian LED on for 20 seconds. 2.Turn off the large green car LED and turn on the yellow car LED for 5 seconds. If the orange LED is off, move to the red state by turning the yellow car LED off and the red car LED on for 5 seconds. 3.Else, turn the orange and small red pedestrian LEDs off and small green pedestrian LED and red car LED on. After 5 seconds, toggle small green LED on and off for 6 seconds at 1 second intervals. Finish by toggling small green LED on and off for 4 seconds at 1/5 second intervals. 4.Repeat the traffic stoplight cycle. BONUS VARIATION: Number of 1/10 delays is passed to the delay subroutine on the stack. Interrupts replace polling to respond to a switch (orange LED). Immediately move from green state to yellow state if orange LED is on and at least 10 seconds has expired. BYU CS 124RBX43012

Traffic Light States BYU CS 124RBX43013 Pedestrian Ped Walk Red Cars Stop Green Cars Go Yellow Cars Go 15 Seconds 5 Seconds and Orange LED on 10+ Seconds and Orange LED on (Bonus) 20 Seconds 5 Seconds 5 Seconds and Orange LED off

Traffic Light States BYU CS 124RBX Seconds 10 Seconds 15 Seconds Orange Red Cars Stop 10 Green Cars Go 00 Orange Ped Walk 11 Yellow Cars Go Seconds 5 Seconds and Orange 10+ Seconds And Orange 20 Seconds 5 Seconds and NO Orange

GreenYellowRed Traffic Light Patterns BYU CS 124RBX43015 Normal traffic light cycle time should be 30 seconds (  1/2 second). Turn on green car and pedestrian red LED for 20 seconds. Turn on yellow car LED for 5 seconds. No pedestrian signal. Turn on red car LED for 5 seconds. Green (10 seconds minimum)YellowPedestrian Pedestrian traffic light cycle time should be seconds (depending on when button is pressed). Turn on green car and pedestrian red LED for 10 seconds minimum. If pedestrian signal after 10 seconds, move to yellow. Turn on yellow car LED for 5 seconds. Move to pedestrian sequence. Turn on red car LED and turn off orange LED. Turn on small green LED for 5 seconds, toggle every second for 6 seconds, and rapidly toggle every 1/5 second for 4 seconds. Car Ped Car Ped

GreenYellowRed Traffic Light Patterns BYU CS 124RBX43016 Normal traffic light cycle time should be 30 seconds (  1/2 second). Turn on green car and pedestrian red LED for 20 seconds. Turn on yellow car LED for 5 seconds. No pedestrian signal. Turn on red car LED for 5 seconds. Green (10 seconds minimum)YellowPedestrian Pedestrian traffic light cycle time should be seconds (depending on when button is pressed). Turn on green car and pedestrian red LED for 10 seconds minimum. If pedestrian signal after 10 seconds, move to yellow. Turn on yellow car LED for 5 seconds. Move to pedestrian sequence. Turn on red car LED and turn off orange LED. Turn on small green LED for 5 seconds, toggle every second for 6 seconds, and rapidly toggle every 1/5 second for 4 seconds.

Green (10 seconds minimum)YellowRed / Pedestrian Green Pedestrian Cycle BYU CS 124RBX43017 Pedestrian traffic light cycle time should be seconds (depending on when button is pressed). Turn on green car and pedestrian red LED for 10 seconds minimum. If pedestrian signal after 10 seconds, move to yellow. Turn on yellow car LED for 5 seconds. Move to pedestrian sequence. Turn on red car LED and turn off orange LED. Turn on small green LED for 5 seconds, toggle every second for 6 seconds, and rapidly toggle every 1/5 second for 4 seconds.

GreenYellowRed Traffic Light Patterns BYU CS 124RBX43018 Turn on green car and pedestrian red LED for 20 seconds. Turn on yellow car LED for 5 seconds. No pedestrian signal. Turn on red car LED for 5 seconds. Normal traffic light cycle time should be 30 seconds (  1/2 second). Green (10 seconds minimum) YellowPedestrian Turn on yellow car LED for 5 seconds. Move to pedestrian sequence. Turn on red car LED and turn off pedestrian red and orange LEDs. Turn on pedestrian green LED for 5 seconds, toggle every second for 6 seconds, and then rapidly toggle every 1/5 second for 4 seconds. Pedestrian traffic light cycle time should be seconds (depending on when button is pressed). Turn on green car and pedestrian red LED for 10 seconds minimum. If pedestrian (orange LED) after 10 seconds, move to yellow. Car Ped Car Ped Red pedestrian LED on during Normal cycle.

GreenYellowRed Green (10 seconds minimum) YellowPedestrian Traffic Light Patterns BYU CS 124RBX43019 Turn on green car and pedestrian red LED for 20 seconds. Turn on yellow car LED for 5 seconds. No pedestrian signal. Turn on red car LED for 5 seconds. Turn on yellow car LED for 5 seconds. Move to pedestrian sequence. Turn on red car LED and turn off pedestrian red and orange LEDs. Turn on pedestrian green LED for 5 seconds, toggle every second for 6 seconds, and then rapidly toggle every 1/5 second for 4 seconds. Normal traffic light cycle time should be 30 seconds (  1/2 second). Pedestrian traffic light cycle time should be seconds (depending on when button is pressed). Turn on green car and pedestrian red LED for 10 seconds minimum. If pedestrian signal after 10 seconds, move to yellow. Car Ped Car Ped Red pedestrian LED on during Normal cycle.