Our Kickstarter project is live – join us to bring E-Tac-Toe to life!
In this project, we will design and construct a Short Range Radar System using the MaxSonar EZ-1 ultrasonic range finder. This system will measure the distance from the front of the sensor to nearby objects with high precision. The main components required for this project include an ultrasonic range finder, a servo motor, an Arduino UNO, and jumper wires. Optionally, a motor shield can be used for more efficient control of the servo motor. The software development will utilize the Arduino and Processing IDEs, both of which are open-source and freely available.
Programming: Used for writing and uploading the code to the Arduino UNO. The code will manage the sensor data acquisition and motor control.
Libraries: Necessary libraries for ultrasonic sensors and servo motor control will be included.
Visualization: Processing will be used to create a visual representation of the radar data, allowing us to see the detected objects in a graphical format.
Integration: The Processing IDE will communicate with the Arduino to receive distance measurements and display them in real time.
1. Assembly:
Connect the MaxSonar EZ-1 sensor to the Arduino UNO using jumper wires.
Attach the servo motor to the Arduino, optionally using the motor shield for easier connections.
Ensure all connections are secure and correctly placed according to the pin configuration.
2. Coding:
Write the Arduino sketch to control the servo motor's rotation and read distance measurements from the ultrasonic sensor.
Develop a Processing sketch to visualize the distance measurements, creating a radar-like display.
3. Testing:
Upload the Arduino sketch to the Arduino UNO and run the Processing sketch.
Observe the radar display and verify that the system accurately detects and displays distances to nearby objects.
Precision: The MaxSonar EZ-1 is selected for its precision and variety of options. It provides accurate readings from 0 to 255 inches (0 to 6.45 meters) in 1-inch increments.
Features: It has a minimal dead zone, ensuring reliable distance measurements even at close range.
Operation: The MaxSonar EZ-1 operates in a free-run mode, continuously ranging until power is removed. It can also operate with a trigger signal, allowing it to be controlled by a microcontroller, computer, or other devices capable of initializing a ranging cycle.
Detection Method: It uses high-frequency sound for non-contact object detection in the air. The sensor is unaffected by the color or other visual characteristics of the object, making it versatile for various environments.
Measurement Principle: The sensor measures the time of flight for the sound wave that is transmitted and then reflected back from an object. Based on the time of flight, the sensor outputs a range reading.
This ultrasonic sensor works in the air for non-contact object detection within an area. This sensor is not affected by a color or other visual characteristics of the detected object. Ultrasonic sensors use high-frequency sound to detect and localize objects in a variety of environments. Ultrasonic sensors measure the time of flight for sound that has been transmitted to and reflected from nearby objects. Based on the time of flight, the sensor then outputs a range reading.
LV-MaxSonar-EZ1 Pin Out
Pin 1-BW- * Leave open or hold low for serial output on the TX output. When BW pin is held high the TX output sends a pulse (instead of serial data), suitable for low noise chaining.
Pin 2-PW- This pin outputs a pulse width representation of range. The distance can be calculated using the scale factor of 147uS per inch.
Pin 3-AN- Outputs analog voltage with a scaling factor of (Vcc/512) per inch. A supply of 5V yields ~9.8mV/in. and 3.3V yields ~6.4mV/in. The output is buffered and corresponds to the most recent range data.
Pin 4-RX– This pin is internally pulled high. The LV-MaxSonar-EZ will continually measure range and output if RX data is left unconnected or held high. If held low the sensor will stop ranging. Bring high for 20uS or more to command a range reading.
Pin 5-TX- When the *BW is open or held low, the TX output delivers asynchronous serial with an RS232 format, except voltages are 0-Vcc. The output is an ASCII capital “R”, followed by three ASCII character digits representing the range in inches up to a maximum of 255, followed by a carriage return (ASCII 13). The baud rate is 9600, 8 bits, no parity, with one stop bit. Although the voltage of 0-Vcc is outside the RS232 standard, most RS232 devices have sufficient margin to read 0-Vcc serial data. If standard voltage level RS232 is desired, invert, and connect an RS232 converter such as a MAX232. When the BW pin is held high the TX output sends a single pulse, suitable for low noise chaining (no serial data).
Pin 6- Vcc (+5V) - Operates on 2.5V - 5.5V. Recommended current capability of 3mA for 5V, and 2mA for 3V. Please reference page 4 for minimum operating voltage versus temperature information.
The LV-MaxSonar-EZ sensor measures the distance to objects starting from the front of the sensor, as illustrated in the diagram below. Typically, the LV-MaxSonar-EZ reports the distance to the leading edge of the nearest detectable object. The sensor's ability to detect targets has been characterized and illustrated in its beam patterns.
The sensor minimum reported distance is 6-inches (15.2 cm). However, the LV-MaxSonar-EZ will range and report targets to the front sensor face. Large targets closer than 6 inches will typically range from 6 inches.
The range is measured from the front of the MaxSonar.
The Servo Motor SG90 is tiny and lightweight with high output power. The servo can sweep approximately 180 degrees (90 in each direction) and works just like the standard motors. You can use any servo code, hardware, or library to control these servos. It is good for beginners who want to make stuff move without building a motor controller with feedback & gear box, especially since it will fit in small places.
Specifications
- Weight: 9 g
- Dimension: 22.2 x 11.8 x 31 mm approx.
- Stall torque: 1.8 kg f cm
- Operating speed: 0.1 s/60 degree
- Operating voltage: 4.8 V (~5V)
- Temperature range: 0 ºC – 55 ºC
Servo Motor SG90
- Microcontroller: The Arduino UNO serves as the main controller for the radar system, processing data from the ultrasonic sensor and controlling the servo motor.
- Connections: These are used to connect the various components to the Arduino board.
- Enhanced Control: While optional, a motor shield can simplify the control of the servo motor by providing dedicated motor control pins and additional power options.
The circuit for this project can be constructed using an Arduino UNO without a motor shield, as the current requirement of the SG90 servo motor is very low. However, as a good practice, it is recommended to use motor drivers to control motors connected to the Arduino, especially if the project is upgraded with additional components.
Powered by USB: Total of 500mA
With External Power Supply: Total of 500mA to 1A
5V Pin: 500mA or 500mA to 1A
Each Input/Output Pin: 40mA
The sum of All Input/Output Pins Combined: 200mA
Due to these current limitations, using a motor driver (as shown in the figure, Option 2) is recommended for projects that may include additional gadgets. However, if a motor shield is not available, the circuit can be connected as shown in the figure below (Option 1).
Arduino UNO
SG90 Servo Motor
MaxSonar EZ-1 Ultrasonic Sensor
Jumper Wires
Connect the VCC of the MaxSonar EZ-1 sensor to the 5V pin on the Arduino.
Connect the GND of the MaxSonar EZ-1 sensor to the GND pin on the Arduino.
Connect the analog or digital output pin of the MaxSonar EZ-1 sensor to an appropriate input pin on the Arduino (e.g., A0 or D2).
Connect the VCC of the SG90 servo motor to the 5V pin on the Arduino.
Connect the GND of the SG90 servo motor to the GND pin on the Arduino.
Connect the signal wire of the SG90 servo motor to a PWM-enabled digital pin on the Arduino (e.g., D9).
Arduino UNO
Motor Shield
SG90 Servo Motor
MaxSonar EZ-1 Ultrasonic Sensor
Jumper Wires
Attach the motor shield to the Arduino UNO.
Connect the VCC of the MaxSonar sensor to the 5V pin on the motor shield.
Connect the GND of the MaxSonar sensor to the GND pin on the motor shield.
Connect the analog or digital output pin of the MaxSonar EZ-1 sensor to an appropriate input pin on the motor shield.
Connect the VCC of the SG90 servo motor to the 5V pin on the motor shield.
Connect the GND of the servo motor to the GND pin on the motor shield.
Connect the signal wire of the servo motor to a PWM-enabled digital pin on the motor shield.
The following video shows the complete development and testing of an Arduino-based radar system using the MaxSonar EZ-1 ultrasonic sensor. The demonstration covers the following key aspects:
Arduino Radar DEMO
Arduino Code
Processing Code
Test Results
Arduino Radar DEMO
The video then transitions to an overview of the Arduino code that controls the radar system. Key points covered include:
Initialization: The code begins by initializing the servo motor and ultrasonic sensor.
Servo Control: Functions to rotate the servo motor from 0 to 180 degrees in increments, allowing the sensor to sweep the area.
Distance Measurement: Code to trigger the ultrasonic sensor and read the time of flight for the sound waves.
Data Processing: Calculation of distance based on the time of flight and storing the results.
Serial Communication: Sending distance data to the computer via serial communication for further processing.
The video highlights specific portions of the code, explaining how each part contributes to the overall functionality of the radar system.
Following the Arduino code, the video demonstrates the Processing code used for visualizing the radar data. The key features include:
Serial Data Reading: The Processing sketch reads the distance data sent from the Arduino via the serial port.
Graphical Interface: A graphical user interface (GUI) is created to display the radar data in a visual format.
Real-time Visualization: As the servo motor sweeps, the Processing sketch plots the detected distances on a radar-like display, showing the position and distance of objects relative to the sensor.
The video walks through the Processing code, explaining how the data is read and visualized, and how the interface updates in real-time to reflect the sensor readings.
»»» END of Short-Range Radar System »»»