You Can Never Have Enough 0.1 uF Capacitors

I had almost gotten my ultrasonic sonar detecting aquarium light controller to work when I ran into a weird problem: the hardware and program code worked fine in my desktop development/testing environment, but not in the “production” environment with the aquarium. In the latter situation I’d get all sorts of spurious distance results: the system would report nothing was present, then it would report an object was 5 inches in front of the sensor, then it would indicate something was 7 feet away, etc.

This was a bit of a puzzle. Why would the exact same hardware, software, sensor, cables, etc. work one place but not another?

At first I thought it was noise from all the pumps, ballasts and stuff in the aquarium. But connecting the sensor via a shielded cable (made from an old S-video cable) didn’t solve the problem.

Next I thought it was because I was using the sensor in a “free running” state, rather than commanding it to do a ranging, report the results, and then go quiet until the next ranging event was needed. But rewriting the Arduino sketch to do that didn’t solve the problem either.

Fortunately at that point I noticed that the test rig and software worked fine in the production environment…provided it was all powered off my laptop’s USB port. The Arduino can be powered that way, and it can in turn power a low-drain device like the MaxSonar sensor.

That turned out to be the critical observation. Slapping a 0.1 uf capacitor across the MaxSonar’s power and ground terminals solved the problem. Apparently the MaxSonar, like many other low power digital devices, is pretty sensitive to the quality of its power supply. And I guess my wall wart is pretty noisy!

The moral of the story, of course, is that you never know when you’ll need a small capacitor to short out some unwanted AC… 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *

Categories
Archives