“It’s only software!” A sentence that strikes terror in the heart of an embedded systems software developer. That sentence is often uttered when the software person finds a bug in the hardware and others assume it’s going to be easier for fix in software rather than spin a new hardware revision. No wonder software is always late.
[Clint Stevenson] is his own hardware and software guy, as are most of us. He wanted to use the less expensive HC-SR04 ultrasonic rangefinder in a prototype. Longer term he wanted to have the choice of either a Parallax PING or MaxBotix ultrasonic sensor for their better performance outdoors. His hardware hack of the SR04 made this a software problem which he also managed to solve!
[Clint] was working with the Arduino library, based on the Parallax PING, which uses a single pin for trigger and echo. The HC-SR04 uses separate pins. Originally he modified the Arduino library to accept the two pin approach. But with his long term goal in mind, he also modified the HC-SR04 sensor by removing the on-board pull-up resistor and adding a new one on the connector side to combine the signals. That gave him an SR04 that worked with the single-pin based library.
We’ve seen Parallax PING projects for sensing water depth and to generate music. These could be hacked to use the HC-SR04 using [Clint’s] techniques.
[Arduino and HC-SR04 photo from Blax Lab]
[Emil] got his hands on a dozen HC-SR04 ultrasonic sensors, but wasn’t too happy with their performance. Rather than give up, he reverse engineered the sensor and built an improved version. Hackers, Makers, and robotics enthusiasts have had easy access to standard sonar platforms since the early 1980’s, when Polaroid began selling their 6500 sonar modules. A number of companies have released sonar boards since then, notably The Parallax Ping))) module. The HC-SR04 appeared on the market a few years back as a low-cost alternative of the Ping.
[Emil] found that the HC-SR04 would work reliably on hard surfaces as far as 4 meters away from the sensor. However, he got a lot of bad data back when using soft sided targets, or when no target was present at all. [Emil] reverse engineered the schematic of the HC-SR04 and found some interesting design decisions. A Max232 RS-232 converter chip is used for its
+-12V +-10V charge pumps. The charge pumps are connected to create 24V 20V at the ultrasonic transmitter. A mask programmed microcontroller manages the entire unit, commanding the ultrasonic transmitter to send 40Khz pulses, and listening for returns on the receive side of the system. [Emil] believes the micro is running in polled mode, due to the fact that it sometimes misses pulses. Even worse, the micro runs on an unmarked 27MHz crystal which had quite a bit of drift.
[Emil] solved these problems by creating his own PCB with an ATtiny24 and a 12MHz crystal. He increased the pin count from 4 to 6, allowing the ATtiny to be programmed in circuit, as well as opening the door to I2C and SPI operation. To build the boards up, [Emil] first solders his micro and crystal. He then uses a hot air gun to move all the components from the HC-SR04 board to his own. The new boards are still being tested, but [Emil] has posted his PCB and BOM data. He’s also promised to post his AVR code when it is available.
[Miguel] wanted to get more hands-on experience with Python, so he created a small robotic platform as a testbed. But as such things sometimes go, it turns out the robot he created is a worthy enough project in its own right. With a low total cost and highly flexible design, it might be exactly what you’re looking for. Who knows, it might even bootstrap that rover project that’s been wandering around the back of your mind.
The robot makes use of an exceptionally simple 3D printed frame. No complicated suspension to worry about, no fasteners to hold together multiple printed parts. It’s just a single printed “L” shaped piece that has mounts for the motors and front sensor board. As designed it simply drags its tail around, which should work fine on smooth surfaces, but might need a bit of tweaking if you plan on taking your new robotic friend on an outdoor adventure.
There’s a big open area on the “tail” to mount a Raspberry Pi, but you could really put whatever board or microcontroller you wish here. In the nose is an HC-SR04 ultrasonic sensor, which [Miguel] is using to perform obstacle avoidance in his Python code. A dual H-Bridge motor driver controls the pair of gear motors in the front to provide propulsion and steering, and a buck converter steps down the 7.4V from the 2S LiPo battery to power the electronics. He’s even included a mini breadboard so you can add circuits or sensors as experimental payloads.
If you’re looking for a slightly more advanced 3D printed robotics platform, we’ve seen our fair share. From the nearly fully printed Watney to a tank that looks like it’s ready for front-line combat.
Infrared certainly has its uses, but if you’re trying to locate objects, ultrasonic detection is far superior. It’s contact-less, undetectable to the human ear, and it isn’t affected by smoke, dust, ambient light, or Silly String.
If you have one ultrasonic sensor and a microcontroller, you can detect plenty of useful things, like the water level in a rain barrel or the distance traveled by a tablet along a rail. If you have two sensors and a microcontroller, you can pinpoint any object within a defined range using trigonometry.
[lingib]’s dual sensor echo locator uses two HY-SRF05s, but the cheap and plentiful HC-SR04s will work, too. Both sensors are arranged for maximum beam overlap and wired up to an Arduino Uno. One sensor’s emitter is blocked with masking tape, so all it does is listen.
When the system registers the object, it shows up as a red dot on a grid inside a Processing sketch along with a bunch of details like the object’s coordinates, its distance from each sensor, and the area of the triangle formed by the two sensors and the object. [lingib] reports that the system is quite accurate and will work for much larger playgrounds than the 1 meter square in the demo after the break.
Don’t want to detect objects? Ultrasonic sensors are cheap enough to hack into other things, like this one-way data communications module.
Continue reading “Dual Sensor Echo Locator Gives High Accuracy At Low Cost”
Some of the best hacks are the ones which seem perfectly obvious in hindsight; a solution to the problem that’s so elegant, you wonder how it never occurred to you before. Of course we also love the hacks that are so complex your eyes start to water, but it’s nice to have a balance. This one, sent in by [Eduardo Zola] is definitely in the former group.
In the video after the break, [Eduardo] demonstrates his extremely simple setup for using ultrasonic transducers for one-way data communication. Powered by a pair of Arduinos and using transducers salvaged from the extremely popular HC-SR04 module, there’s a good chance a lot of readers can recreate this one on their own bench with what they’ve got lying around. In this example he’s sending strings of text from one computer to another, but with a little imagination this can be used for all sorts of projects.
For the transmitter, the ultrasonic transducer is simply tied to one of the digital pins on the Arduino. The receiver is a bit more complex, requiring a LM386 amplifier and LM393 comparator to create a clean signal for the second Arduino to read.
But how does it work? Looking through the source code for the transmitter and receiver, we can see it’s about as basic as it gets. The transmitter Arduino breaks down a given string into individual characters, and then further converts the ASCII to eight binary bits. These bits are sent out as tones, and are picked up on the receiving end. Once the receiver has collected a decent chunk of tones, it works through them and turns the binary values back into ASCII characters which get dumped over serial. It’s slow, but it’s simple.
If you’re looking for something a bit more robust, check out this guide on using GNU Radio with ultrasonics.
Continue reading “Dead Simple Ultrasonic Data Communication”
We thought that making things levitate in mid-air by the power of sound was a little bit more like magic, or at least required fancy equipment. It turns out that you can do it yourself easily enough with parts that any decent hacker’s closet should have in abundance: a motor-driver IC, two ultrasonic distance pingers, and a microcontroller. This article shows you how (translated here, scroll down).
But aside from a few clever tricks, there’s not that much to show. The two HC-SR04 ultrasonic distance sensors are standard fare, and are just being used as a cheap source of 40 kHz transducers. The circuit uses a microcontroller, but any source of 40 kHz square waves should suffice. Those of you who could do that with a 555 (or a Raspberry Pi), this one’s for you! A stepper motor driver bumps up the voltage applied to the transducers, but you could use plain-vanilla transistors as well.
It’s all the little details that count, however. You need to position the two ultrasonic drivers fairly precisely to create a standing wave, and while you can start at 8.25 mm and trial-and-error it, the article demonstrates using an oscilloscope to align the capsules by driving one and reading the signal out of the other and tweaking them until they’re in phase. Clever!
The author also takes the ultrasonic-transparent grille from one of the unused receivers and uses it as a spoon to help position the styrofoam bits in the sound waves. We always wondered how you’d do that!
It turns out that it’s easy to make a DIY ultrasonic levitation desk toy, and none of the parts are expensive or critical. The missing ingredient is just the gumption to try it, and now we have that, too.
As cool as they are, the HC-SR04 modules aren’t perfect for all distance sensing applications. Here’s everything you need to know about them, including hacks to make them work up-close. And since HC-SR04 sensors come cheapest in ten-packs, you’ll be wondering what you’re going to do with the other eight. That problem has apparently also been solved.
[ChrisN219] has an antique Coke machine that used to hold glass bottles. Now it holds around 30 tall boy cans of his favorite post-work suds. The only problem is that [Chris] has no idea how many cans are in it without opening up the door or keeping tally on a nearby slate board. Enter the Arduino.
He wanted to make something completely non-invasive to the machine (phew!) while using as many parts he already had as possible. The result is a simple circuit that uses an ultrasonic sensor mounted inside the machine to ping the depths, and a Nano in a nifty 3D printed box up top to do some math and display the number of cans remaining as a simple bar graph. The sensor reads one bay, and the code multiplies by two to get the total. It was touch and go there for a minute as he wasn’t sure that the HC-SR04s would get a good response from the cylindrical cans. Not only did they give a good reading, the first test was quite accurate.
[Chris] recently finished Mk. II, which replaces the momentary (and the Coke logo) with a second HC-SR04. The first version required the push of a button to do inventory, but now he simply walks up to the machine and knows at a glance if it’s time to make a beer run.
Okay, so maybe you don’t have cool old Coke machine problems. But surely you can find something that needs pinging, like an inconvenient rain barrel.