Difference between revisions of "2019WinterTeam4"

From MAE/ECE 148 - Introduction to Autonomous Vehicles
Jump to: navigation, search
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
The goal of our project is to create a '''smart traffic light'''. We created structures for ultrasonic sensors to detect the car's presence and manage traffic. Utilizing the idea of smart infrastructure, smart cars are able to become more effective and optimizing traffic. We are able to turn off street lighting when it is unused and give priority to emergency vehicles. This simple model minimizes cost and complexity. This project surrounds the problem of directing traffic when 2 way streets merge into 1 on a mountain road.
+
The goal of our project is to create a '''smart traffic light'''. We created structures for ultrasonic sensors to detect the car's presence and manage traffic. Utilizing the idea of smart infrastructure, smart cars are able to become more effective and optimizing traffic. We are able to turn off street lighting when it is unused and give priority to emergency vehicles. This simple model minimizes cost and complexity. This project surrounds the problem of directing traffic when 2-way streets merge into 1 on a mountain road.
  
Our GitHub repository can be found here: [https://github.com/Jupiderp/ECEMAE148Team4Winter2019.git]
+
[[File:Team4car.jpg | 400px]]
 
 
[[File:Team4car.jpg | 500px]]
 
  
 
== Team Members ==
 
== Team Members ==
Line 12: Line 10:
  
 
Kaj Kuchina
 
Kaj Kuchina
 
  
 
== Mountain Road Model ==
 
== Mountain Road Model ==
Line 21: Line 18:
  
 
[[File:Arduino_US_LED_bb.jpg | 400px]]
 
[[File:Arduino_US_LED_bb.jpg | 400px]]
 
 
[[File:Arduino_US_LED_schem.jpg | 400px]]
 
[[File:Arduino_US_LED_schem.jpg | 400px]]
  
 +
== STL Models ==
  
== STL Models ==
+
Ultrasonic Sensor Mount
 +
[[File:UltrasonicSensorWMount.jpg | 150px]]
  
 +
Traffic Light
 +
[[File:TrafficLight.jpg | 300px]]
  
 +
== Decreasing Ultrasonic Variability ==
 +
The ultrasonic sensors will observe a sharp decrease in the distance as a car drives in front of the sensor. When the sensor is first configured, it establishes a baseline for an empty road. However, in the real world, the object it sees might not be flat or stationary, which could cause false detections. To ensure we had a consistent baseline for the ultrasonic sensors, we designed flat acrylic plates.
 
== Arduino Code ==
 
== Arduino Code ==
 
+
Library that can read from multiple ultrasonic sensors at the same time and frequency.
 
  #include <NewPing.h>
 
  #include <NewPing.h>
  
 +
Define variables with set values
 
  #define SONAR_NUM 2      // Number of sensors.
 
  #define SONAR_NUM 2      // Number of sensors.
 
  #define MAX_DISTANCE 100 // Maximum distance (in cm) to ping.
 
  #define MAX_DISTANCE 100 // Maximum distance (in cm) to ping.
 
  #define THRESH 40
 
  #define THRESH 40
 +
 +
Define green and red led pins on Arduino for traffic light.
 
  #define led_g 7
 
  #define led_g 7
 
  #define led_r 8
 
  #define led_r 8
  
 +
Create a NewPing for each ultrasonic echo and trigger pairing.
 
  NewPing sonar[SONAR_NUM] = {  // Sensor object array.
 
  NewPing sonar[SONAR_NUM] = {  // Sensor object array.
 
   NewPing(10, 9, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping.
 
   NewPing(10, 9, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping.
Line 56: Line 62:
 
   delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
 
   delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
 
   Serial.println(sonar[1].ping_cm());
 
   Serial.println(sonar[1].ping_cm());
 +
First ultrasonic sensor detects an object then turn green for that side and red for the other side.
 
   if (sonar[0].ping_cm() < THRESH) {
 
   if (sonar[0].ping_cm() < THRESH) {
 
     digitalWrite(led_g, HIGH);
 
     digitalWrite(led_g, HIGH);
Line 61: Line 68:
 
     delay(1000);
 
     delay(1000);
 
   }
 
   }
 +
Second ultrasonic sensor detects an object then turn green for that side and red for the other side.
 
   else if (sonar[1].ping_cm() < THRESH) {
 
   else if (sonar[1].ping_cm() < THRESH) {
 
     digitalWrite(led_g, LOW);
 
     digitalWrite(led_g, LOW);
 
     digitalWrite(led_r, HIGH);
 
     digitalWrite(led_r, HIGH);
 +
    delay(1000);
 
   }
 
   }
 +
No objects detected then turn red for both sides.
 
   else {
 
   else {
 
     digitalWrite(led_g, LOW);
 
     digitalWrite(led_g, LOW);
Line 70: Line 80:
 
   }
 
   }
 
  }
 
  }
 +
 +
== Demo ==
 +
[[File:Demo2.mp4 | 600px]]
  
 
== Resources ==
 
== Resources ==

Latest revision as of 12:04, 24 March 2019

Introduction

The goal of our project is to create a smart traffic light. We created structures for ultrasonic sensors to detect the car's presence and manage traffic. Utilizing the idea of smart infrastructure, smart cars are able to become more effective and optimizing traffic. We are able to turn off street lighting when it is unused and give priority to emergency vehicles. This simple model minimizes cost and complexity. This project surrounds the problem of directing traffic when 2-way streets merge into 1 on a mountain road.

Team4car.jpg

Team Members

Justine Lee

Mihir Sathe

Kaj Kuchina

Mountain Road Model

MountainModel.png

Circuit Schematics

Arduino US LED bb.jpg Arduino US LED schem.jpg

STL Models

Ultrasonic Sensor Mount UltrasonicSensorWMount.jpg

Traffic Light TrafficLight.jpg

Decreasing Ultrasonic Variability

The ultrasonic sensors will observe a sharp decrease in the distance as a car drives in front of the sensor. When the sensor is first configured, it establishes a baseline for an empty road. However, in the real world, the object it sees might not be flat or stationary, which could cause false detections. To ensure we had a consistent baseline for the ultrasonic sensors, we designed flat acrylic plates.

Arduino Code

Library that can read from multiple ultrasonic sensors at the same time and frequency.

#include <NewPing.h>

Define variables with set values

#define SONAR_NUM 2      // Number of sensors.
#define MAX_DISTANCE 100 // Maximum distance (in cm) to ping.
#define THRESH 40

Define green and red led pins on Arduino for traffic light.

#define led_g 7
#define led_r 8

Create a NewPing for each ultrasonic echo and trigger pairing.

NewPing sonar[SONAR_NUM] = {   // Sensor object array.
  NewPing(10, 9, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping.
  NewPing(6, 5, MAX_DISTANCE),
};
void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
  pinMode(led_r, OUTPUT);
  pinMode(led_g, OUTPUT);
  digitalWrite(led_g, LOW);
  digitalWrite(led_r, HIGH);
}
void loop() {
  Serial.print(sonar[0].ping_cm());
  Serial.print(",");
  delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.println(sonar[1].ping_cm());

First ultrasonic sensor detects an object then turn green for that side and red for the other side.

  if (sonar[0].ping_cm() < THRESH) {
    digitalWrite(led_g, HIGH);
    digitalWrite(led_r, LOW);
    delay(1000);
  }

Second ultrasonic sensor detects an object then turn green for that side and red for the other side.

  else if (sonar[1].ping_cm() < THRESH) {
    digitalWrite(led_g, LOW);
    digitalWrite(led_r, HIGH);
    delay(1000);
  }

No objects detected then turn red for both sides.

  else {
    digitalWrite(led_g, LOW);
    digitalWrite(led_r, LOW);
  }
}

Demo

Resources

Traffic Light STL:

https://www.thingiverse.com/thing:2826057 

NewPing Arduino Library :

https://playground.arduino.cc/Code/NewPing