Ultrasonic Mapmaker Using Arduino and MatLab




Vision is one of the most exciting senses you can endow on your robot. The ability to perceive obstacles allows a robot to make an educated decision regarding further movements.

However, it is also not the easiest senses to implement for a few reasons. Firstly, vision can be abstracted to a two-dimensional vector when it comes to computing, as opposed to a single dimensional scalar such as, say, temperature. Secondly, it is an analog value like many other senses, so it requires a certain degree of digitization and processing for it to make sense to a computer. Finally, though this is not strictly a problem, is visualization. Vision data cannot be represented as mere numbers to humans. Although that is how computers process data, it makes no sense for a human to decode digits. However, with the help of modern technology, and basic knowledge of physics and math, we will be able to endow our robot with the gift of sight!




Step 1: Theory

In this project, we are using an ultrasonic Distance sensor. It generates sound waves beyond the scope of human hearing and measures distance by calculating the time required by these waves to hit an obstacle and travel back. This is similar to the principle used by bats.

Another component that we are going to use is a servo motor. It differs from the usual DC motor in that it can turn very precisely to a given angular position and hold its state there. When a servo motor is given pulses of a specific duration, it moves to the corresponding angular position.

READ  A lightning flash counter

We will be using both these components to get a 180 degree field of view for our robot.

Step 2: Collecting Materials

This project uses the following hardware

  1. Arduino Uno/Yun (Please note that any Arduino footprint board can be used in place of the Uno or Yun)
  2. Arduino Prototyping Shield
  3. An HC-04 Ultrasonic Sensor
  4. A servo motor (I’ve used the Tower Pro SG90 because its very compact)

On the software side we are using the following programs

  1. The Arduino IDE to upload control code to the Arduino to rotate the servo and get distance data from the ultrasonic sensor and also push it to the serial port.
  2. Mathworks MatLab to receive data from the serial line, process it and visualize it to a graph.

Step 3: Mechanical Assembly

Using a small piece of general purpose PCB, make a small header for the HC-04, and attach it to a servo horn using a piece of double sided tape.

This step is optional, but to make the system more compact, I’ve attached the servo to the jutting part of the protoboard shield using double sided tape as well.

The final result should look like Wall-E’s abdomen.

Step 4: The Arduino Code

The Arduino code controls the motion of the servo motor, and when the readings from the ultrasonic sensor are captured and how frequently. It also pushes the sensor data to the serial port.

  1. Import libraries
  2. Initialize variables and pins.
  3. Initialize servo object
  4. Initialize serial communication
  5. Wait for 3 seconds
  6. Initialize counters to 0
  7. Rotate servo by 1 degree
  8. Get ultrasonic sensor data 10 times (set by default)
  9. Average the data
  10. Send the average to serial port
  11. Return to step 7
READ  ATMEL ARDUINO COLORED CONNECTION CHART

Read more: Ultrasonic Mapmaker Using Arduino and MatLab




Leave a Comment

*
= 3 + 7

(Spamcheck Enabled)

Read previous post:
AAEON’s VPC-5600S opens up new horizons for NVR technology
AAEON’s VPC-5600S opens up new horizons for NVR technology

AAEON, an award-winning developer of network devices and embedded computers, launches the VPC-5600S, a network video recorder (NVR) with a...

Close
Scroll to top