I'm trying to diagnose a problem with a MaxSonar sensor. I'm using pulse width detection, but in a free-running state (i.e., I don't toggle the RX line high/wait 25 microseconds/low/wait 25 microseconds each time I take a reading). That's because I don't have enough free pins on my Arduino to control the RX line.

When I run my project off of a laboratory/bench power supply everything works exactly as I expect. Objects are detected when they come within a defined horizon, and lost when they move beyond it.

When I run the project off a wall wart, an object will be detected successfully, but once it is, it's never seen to leave (i.e., the sonar sensor is reporting that something's within the horizon even when nothing is). If I cycle the RX line low/high manually (i.e., by pinning it to ground and then to +5V), and leave it pinned high, the lack of an object within the horizon gets detected. But once I try to repeat the object seen/object departed cycle, the sensor once again can't detect the departure.

This sounded like noise on the line. But putting a 0.1 uF capacitor across the MaxSonar board's power supply pins didn't solve the problem. Neither did putting a 1000 uF capacitor across the output from the wall wart.

Normally I'd conclude you have to cycle the MaxSonar's RX pin to use the sensor. But that doesn't square with everything working fine off of the laboratory power supply. Then again, neither does the persistence of the problem after putting a big capacitor across the wall wart output.

I'd be interested in thoughts or suggestions as to what might the problem, or what I might try to work around it.

Thanx for the offer, Tom. But I think I've solved the problem. There's a more detailed discussion in a subsequent thread I opened, but this is the gist: I purchased a model with a wide detection envelope because I need to sense people standing anywhere along a five foot span four or so feet from the sensor. The sensor is mounted in a position where a hardwood floor is just at, or slightly beyond, the detection envelope.

When no observer is present the sensor occasionally senses the hardwood floor. Based on what I saw when I put the sensor output on my scope this happens once or twice out of every 10 scan cycles. For the other 8 or 9 cycles the distance reading is maxed out. Unfortunately, those one or two "spurious" results were enough to trip my detection algorithm.

I fixed the problem by angling the sensor up, away from the floor. I also changed the algorithm so that instead of reporting the median distance of a series of 7 or so observations, it reports the maximum distance observed. For my application that works better than the median approach.