Introduction: Acoustic Radar Display
This instructable describes how to make an ultrasonic “radar-style” display using an Arduino microcontroller, an ultrasonic sensor, and a small stepping motor.
An optional sensor modification allows multiple objects to be detected with each ping.
Construction is simple ... all you need are two drills, a sharp knife, a pair of side-cutters , and a soldering iron.
Photo 1 shows the basic parts. The “insert” shows a random-dot test pattern. Dots representing primary objects are shown in red ... dots representing secondary objects are shown in blue.
Photo 2 shows the assembled unit.
Photo 3 shows an actual screen shot of seven objects. [1]
The video clip shows the unit in operation.
[1]
The azimuth and distance of each primary object are shown in red. Any echo from a secondary object is shown in blue. Without the sensor modification you will only see the red objects.
Since the sonic pulses expand in a cone-like manner, distant objects appear wider. The actual bearing of each object is the midpoint of each continuous (red or red/blue) line.
Continuous lines containing both red and blue dots are a single object, part of which is in shadow.
Step 1: Wiring Diagram
The wiring diagram is shown in photo1.
An optional modification is shown in photo2. This modification is the SAME for both the HC-SR04 and the HY-SRF05 ultrasonic sensors and allows multiple echos to be detected. [1]
[1]
For a full explanation see my instructable https://www.instructables.com/id/Enhanced-Ultraso...
If you have an HC-SR04, the integrated circuit to which you solder the wire is labelled U2
Step 2: Parts List
The following parts were obtained locally:
- 1 only plastic food container.
- 1 only sub-miniature micro-switch.
- 1 only male header strip (used for attaching wires from sensor).
- 1 only female header strip (used to mount sensor).
- 1 only piece of 20 gauge aluminium (scrap) sheet 40mm x 55mm.
- 6 only 9mm nylon spacers tapped 3mm.
- 3 only cable-ties.
- 13 only 3mm x 6mm bolts.
- 1 only 3mm nut.
- 4 only 4mm x 10mm bolts.
- 2 only 4mm nuts.
The following parts were obtained from https://www.aliexpress.com/
- 1 only Arduino Uno R3 microcontroller complete with USB cable.
- 1 only 28BJY-48 5 volt stepping motor complete with ULN2003 controller.
- 1 only 5mm bore brass hex shaft to wheel coupler for model cars.
- 1 only HY-SRF05 (or HC-SRF04) ultrasonic sensor.
Step 3: How It Works
Mechanical
All parts are housed inside a plastic food container. Power is obtained from your USB port.
The circuit comprises an Arduino, an ultrasonic sensor, a stepping-motor, and a micro-switch for moving the sensor to its “home” position. The micro-switch is necessary as it is not possible to rotate the stepping motor by hand due to its 64:1 internal gearing.
When first powered up the Arduino rotates the sensor to its “home” position, as determined by the micro-switch, then “polls” the display until it gets a response.
The 28BJY-48 stepping motor has a “stride angle” of 5.625/64 degrees which means that 1 degree steps are not possible (even though our graticule is labelled 0..180 degrees).
Fortunately, 180/stride-angle = 180*64/5.625 = 2048 which is evenly divisible by 8. If we increment a number from 0..2048 and divide by 8 there are 256 occasions when we get a remainder of zero ... we simply send a “ping” whenever the remainder is zero. This equates to a “ping” every PI/256 radians or 0.703125 degrees.
Software [1]
The display then takes control and continually asks the Arduino to supply the following data:
- Azimuth
- Distance1
- Distance2
- Direction
The “distance(s)” for each “azimuth” are then displayed on the screen. The “direction” information is used to create the illusion of “dots” appearing behind the “beam” as it rotates.
The Arduino automatically moves to the next “ping” position whenever data is sent to the display.
[1]
The “Processing 3” software used for writing the display may be downloaded from https://processing.org/download/
Processing 3 supports 2D and 3D graphics and is very similar to the Arduino IDE (Integrated Development Environment). The main visual differences are a “graphics window” when the code is running and the use of a “draw()” function instead of the Arduino “loop()”.
Step 4: The Display
The Graticule
I chose to create a 180 degree graphics display as it provides a “radar shadow” in which to stand while experimenting. Such a display is also compatible with a servo motor should I wish to use one. A full 360 degree display can be obtained by tweaking the code.
The following photos explain how the graticule was created:
Photo 1
- The graticule comprises a number of “arcs” and “lines”. Angled labels are shown in this photo but were later dropped in favour of horizontal text which is easier to read.
Photo 2
- Shows a red line depicting the “beam”. The text in the label is now horizontal.
Photo 3
- The red line in photo 2 has been rotated 0..180 degrees through 256 azimuth positions. In this photo the outer parts of the graticule are not covered as the beam-width is too narrow. This results in some strange artifacts.
Photo 4
- Increasing the beam-width has eliminated these artifacts.
Photo 5
- Random dots have been introduced to represent primary (red) and secondary (blue) echos. The range, which can be changed, has been set to exactly 100cm to match the display. A fading beam pattern has also been introduced. The technique used to create this “fading beam” is explained further on.
Photo 6
- The color scheme has been changed to add a touch of realism.
Animation
The animated portions of the graphics display use 3D graphics to greatly simplify the code. To understand how this is possible let’s draw a “30 degree line” of constant radius from an XY start coordinate of (0,0).
2D graphics requires the use of sin(30) and cos(30) to calculate the XY end coordinates of the line:
X=cos(30)*radius = 0.866*radius Y=sin(30)*radius = 0.5*radius line(0,0,X,Y);
3D graphics doesn’t require the use of trigonometry. We simply rotate the XY grid coordinates about the Z-axis then draw a horizontal line .... no maths required!!!
pushMatrix(); //preserve our current grid coordinates rotateZ(radians(30)); //rotate our XY grid coordinates about the Z-axis line(0,0,radius,0); //draw a “horizontal” line on the rotated grid popMatrix(); //restore our grid coordinates
Either way works but this second method lends itself to “ping” intervals of PI/256 radians.
Fading Lines
The fading beam pattern uses a clever technique found at https://forum.processing.org/two/discussion/13189...
The beam is given its own virtual screen. Prior to drawing any line the “alpha” (opacity) of all previous lines is reduced by a small amount. Ultimately the earliest lines become invisible which gives the illusion of a fading “fan” pattern.
This virtual screen, which is never erased, is then merged with the contents of the main screen whenever the display is refreshed.
Step 5: Mounting Bracket
The drilling template for a suitable mounting bracket is shown in photo 1.
Position the two outer “mount” holes below the transmit (T) and receive (R) sensors. I find that best results are obtained if the sensor rotates around the receive (R) sensor rather than midway between the two sensors. The three holes allows you to experiment.
Details of how to “cut and fold” aluminium may be found in my instructable https://www.instructables.com/id/How-to-Cut-Fold-...
Step 6: Assembly
USB cable-hole
Do not try and drill a cable-hole for the USB connector though the side of the plastic container as plastic tends to split and chip. Instead, melt a hole using the tip of a hot soldering iron then trim with a sharp knife. Take care not to breath the fumes.
Shaft-extender
Replace one of the 4mm “grub-screws” in the shaft-extender with a 4mm x 10mm bolt. This bolt is used to activate the micro-switch.
Micro-switch
Position the micro-switch such that it is activated by the 4mm bolt when the shaft rotates in a clockwise direction.
I used two turns of 20 gauge copper wire to attach the micro-switch to the case as 2mm nuts and bolts were not readily available.
Remaining components
Layout is not critical. The motor shaft was positioned centrally. The Arduino and motor controller were mounted on nylon spacers which allow the wires to be tucked underneath.
Mounting the sensor
Photo 1
- shows the sensor assembly. The HY-SR0F-5 socket has been fashioned from a female-header socket. All unwanted pins have been removed and a 3mm hole drilled through the plastic. The header is then attached to the bracket by means of a 3mm nut and bolt.
Photo 2
- shows a side view of the sensor assembly. The wires from the header are cable-tied to the bracket. This “strain-relief” prevents unwanted cable movement as the sensor rotates. Note also the “grey” wire attached to pin 10 of IC1. This wire is optional and feeds the secondary echos to the Arduino.
Attach the sensor assembly to the shaft extender after the micro-switch has operated following power-up. The shaft is then in its “home” position.
Step 7: Software Installation
Install the following code in this order:
Arduino IDE
Download and install the Arduino IDE (integrated development environement) from https://www.arduino.cc/en/main/software if not already installed.
Processing 3
Download and install Processing 3 from https://processing.org/download/
Acoustic Radar Sender [1]
Copy the contents of the attached file, “acoustic_radar_sender_2.ino”, into an Arduino “sketch”, save, then upload it to your Arduino Uno R3.
Close the Ardino IDE but leave the USB cable connected.
Acoustic Radar Receiver
Copy the contents of the attached file, “acoustic_radar_receiver.pde” into a Processing “Sketch”.
Bugfix
[1]
"acoustic_radar_sender_2.ino" fixes a "scan-creep" bug in "acoustic_radar_sender_1.ino" . My thanks to https://www.instructables.com/member/newtoeu/instr... for pointing it out.
Step 8: Testing
Click the top left “Run” button in your Processing window and your project will burst into life.
Try detecting different objects:
- Nearby objects require the transmit (T) sensor to be low to prevent the "beam" passing over the top.
- More distant objects require a larger surface area as much of the acoustic energy is lost as the beam spreads ... plus the return echo also spreads.
- Experiment with the three mounting holes.
- You may wish to try mounting the sensor vertically so that the transmit and receive beam-widths overlap.
Click here to view my other instructables.
59 Discussions
6 months ago
what is the necessary change to display second time around echo ?......basically distance after 2m must ba agin measured from the origin (i.e 250 must be 50)...and so on ......
10 months ago
hiii ...sorry to bother u again but do u this this instructable should be able to make it wireless just have a look and tell me
https://www.instructables.com/id/Arduino-Reading-S...
this one according to this person is just a little of physical changes(powering bluetooth) then adding a serial.flush ..to wait till tx is done and change port to output port of bluetooth ..so that u communicate via output port of bluetooth i tried this but it is not working for mr could u please look and see what all chnages are required
Reply 10 months ago
The circuit to which you refer has a number of errors.
The RXDATA voltage divider resistors are missing from the circuit. The author draws your attention to this fact but expects you to look them up. Suitable resistor values are shown in the circuit diagram for this instructable https://www.instructables.com/id/Add-Bluetooth-to...
Connecting the the HC-05 bluetooth module to the 3.3volt supply will NOT protect the RXDATA line. The Arduino is connected to a 5 volt supply which means the TX data pin will rise to 5 volts. A voltage divider is required.
I suspect that the reason your project is not working is one of communication speed.
The default speed for an HC-05 is 9600 bauds whereas the required communication speed for my Acoustic Radar Receiver is 115200 bauds.
My Acoustic Radar Receiver is unlikely to work if you reduce the communication speed. To convert this project to bluetooth requires that you increase the HC-05 communication speed to 115200 bauds.
Instructions for doing this may be found by entering "AT bluetooth" (without the quotes) into the Instructables "Lets Make ..." search bar. This search brings up a number of instructables.
The following example appears to have the AT commands that you need https://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/
Question 12 months ago
hi can u tell me the connection of microswitch as where does c ,nc and no ...should go please help me as it is not clear as if where to connect the microswitch
Answer 12 months ago
The microswitch is connected between GND (ground) and Arduino pin 4 (this pin is also known as pin D4). The green lines on the wiring diagram are correct.
The microswitch connections are also defined in code lines 45,46
// ----- micro-switch
#define Micro_switch 4
The letters c, nc, no on your micro-switch mean:
c = common
nc = normally closed
no = normally open
Connect the green wires on the wiring diagram between c and no.
Question 1 year ago
can i remove the micro switch by directly connecting the pin 4 to 5v vcc in the arduino itself
or that micro switch is necessary as it is a part of program i wanted to know how to remove it
Answer 1 year ago
Remove the switch and change code line 47 to read:
bool Switch_present = false;
Reply 1 year ago
i removed the switch and all wires with it ...and changed this line bool Switch_present = true; to false ..i am not using that raw echo pin ..but the setup is not working ,,....the motor dosen't rotate and if i keep it "true" motor rotates but nothing happens in processing 3
Reply 1 year ago
Working code does not stop without a reason ... it appears that you have introduced a logic or coding error.
Your project has a number of innovative ideas that would make a great Instructable once you have solved the issues.
Reply 1 year ago
thank u for the praise but right now it is not working
if i just change the line 47 as false and keep the rest of code same and dont connect the raw echo line and microswitch line ..it should work fine ...do i need to remove the lines regarding the raw echo and if i need to remove any other lines ..please help me out its a project of mine and there is no one here who can help me in programming
Reply 1 year ago
Use the following strategy to debug any code changes that you make to this instructable:
----------------------------------------
Debugging your Arduino code
-----------------------------------------
(1) Close Processing ... Processing is not required when debugging the Arduino code for this particular project
(2) Upload my original code to your Arduino
(3) Open "Serial Monitor"
(4) Set the Serial Monitor baud speed to 115200
(5) Observe what happens ... you should see an upper-case letter 'S' scrolling down the screen.
(6) Send an upper-case 'S' from the Serial Monitor ... the scrolling should stop ... and the Arduino should respond with a string of data
(7) Send another upper-case 'S' ... each time you send an 'S' the motor should move slightly and the Arduino should respond with another string of data.
(8) Now make a code change and see how the Arduino responds.
(9) Repeat the above two steps until your Arduino code is working the way you want.
(10) Close the Serial Monitor
---------------------------------------------
Debugging your Processing code
---------------------------------------------
(1) Connect your Arduino to your PC
(2) Open Processing
(3) Upload my Processing code
(4) Alter the Processing code to make it compatible with your Arduino code changes.
(5) Click the Run button and observe what happens.
(6) Repeat the above two steps until you have your project working.
I am unable to help you further ...
Question 1 year ago
hi i have the same project but i want to make it a 360 continuous rotating one and to do so help me out in what all changes do i have to do in arduino ide sketch as well as processing 3 sketch so that a complete 360 rotating display can be visualized ...to kepp the wires from entangling i am using bluetooth hc05 module ...please help me out in what all changes i need to make and about making it wireless over bluetooth module
Regards
Answer 1 year ago
Thank you for your interest in my project.
Unfortunately I don't have time to develop your project but the following tips should help:
------------
Arduino
------------
- Use a magnetic reed switch for detecting "zero"
- Use "slip-rings to prevent the wires tangling.
- Change the stepping motor algorithm to suit
---------------
Processing
---------------
- Double the Processing array size to accommodate the other half of the display.
- Extend the Processing labelling concept
Good luck
Reply 1 year ago
thank u for the tips i will get back to u if i need some help thank u and sorry to bother you
Question 2 years ago
I HAVE A PROBLEM !!!
Hi im a student of the damiaaninstituut at aarschot in belgium
we had to choose a project from this site and i chose this
i think its a cool and nice project
but i have a problem
everytime i try to start the progam i get this error :
Error opening serial port COM1: Port busy
Answer 2 years ago
The software for "Acoustic Radar Display" must be loaded in the following sequence:
--------------------
The Arduino software
--------------------
(1) Connect a USB cable between your Arduino and your PC
(2) Click "Tools|Port" then select your Arduino serial port number.
(3) Upload the Arduino sketch to your Arduino
(4) Leave the USB plugged in to your PC
(5) Close your Arduino IDE ... it is no longer required
---------------------
Processing 3 Software
----------------------
(1) Now run the Processing 3 sketch
-----------------------
Possible error messages
------------------------
You will get an error message if:
(1) the Arduino USB cable is not plugged in to the PC.
(2) The Processing serial port is not the same as that used to program the Arduino
(3) The error message that you describe indicates that you have tried to upload software to your Arduino while the Processing sketch is running.
Question 2 years ago on Step 1
hello.....do you know of a way to send the video to a 4 wire oled display? Trying to make a 1 inch radar screen for a 1/10 scale model boat.
Thanks
Glenn
Answer 2 years ago
My first approach would be to replace the USB cable with a two way wireless link. The following tutorials:
https://www.instructables.com/id/Arduino-wireless-...
https://www.instructables.com/id/Interfacing-OLED-...
may be helpful.
2 years ago
Can of Watties!!! This guy's a Kiwi!
Excellent Instructable, lots of fun and very well presented. It looks like the radar prefers the Baked Beans...
Thanks.
Reply 2 years ago
Thanks for commenting :)