Safety Group

Eric Bellows, Thomas Warring, Gerald Frasco

Week 7 report

Eric Bellows Section

This week we received 3 HC-SR04 arduino ultra sonic sensors and one MB7076 long range ultra sonic sensor that were used from previous semester. The 3 HC-SR04 sensors claim to have a range of 400 cm and the MB7076 has a range of 37 feet. We are still haven’t received what we ordered the second week but have moved on and started to create the model for the electric car.

The model consists of two bread boards glued together to create a “T” shape to hold the sensors and micro controller. The front HC-SR04 will resemble the sensor on the front of the car and the 2 HC-SR04 sensor in the back will be the blind spot detection which will be located on the rear of the car shown in Figure 1.

Figure 1 Model of the Car

The code written to control the front and right HC-SR04 sensors was created to display the distance detection. The distance is displayed on the serial monitor which shows both front and right sensors distance in inches shown as “24 Front in 31 Right in”. The ultra sonic sensor sends out a sound wave on the left side of the sensor and the sound wave will travel until it hits an object. When the sound wave hits the object it the travels back to the sensor and is detected on the right side of the sensor. The code created for this model is shown below in Figure 2.

#define front_trig 12 / defines the ports

#define front_echo 13

#define right_trig 7

#define right_echo 8

void setup() {

Serial.begin (9600); / Assigns the board rate at 9600 hz

pinMode(front_trig, OUTPUT);

pinMode(front_echo, INPUT);

Serial.begin (9600);

pinMode(right_trig, OUTPUT);

pinMode(right_echo, INPUT);

}

void loop() {

int f_dur, f_d, f_inches, r_dur, r_d, r_inches; / defines variables

digitalWrite(front_trig, HIGH);

digitalWrite(right_trig, HIGH);

delayMicroseconds(1000);

digitalWrite(front_trig, LOW);

digitalWrite(right_trig, LOW);

f_dur = pulseIn(front_echo, HIGH);

r_dur = pulseIn(right_echo, HIGH);

f_d = (f_dur/2) / 29.1;

r_d = (r_dur/2) / 29.1; / calculates data from sensor

f_inches= (f_d*0.393701); / inches conversion

r_inches= (r_d*0.393701);

Serial.print(f_inches); / serial monitor display

Serial.print(" front in ");

Serial.print(r_inches);

Serial.println(" right in ");

delay(250); } / .25 second delay

Figure 2 Distance HC-SR04 Sensor Code

Code Reference

http://trollmaker.com/article3/arduino-and-hc-sr04-ultrasonic-sensor

Gerald Frasco Section

This week Eric set up the Arduino with the short range sonic sensors which we got from Angelo. In lab we hooked up the long range sensor. The long range sensor has two output methods. The first method involves a variable DC voltage corresponding to the range of an object in front of the sensor. The second method utilizes frequency variation with range. We focused on the first method. After some testing, it appears that the output voltage shoots up very high while the object is moving, and rests to a steady voltage corresponding to range while the object is stationary. More testing will need to be conducted to establish a reliable empirical pattern.

Thomas Warring Section

Trial code written for the MB7076 long range sensor. The code has some errors but it’s the first try with this sensor and the arduino.

#define Vin A0

void setup() {

Serial.begin (9600);

pinMode(Vin, INPUT);

Serial.begin (9600);

}

void loop() {

int f_dur, f_d, f_inches, r_dur, r_d, r_inches;

delayMicroseconds(1000);

f_dur = pulseIn(Vin, HIGH);

r_d = f_dur/4.9;

Serial.print(r_d);

Serial.println("cm");

delay(500);

}