Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
31 views7 pages

Lab 4

Uploaded by

Malik Yousaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views7 pages

Lab 4

Uploaded by

Malik Yousaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Robotics Lab LAB 4

Performance parameters of ultra sonic sensor and 4WD Robot Kinematics.

Objectives:

- To get familiar with Arduino I/O commands


- To get familiar with Ultra-sonic sensor
- To analyze the kinematics of 4WD Robot
- To produce PWM signals to control motor driver
- To get familiarized with Arduino libraries
-

Introduction
A few sensor characteristics can be rated quantitatively in a laboratory
setting. Such performance ratings will necessarily be best-case scenarios
when the sensor is placed on a real-world robot but are nevertheless
useful.
Sensitivity itself is a desirable trait. This is a measure of the degree to
which an incremental change in the target input signal changes the output
signal. Formally, sensitivity is the ratio of output change to input change.
Cross-sensitivity is the technical term for sensitivity to environmental
parameters that are orthogonal to the target parameters for the sensor.
For example, a flux-gate compass can demonstrate high sensitivity to
magnetic north and is therefore of use for mobile robot navigation.
However, the compass will also demonstrate high sensitivity to ferrous
building materials, so much so that its cross-sensitivity often makes the
sensor useless in some indoor environments. Accuracy is defined as the
degree of conformity between the sensor’s measurement and the true
value and is often expressed as a proportion of the true value (e.g., 97.5%
accuracy).

Motor speed and direction control is a fundamental aspect of robotics and


automation, playing a pivotal role in determining the movement, precision,
and functionality of robotic systems. Whether it's in industrial automation,
mobile robots, or even hobbyist projects, the ability to precisely manage
the speed and direction of motors is the cornerstone of achieving tasks
efficiently and with precision. By modulating the rotational speed and
steering of motors, we unlock a world of possibilities, from the precise
positioning of robotic arms to the navigation of autonomous vehicles. In
this realm of control, we delve into the technologies and methodologies
that empower us to manipulate motors with finesse, turning them into the
obedient workhorses of our mechanized world.

H Bridge:
Circuit containing 4 switching elements + 4 catch diodes
Switching elements are usually bipolar transistors or MOSFETs
Catch diodes are used to prevent short circuiting
Path of current controlled by switches
Robotics Lab LAB 4

L298N Dual H-Bridge Motor Driver


This dual bidirectional motor driver, is based on the very popular L298 Dual H-Bridge Motor Driver
Integrated Circuit. The circuit will allow you to easily and independently control two motors of up
to 2A each in both directions.It is ideal for robotic applications and well suited for connection to a
microcontroller requiring just a couple of control lines per motor. It can also be interfaced with
simple manual switches, TTL logic gates, relays, etc. This board equipped with power LED
indicators, on-board +5V regulator and protection diodes.

Ultrasonic Sensor
The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like bats
do. It offers excellent non-contact range detection with high accuracy and stable readings in an
easy-to-use package from 2 cm to 400 cm or 1” to 13 feet.

The operation is not affected by sunlight or black material, although acoustically, soft materials like
cloth can be difficult to detect. It comes complete with ultrasonic transmitter and receiver module.
Robotics Lab LAB 4

Technical Specifications
 Power Supply − +5V DC
 Quiescent Current − <2mA
 Working Current − 15mA
 Effectual Angle − <15°
 Ranging Distance − 2cm – 400 cm/1″ – 13ft
 Resolution − 0.3 cm
 Measuring Angle − 30 degree

Circuit Diagram
Robotics Lab LAB 4
Sample code to interface ultrasonic sensor with Arduino:
You have to merge a chunk of this code to the 4WD robot kinematics code to run a robot
in closed path.

const int Trigpin = A0; // Trigger Pin of Ultrasonic Sensor


const int echoPin = A1; // Echo Pin of Ultrasonic Sensor
long duration, inches, cm;

void setup() {
Serial.begin(9600); // Starting Serial Terminal
pinMode(Trigpin, OUTPUT);
pinMode(echoPin, INPUT);

void loop() {
calculateDistance();

Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}

void calculateDistance(){

digitalWrite(Trigpin, LOW);
delayMicroseconds(2);
digitalWrite(Trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(Trigpin, LOW);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
return inches;
return cm;}

long microsecondsToInches(long microseconds) {


return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {


return microseconds / 29 / 2;
}
Robotics Lab LAB 4
Task:
Task Description: Moving a Robot Along a Rectangular Path with Timed Movements

In this lab task, the objective is to program a robot to move along a rectangular path,
performing a series of timed movements. Placed an ultra-sonic sensor and program such a
way that whenever it detects any obstacle it will reset at that point and start the path
completion from that point. The lab demonstrates fundamental concepts of ultra sonic sensor
performance using robot kinematics, motion control, and sequencing.

Lab Assignments Marks: 20

1- Write a code to program Arduino to run a robot in rectangular path in varying speed to
complete two laps.
Note: Paste your code in the manual:

1- Write a code to program Arduino to spin a robot along y axis and after 5 second of
spinning, the rotation of robot spin should be inverse for next 5 seconds.
Note: Paste your code in the manual:
Robotics Lab LAB 4

OBSERVATIONS AND COMMENTS


Robotics Lab LAB 4

You might also like