Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Page |1

FACULTY OF CHEMICAL & PROCESS

ENGINEERING TECHNOLOGY

BTO1313 – SECTION 1

MANUFACTURING COMPUTER APPLICATION

MINI PROJECT

ULTRASONIC RADAR

Prepared by

Student
Group Members Section
ID
Mohammad Zaaim Bin Molsar TH21031 01
Nurul Hannah Binti Mohd Rizal TH21030 01
Zul Khahlib Bin MD Yasin TH20038 01
Nur Aqilah Kamaludin TH20062 01
Page |2

Contents

1) Introduction ……………………………………………………………………………………………………… 3

2) System Description …………………………………………………………………………………………. 3

3) List of Components …………………………………………………………………………………………. 4

4) Description of Components …………………………………………………………………………….. 5

5) Problem Statement …………………………………………………………………………………………. 6

6) Flowchart ………………………………………………………………………………………………………… 7

7) Schematic and Simulation Diagram ………………………………………………………………… 8

8) Appendices Coding …………………………………………………………………………………………. 9

9) Conclusion ………………………………………………………………………………………………………. 18

10) Improvement and Suggestion ……………………………………………………………………….. 18


Page |3

INTRODUCTION

Ultrasonic sensors are used in a variety of technical fields. In automation, robotics, and
instrumentation, "no-contact" distance measurement is extremely valuable. Ultrasonic
sensing is one of the most reliable ways to sense proximity and detect levels. An
ultrasonic sensor is a device that uses ultrasonic sound waves to determine the distance
to an item. An ultrasonic sensor employs a transducer to emit and receive ultrasonic
pulses that reflect information about an object’s vicinity. High-frequency sound waves
reverberate off surfaces, creating different echo patterns. Ultrasonic sensors function
by emitting a sound wave that is above the human hearing range. The ultrasonic sensor
(also known as a transducer) works in the same way that a radar system does. Electrical
energy can be converted into acoustic waves and vice versa using an ultrasonic sensor.
The acoustic wave signal is a high-frequency ultrasonic wave that travels over 18khz.

SYSTEM DESCRIPTION

The system is made up of a simple ultrasonic sensor mounted on a servo motor that rotates
at a specific angle and speed. This ultrasonic sensor is connected to Arduino digital input
output pins, as is the servo motor. This is an object-detection system that employs radio
waves to assess whether or not there is an obstruction in a 180-degree viewing angle. The
Arduino uno will serve as the messenger for the processing application in this setup. The
ultrasonic sensor will use radio waves to identify an item, and the servo motor will spin the
ultrasonic sensor to 180 degrees. When the ultrasonic sensor detects an obstruction, the
processing application will display a red region where the impediment was identified.
Page |4

LIST OF COMPONENTS

NO NAME PRICE
1 UNO ARDUINO RM 32.99
2 ULTRASONIC SENSOR (HC SR04) RM 3.30
3 MICRO SERVO RM 8.39
4 BREADBOARD RM 2.50
5 MALE TO MALE JUMPER WIRE RM 3.49
6 FEMALE TO MALE JUMPER WIRE RM 3.49
7 PUSH BUTTON RM 1.20
TOTAL RM 55.36
Page |5

DESCRIPTION OF COMPONENTS

UNO ARDUINO ULTRASONIC SENSOR (HC SR04)

- Digital I / O digital input / output of 0 to 13 - Operating Voltage: 5V DC


- Analog I / O Analog Input / output of 0 to 5 - Operating Current: 15mA
- PWM Pin - 3,5,6,9,10,11 - Operating Frequency: 40KHz
- Support ISP download function - Maximum reading distance: 400cm
- Input voltage: USB Cable / 7-12V DC Plug - Minimum reading distance: 2cm
- Output voltage: 5V DC voltage output and 3.3V - Detection Angle: 15°
DC voltage output
- Resolution: 0.5cm
- Using Atmel Atmega328P microprocessor
- Trigger pulse: >10us TTL pulse
controller
- Output pulse with proportional to distance
- Using Atmel Mega16u2 USB Chip (CP2012
Driver) - Maximum pulse width: 38ms if no obstacle
- Dimension: 45 x 20 x 15 mm
MICRO SERVO

- Control degree: 180O BREADBOARD

- Torque: 4.8V (1.2kg/cm) - Size: 5.5x8.3cm


O
- Speed: 0.12sec/60 (4.8V) - Suitable for standard Dupont Jumper Wire
- Start/ stall current: 0.4A+ - Come with Double Sided Tape on reverse
- Rated: 0.15A+ side
- Easy to build a PCB circuit without
soldering
MALE TO MALE JUMPER WIRE
-Wire length: 10cm & 20 cm
PUSH BUTTON
-6 x 6 x 5 MM
FEMALE TO MALE JUMPER WIRE
-Wire length: 10cm & 20 cm
Page |6

The speed of sound is


variable in different
mediums also depends on
temperature of the
medium, so manual
manipulations are
required on calculated
distance.

Signals get weekend as they


The object propagate through the
should be a good medium. Attenuation
depends on frequency of
reflecting the signals putting a
surface. constraint on the range of
the systems.
PROBLEM
STATEMENT

The object should be The size of the object


placed near the should be of the order
rotational axis of of wavelength of signal
transmitter. At wider for it to be detected.
angles less reflection So, object should not
takes place. be very small.
Page |7

FLOWCHART

START

i=0

F
i<=10

Radar moves 180o to left

T
Object detected? Red signal shows on radar

Radar moves 180o to right

T
Object detected? Red signal shows on radar

i = i+1

STOP
Page |8

SCHEMATIC AND SIMULATION DIAGRAM

Schematic and Simulation for Thinker CAD Diagram and Arduino Ide
Page |9

Coding for Thinker cad And Arduino Ide -Appendices

// Includes the Servo library

#include <Servo.h>.

// Defines Trig and Echo pins of the Ultrasonic Sensor

const int trigPin = 10;

const int echoPin = 11;

// Variables for the duration and the distance

long duration;

int distance;

Servo myServo; // Creates a servo object for controlling the servo motor

int pos=0; //variable to store the servo position

void setup() {

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Serial.begin(9600);

myServo.attach(12); // Defines on which pin is the servo motor attached

void loop() {

// rotates the servo motor from 0 to 180 degrees

for (pos = 0; pos<= 180; pos +=1) {//goes from 0 degrees to 180 degrees

//in steps of 1 degree

myServo.write(pos);//tell servo to go to position in variable 'pos'

delay(1);//tell servo to go to position in variable 'pos'


P a g e | 10

distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for
each degree

Serial.print(pos); // Sends the current degree into the Serial Port

Serial.print(","); // Sends addition character right next to the previous value needed later in the Processing IDE for
indexing

Serial.print(distance); // Sends the distance value into the Serial Port

Serial.print("."); // Sends addition character right next to the previous value needed later in the Processing IDE for
indexing

// Repeats the previous lines from 180 to 0 degrees

for(pos = 180; pos>= 0; pos-=1 ){//goes from 180 degrees to 0 degrees

myServo.write(pos);//tell servo to go to position in variable 'pos'

delay(1);//tell servo to go to position in variable 'pos'

distance = calculateDistance();

Serial.print(pos);

Serial.print(",");

Serial.print(distance);

Serial.print(".");

// Function for calculating the distance measured by the Ultrasonic sensor

int calculateDistance(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);
P a g e | 11

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds

distance= duration*0.034/2;

return distance;

}
P a g e | 12

Schematic and Simulation for Visual Studio


P a g e | 13

Guide User Interface(GUI) Codding


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RADAR_lll
{
public partial class Form1 : Form
{
Timer t = new Timer();

int WIDTH = 300, HEIGHT = 300, HAND = 300;


int u;
int cx, cy;
int x, y;
int tx, ty, lim = 20;
int o_x, o_y, t_ox, t_oy;

private void btnDetect_Click(object sender, EventArgs e)


{
serialPort1.Open();
bmp = new Bitmap(WIDTH + 1, HEIGHT + 1);
this.BackColor = Color.Black;
cx = WIDTH / 2;
cy = HEIGHT / 2;
u = 0;
t.Interval = 5;
t.Start();
}

private void serialPort1_DataReceived(object sender,


System.IO.Ports.SerialDataReceivedEventArgs e)
{
string read_s = serialPort1.ReadLine();
string[] data = read_s.Split(' ');

int.TryParse(data[0], out iAngle);


int.TryParse(data[1], out iDistance);
btnlabel.Text = "Angle = " + iAngle + " Distance = " + iDistance;
}

private void btnStop_Click(object sender, EventArgs e)


{
serialPort1.Close();
P a g e | 14

public int iDistance;


public int iAngle;
int dongu;

Bitmap bmp;
Pen p, p1;
Graphics g;

private void Form1_Load(object sender, EventArgs e)


{

serialPort1.Open();
bmp = new Bitmap(WIDTH + 1, HEIGHT + 1);
this.BackColor = Color.Black;
cx = WIDTH / 2;
cy = HEIGHT / 2;
u = 0;
t.Interval = 5;
t.Start();
}

public Form1()
{
InitializeComponent();
serialPort1.BaudRate = 9600;
serialPort1.Parity = System.IO.Ports.Parity.None;
serialPort1.DataBits = 8;
serialPort1.StopBits = System.IO.Ports.StopBits.One;

private void pictureBox1_Click(object sender, EventArgs e)


{
//pen
p = new Pen(Color.Green, 1f);
p1 = new Pen(Color.Red, 1f);
//Graphics
g = Graphics.FromImage(bmp);
int tu = (u - lim) % 360;

if (u >= 0 && u <= 180)


{
//u in degree is converted into radian.

x = cx + (int)(HAND * Math.Sin(Math.PI * u / 180));


y = cy - (int)(HAND * Math.Cos(Math.PI * u / 180));
o_x = cx + (int)((iDistance) * Math.Sin(Math.PI * u / 180));
o_y = cy - (int)((iDistance) * Math.Cos(Math.PI * u / 180));
}
else
{
x = cx - (int)(HAND * -Math.Sin(Math.PI * u / 180));
y = cy - (int)(HAND * Math.Cos(Math.PI * u / 180));
o_x = cx - (int)((iDistance) * -Math.Sin(Math.PI * u / 180));
P a g e | 15

o_y = cy - (int)((iDistance) * Math.Cos(Math.PI * u / 180));


}

if (tu >= 0 && tu <= 180)


{
//tu in degree is converted into radian.

tx = cx + (int)(HAND * Math.Sin(Math.PI * tu / 180));


ty = cy - (int)(HAND * Math.Cos(Math.PI * tu / 180));
t_ox = cx + (int)((iDistance) * Math.Sin(Math.PI * tu / 180));
t_oy = cy - (int)((iDistance) * Math.Cos(Math.PI * tu / 180));
}
else
{
tx = cx - (int)(HAND * -Math.Sin(Math.PI * tu / 180));
ty = cy - (int)(HAND * Math.Cos(Math.PI * tu / 180));
t_ox = cx - (int)((iDistance) * -Math.Sin(Math.PI * tu / 180));
t_oy = cy - (int)((iDistance) * Math.Cos(Math.PI * tu / 180));
}
//draw circle
g.DrawEllipse(p, 0, 0, WIDTH, HEIGHT); //Bigger circle
g.DrawEllipse(p, 80, 80, WIDTH - 160, HEIGHT - 160); //Smaller Circle

//draw perpendicular line


g.DrawLine(p, new Point(cx, 0), new Point(cx, HEIGHT)); //UP-DOWN
g.DrawLine(p, new Point(0, cy), new Point(WIDTH, cy)); //LEFT-RIGHT

if (dongu < 180)


{
//draw HAND
g.DrawLine(new Pen(Color.Black, 1f), new Point(cx, cy), new Point(tx,
ty));
g.DrawLine(p, new Point(cx, cy), new Point(x, y));

g.DrawLine(new Pen(Color.Black, 1f), new Point(t_ox, t_oy), new Point(tx,


ty));
g.DrawLine(p1, new Point(o_x, o_y), new Point(x, y));
}
else
{
//draw HAND
g.DrawLine(p, new Point(cx, cy), new Point(tx, ty));
g.DrawLine(new Pen(Color.Black, 1f), new Point(cx, cy), new Point(x, y));

g.DrawLine(p1, new Point(t_ox, t_oy), new Point(tx, ty));


g.DrawLine(new Pen(Color.Black, 1f), new Point(o_x, o_y), new Point(x,
y));
}

//load bitmap in pictureBox1


pictureBox1.Image = bmp;
//Dispose
p.Dispose();
p1.Dispose();
g.Dispose();
P a g e | 16

//update
dongu++;

u++;
if (u == 360)
{
u = 0;
}
}
}
}
P a g e | 17

Schematic and Simulation Diagram in Proteus


P a g e | 18

CONCLUSION

This tool can be custom made to fit various applications such as being fitted in cars to aid
when reversing, could tell the level of water in a well or storage tanks etc. The
technique can also be implemented with the GSM for proper remote monitoring.
The technique can also be recommended to be used in the tunnels such as train or
vehicle tunnels to give signal in case there are complications.

iThe objective of this project was to design and implement an Ultrasonic Distance
Measurement device. As described in this report a system is developed that can calculate
the distance of the tracked object. With respect to the requirements for an ultrasonic
rangefinder the followings can be concluded.

1.The system can calculate the distance of the obstruction with sufficient accuracy.
2.The device has the capability to interact with other peripheral if used as a secondary
device.
3.This can also communicate with PC through its serial port.
4.This offers a low cost and efficient solution for non-contact type distance measurements.

IMPROVEMENTS AND SUGGESTION

The range can be considerately increased by using high power drive circuit.
- Using temperature compensation, it can be used over wide temperature range.
- Increase the number of moving objects that can be detected
- Expanding the range of tracking moving object

You might also like