Shop Stuff: April 2013 Archives

MPXV5004G Breakout board

| Comments (0)
A small project to practice milling PCB boards. This board holds a MPXV5004G pressure sensor. It will eventually be part of my furnace monitor - it will detect the pressure (vacuum) in the fan housing part of the furnace. As the furnace filter plugs up, the vacuum will increase (pressure will decrease). The furnace monitor will correlate the pressure to the activity (because different fan speeds will produce different pressures). When the pressure is low enough, the furnace will tweet me that I need to change the filter.

MPXV5004G pressure sensor breakout board

The settings for pcb-gcode that I used for this project were:

Etch depth: -0.004
Isolation Default: 0.01
Isolation Max: 0.02
Isolation Step Size: 0.007
Etch tool size: 0.01
Feed rate: 10 IPM

Cheap imported single sided PCB boards from DX.

Troubleshooting a (cheap) sonar unit

| Comments (0)
One of my silly dream projects is a steampunkish range finder. The key part is a sonar unit. There's lots out there - I found an HC-SR04 on eBay for $2 shipped! I couldn't go wrong (or so I thought).

After a few weeks it arrived, and I promptly wired it up to my arduino and grabbed some sample code and ..... nothing. Hmmm... The code talked about having added / removed / tweaked, so maybe the code was faulty. I tried a different code sample, another one and one more before concluding that the unit must be a dud.

But I could not let it rest. I could order another one, but that is not the hacker way.

Then I remembered my XProtolab 'scope! It took some fiddling - had to learn how to configure the trigger setting. Even added a bit of extra code to send a second pulse 1000 micro seconds after the first pulse - just to make sure I was seeing things right. Eventually I got the scope working, and here is what I saw:


Both trigger AND echo were responding with the echo pulse, and both the trigger AND echo lines seemed to be seeing the trigger pulse! Some experimenting with the pins used on the arduino and even disconnecting the trigger all together confirmed that internally the sonar unit was somehow joining the two lines. And more importantly, the echo signal was very weak - too weak for the arduino to detect.

I tried to boost the signal by using a NPN transistor (2N3904), but clearly had it wired wrong. I fed the weak echo into the base, and sent the emitter into the arduino. The result was a weird capacitance coming off the trigger pulse.


After consulting with a friend, I was informed "If you feed the signal into an npn base the signal voltage out of the emitter can never be higher than the input. You need to take the voltage off the collector and invert it".


My first attempt was on the left. Hmmmm... okay, so I flipped the resistors around (schematic on the right) and took the voltage off the collector and sure enough it was inverted! (I removed the second pulse at 1000uS)


Now, I suppose I could have added another transistor to invert it again, but it was much easier changing the code from:

ms = pulseIn(EchoPin, HIGH);


ms = pulseIn(EchoPin, LOW);


"Fixed" sonar unit

And now my range finder works!!!! Yeah!!

I learned a bit more about transistors, and how to use my scope!

A $2 part and a couple hours of trouble shooting is not a bad price to pay for some edumacation :-)