Presentation is loading. Please wait.

Presentation is loading. Please wait.

Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Object Detection by Ultrasonic How to install and program a ultra sonic sensor with Arduino.

Similar presentations


Presentation on theme: "Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Object Detection by Ultrasonic How to install and program a ultra sonic sensor with Arduino."— Presentation transcript:

1 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Object Detection by Ultrasonic How to install and program a ultra sonic sensor with Arduino Board

2 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Physics Ultrasound Ultrasounds are sound waves Frequencies higher of limit of human hearing. Ultrasound is not different from 'normal‘ sound Frequencies from 20 kHz up to several gigahertz Speed of ultrasound is 343,2 m/s – in dry air – at 20 °C

3 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection 1.The Sensor send out an sound wave and will be reflected at an object 2.The sound waves travel forth an back - this takes time 3.The Sensor returns the time 4.Since we know the speed of sound – we can calculate the distance Function Ultrasound Sensor HC-SR04 Distance (sound wave) HC-SR04 Speaker Microphone Sensor Object

4 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Physics Ultrasound

5 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Obstacle Detection Distance Measurement Level Indicators Industrial Applications Area of Application

6 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Programming – Use a Library The physics and programming rules are implemented in a library! You don‘t have to program them – You only have to use the Library in your code The function returns the distance in cm Function (Prototype) – double readdistance(int echoPin, int trigPin) – You’ve to define the echo (12) and trigger pins (13) of the sensor

7 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection How-to: Use a Library 1. 2. 3.

8 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Example US-Sensor We want to control a motor via the US-Sensor Depending on the distance… – The motor should move forward or backward The Ultra Sensor library contain a function: double getdistance(int Triggerport, int Echoport) Datatype Returnvalue [cm] Function name Parameter: Arduino Portnumber Connected to Triggerport Echoport

9 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Start Measurement Arduino set a digital signal to “1” Sensor will watch that signal at PIN2 After 10 μs Arduino can set signal to “0” Start measurement Sending ultra sonic sound wave After 200 μs, a 40 kHz Burst-Signal, the ultra sonic sound wave will be send out by the sensor Duration: 200 μs Sensor sets the output to high signal Waiting for echo If echo will be detected, the Output falls to L-Level (“0”) Time between high and low signal can be read out by Arduino Time which the ultrasonic needs forth and Get the measurement The Arduino can directly fetch the measurement result (duration) Programming Rules

10 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Arduino (e.g. Arduino Uno) Ultra Sonic Sensor (HC-SR04) Cabling – 1 x USB PC-Arduino – 10 x Cable 0,75 mm² (length approx. 10 cm) 1 x Computer / Laptop 1 x Breadboard 1 x DC Motor Motor driver L1910S Power Supply/Battery Needed Parts

11 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection HW Setup on Breadboard

12 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Example US-Sensor We want to control a motor Depending on the distance – The motor should move forward or backward The Ultra Sensor library contain a function: double getdistance(int Triggerport, int Echoport) Datatype return value [cm] Name of function Parameter: Arduino port number Connected to: Triggerport Echoport

13 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Programming Sample #include //Library for the motor to control the motor #include //Library for the US sensor to read a distance #define echoPin 12 // Echo Pin #define trigPin 13 // Trigger Pin #define motor1Pin1 5 // Motor Pin #define motor1Pin2 6 // Motor Pin double distance; // Variable to store the distance int speed = 100;// Variable to set the motor speed US_Sensor Sensor(trigPin,echoPin); // Object “Senor” needed to access US Sensor functions Motor Motor(motor1Pin1,motor1Pin2);// Object “Motor” needed to access Motor functions void setup() {} // Setup is done in Library void loop() { distance = Sensor.readdistance(); // Get distance [cm] from sensor if (distance < 5)// If distance is less than 5 cm { Motor.Backward(speed); // drive motor left } else// if distance is greater than 5cm { Motor.Forward(speed); // turn motor right } delay(1000); }

14 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Module Specification (HC-SR04) Distance: Detection between 2cm and 3m Resolution: approx. 3mm Voltage: 5V Current: < 2mA Triggering: Falling edge (TTL - level) Self measuring after sending a trigger (input) PWM Signal will be returned (output) Duration Measurement (Interval): 20ms – 50 Measurements/Second

15 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Sensor Accuracy The system-conditioned measuring exactness amounts to approx. 3 mm and is combined with the internal sample rate of the module. Another factor is the temperature dependence of the sonic speed in air. Approximately the sonic speed in relation of the temperature in the area of -20°C till +40°C can be calculated with formula: C air ≈(331,5 +0,6 * ϑ/°C) m/s ϑ = Surrounding temperature in °C

16 Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Best Practise The best measurement results are obtained by reflection on smooth, flat surfaces. For distances up to 1m, the material of surface is rather uncritically. Over short distances, of less than 1m, the angle to the object can reach up to 45 °. Even quite thin objects are reliably detected. A normal pen, for example, can be safely detect at a distance of about 30cm. At maximum distance (3m) the object must be exact targeted and there should be no other object in the area (similar distance) in a emission cone of 15 °.


Download ppt "Istituto Tecnico Industriale A.Monaco EURLAB Object Detection Object Detection by Ultrasonic How to install and program a ultra sonic sensor with Arduino."

Similar presentations


Ads by Google