Mounting, SR HC04 ebay UltraSonic?

Im wondering if any of you have a decent method for mounting these things, the screw holes are so small not even the smallest of stand offs I have will work with them, not to mention the resistors are so close to the screw holes!

Ive all but given up on using the screw holes to mount them, but have been looking around at erector pieces, jb weld etc.. I was thinking about maybe cutting two holes in plastic or metal and sticking the transducers through, but I dont have a hole saw that small. I really do not want to resort to some ghetto method involving zip ties and tape.... I have 5 of these to mount on my sting ray. Im almost wishing I would have bought the 3 ping Ping kit for the stingray, when I had the chance.

Anyways Id love to see any examples you guys have used to mount these cheap UltraSonic sensors.

I enlarged the holes slightly with a small needle file to accept 2-56 screws. Made the standoff from a 3/16" OD nylon spacer, notching one end slightly to clear the resistors. Files, screws and spacers all available at my local Ace Hardware.

There are a couple different variations of these sensors floating around on ebay. Some have 2 screw holes and others have 4. Also, some have a green solder mask and others use a blue solder mask. Of course they all are using the same part #....

I've been able to carefully enlarge the holes on some to use #2 hardware as suggested. Another method I have used it mounting them through a plastic panel. For drilling the holes in plastic I have a few different unibits. If you don't have any of these you may want to invest in a set. They are very handy to have around. These are a must for working with some plastics as they easily and cleanly cut holes without damage. If you used a regular drill bit on plastic they can catch and you may crack or break the plastic. One source for inexpensive ones to try are here:

I wouldn't use JB weld to mount these sensors. For the couple times I needed glue I've used GOOP instead. I like JB weld for certain applications but GOOP seems to work better for these and if needed you can remove it. Although it has a funny name it is great for lots of applications.

Intresting, maybe I will pay Home Depot a visit. I found a few screws the size I needed in my scrap Hardware bag, but I figured this stuff was much to small to source at the hardware store! I thought of reaming the holes also but didnt think it would make to much of a difference.

I do have a half inch unibit, the transducers are a bit bigger than that though. I had a 1 inch too, seems as though its been lost. I have another idea involving a proto board backing I may give a shot too.

Like i said i was just intrested to see what others came up with, im using the blue ones with two holes.

Another option would be to try some heavy gauge copper wire which you could solder into the holes. You could have it come straight off the back and then at the end bend a loop and then bend that 90 degrees so you could put a screw in that.

I think I would only use a spade bit on wood. I'm not sure what other materials it would be good on except for foam. If I were drilling plastic then I would avoid that bit. I would expect that to crack plastic.

Erco probably has a whole set though and would have no issues using them to mount these sensors on one of his plywood robots.....

@RobotWorkshop - It will work with a ==light== touch. I primarily use the spade bit on PVC (solid and expanded), though I've successfully used the bits with styrene sheet. Again... high speed and a very light touch!
The spade bit wouldn't be my first choice, but ya gotta go with what ya have. Not a recommendation, just a suggestion of what "can" work. :-)

This picture kind of show one of these sensors attached to my small quadcopter.

(The ultrasound is pointing down and has small camera mounted on top of it.) Unfortunately these motors produce a lot of ultrasound noise and the setup wasn't useful (at least not useful when the motors were on).

Sorry, I forgot about the "no ghetto" requirement.

Double sided foam tape is great to attaching circuit boards so is Polymorph.

Lol the first thing I though was I should order some polymorph. I just reamed one out and got a 4/40 screw through it with stand off, im gonna test it out in a bit and then use a rubber washer or something on the stand off, if the screw isnt shorting out c3, well see if it worked or I trashed a sensor

@RobotWorkshop - It will work with a ==light== touch. I primarily use the spade bit on PVC (solid and expanded), though I've successfully used the bits with styrene sheet. Again... high speed and a very light touch!
The spade bit wouldn't be my first choice, but ya gotta go with what ya have. Not a recommendation, just a suggestion of what "can" work. :-)

Hello Amanda,

You're right. If your careful I suppose it could work. I can see where it should do ok on the expanded PVC. Some if the other plastics can be pretty brittle and for those I've found the unibit to be the safest way to put a hole in there.

@Duane ok im sitting down now to test my pile of sonar sensors and the one Ive modded. I tested one on a Bs2 with no problems. I noticed you wrote a propeller driver for these HC04s, but in the thread you mentioned you were getting wacky readings? Is this still the case? Just so I know if something like this goes awry its the driver and not the sensor?

My plan is to connect the trig/signal plans togather and try to get it working with a standard ping driver but well see about all that...

@Duane ok im sitting down now to test my pile of sonar sensors and the one Ive modded. I tested one on a Bs2 with no problems. I noticed you wrote a propeller driver for these HC04s, but in the thread you mentioned you were getting wacky readings? Is this still the case? Just so I know if something like this goes awry its the driver and not the sensor?

My plan is to connect the trig/signal plans togather and try to get it working with a standard ping driver but well see about all that...

Are you using the same sensor when testing on the Prop and BS2? I've had several of the cheap sensors not work but I haven't checked them with the BS2 to see if they work with it.

I doubt connecting the trigger and echo pins together will work. I'm not sure but I'd think the echo could cause the sensor to self trigger. I don't think I've tried this but I thought someone else had. Let us know how it turns out.

I have tied several echo lines together so instead of taking n * 2 I/O pins, the sensor uses n + 1 I/O pins. I think I've done this with four sensors at once (using five I/O pins). I'm not sure if I posted my modified driver that uses multiple sensors. If I haven't posted it yet, I'll find it and post it.

If a sensor doesn't seem to be working correctly, try getting rid of the resistor on the trigger line. I know I had problems with high resistor values (4.7K?) on the trigger line.

If you purchased your 5 sensors off ebay, chances are one of the 5 wont work. Odd Bit Collector mentioned a 20% failure rate on the sensors he's ordered. I've also had 20% of my sensor not work.

I had them all mixed up in a box I have no idea which one I originally tested, if I have issues ill just go back to the Bs2 and test. So are you telling me you bad readings were from a faulty sensor and too high of a resistor, not 3.3v comm with the sensor. The issue in the thread sounded a bit like it could be the 3.3v communications.

If I get anywhere with tying the echo and trigger pins together ill let you know, Erco said that this worked and linked to people using picaxes doing it with a 1k8 resistor, ive also seen a lot of arduino write ups on doing this with 3 pins only.

Anyways I got the thing plugged in and your objects along with the ping sensors object. Ill get to work on this after I eat some dinner and let you know If I find anything interesting.

Duane I downloaded your code, then plugged in all my sensors to test them. All 5 seemed to be working correctly but I can have it totally stationary pointed at stationary items and the time will bounce between 800ms and 1100ms. It only flickers in to the 800s a few times, is this normal, do better quality sensors do this, i.e ping or the maxbotix you use sometimes.

Im sorry if this is a stupid question but is this where maybe you could implement a kalman filter to get more stable readings?

Duane I downloaded your code, then plugged in all my sensors to test them. All 5 seemed to be working correctly but I can have it totally stationary pointed at stationary items and the time will bounce between 800ms and 1100ms. It only flickers in to the 800s a few times, is this normal, do better quality sensors do this, i.e ping or the maxbotix you use sometimes.

Im sorry if this is a stupid question but is this where maybe you could implement a kalman filter to get more stable readings?

In my experience, when the sensors work, they work pretty well.

I've noticed a stray wire can get in the way of the sensor and causes a problem. You should also test the sensor with a very well defined target. If you pointing it at a wall that has a lamp in front of the wall, sometimes the lamp's echo may be strong enough to change the reading.

When I tested ultrasound sensors by pointing them up at the ceiling, I found they gave very consistent results.

There are lots of possible ways to filter the readings. I doubt you'd need a Kalman filter.

One filter would be to take several readings and throw out any that are far from the average. Even just averaging a few readings will reduce the problems caused by the bad reading (unless the bad reading is way off).

You could wait until three readings in a row agreed within a certain limit and only then accept the reading as valid.

Erco verifys that jumping the echo/trig pins with a 1800ohm resistor works with a bs2 and picaxe. I left the 1k and 10k resistors attached and tried to jump them with a 1k8 resistor, I used both your code with both pins set the same and then the ping code. Neither worked... I then tried to stick a 5k pot in there and adjust it, still no dice, a little more luck but nothing usefull. So im not really sure how you can do this while still protecting the propeller pins.

Ok so i did a bit more research on how this 1 pin setup works. Basically you have to pull down the pin as soon as you send the trigger, im assuming that none of the code ive been using does this, and thats why i cant get it working right, ill take a look at this tommorow.

One thing i was thinking, and this where i could be totally wrong as im not good with gates. But the trigger and echo are never hi at the same time right? If that is the case than maybe using a xor gate would be an option? They come in quad packages, so for those of using multiple sensors this may be a good option. Would it be possible to mux this with gates, more specificallay a xor. All i have are old 74LS packages but if if this is possible and ls gates are fast enough i can do a bit of testing that way too.

Intresting, maybe I will pay Home Depot a visit. I found a few screws the size I needed in my scrap Hardware bag, but I figured this stuff was much to small to source at the hardware store! I thought of reaming the holes also but didnt think it would make to much of a difference.

I do have a half inch unibit, the transducers are a bit bigger than that though. I had a 1 inch too, seems as though its been lost. I have another idea involving a proto board backing I may give a shot too.

Like i said i was just intrested to see what others came up with, im using the blue ones with two holes.

If they are the same ones I'm thinking of then the hardware that will fit native is #1-64. Tiny screws that I wouldn't wish on an enemy. I used a small drill press to enlarge them to #2-56 at least. ACE hardware is the best place to go if you need small numbers of fasteners. They have a much better collection of sizes and types than Home Depot. You do pay a significant price for the less commonly used sizes.

Ok so i did a bit more research on how this 1 pin setup works. Basically you have to pull down the pin as soon as you send the trigger, im assuming that none of the code ive been using does this, and thats why i cant get it working right, ill take a look at this tommorow.

How are you powering the sonar sensors? Are you running them at 5V or the 3.3V supply of the propeller? I think they are meant to be run at 5V.

With the sensor running at 5V and the Propeller I/O at 3.3V the trick with the resistor may not work the same at the Stamp or PICAXE which are running at the same 5V supply as the sonar module.

Unless you are running out of pins you may just want to live with two I/O pins per sensor. I'm sure you can find ways to consolidate the pins but it may add a lot more complexity to your hardware and code. At that point you'll need to consider if it is really worth it.

Unless you are running out of pins you may just want to live with two I/O pins per sensor.

I've used four of these sensors with five Prop pins. It requires a diode and I think there're also a need for a pull-down resistor with each sensor IIRC. I think I posted code to run four sensors at once. If not, I'm sure I have the code somewhere where I could find it (not that it would be hard for others to reproduce).

Im running them at 5v, just got my scope and LSA working been kinda of looking at the signals all morning. I think im just going to use an i2c I/O expander to cut down on the pins, I have some mcp23018s there just like the the 23017s except they have 5v tolerant pins and an open collector, so I think they will work like an LVC244 as far as being able to do voltage shifting.

Duane your just talking about triggering multiple sensors at once right? Thats not really what im going for, I need independent triggering of each. Also when you said you had to add pull downs was this for the multiple sensor technique or just in general? Im having a hard time with the readings on these things, I mean when I hit the celing or a wall its just fine up to about 8 ft or so as it should be, but when Im just throwing random object in front of them, some time I have to move the object about 30 degrees out of LOS with the sonar for it to pick it up and all kinds of funky things.

Duane your just talking about triggering multiple sensors at once right?

The shared line would be the echo line. Each sensor would have its own trigger line.

Also when you said you had to add pull downs was this for the multiple sensor technique or just in general?

Just when using multiple sensors. I'm pretty sure this was described in one of the other ultrasound threads. I think the thread was started by Martin_H and was about using multiple sensors with fewer pins. If you can't find the thread, I probably can.

Im having a hard time with the readings on these things, I mean when I hit the celing or a wall its just fine up to about 8 ft or so as it should be, but when Im just throwing random object in front of them, some time I have to move the object about 30 degrees out of LOS with the sonar for it to pick it up and all kinds of funky things.

Ultrasound does funky things. A nice hard wall will be invisible to ultrasound if the sound hits the wall at a shallow angle. Soft objects can also be invisible to ultrasound. Not really invisible, some things just don't return an echo. My S2 almost always runs into our couch since the upholstery doesn't reflect the sound.

I haven't played with these cheap ultrasound sensors as much as I've used a Ping and Maxbotix sensor, but I don't think the problems you're seeing are caused by these particular sensors but are just a limitation of ultrasound in general.

Because of these limitations it's very common to use other types of sensors along with ultrasounds to make up for the ultrasound's weaknesses. IR compliments ultrasound well. IR often sees what ultrasound doesn't and visa versa.

I found the thread about using multiple ultrasound sensors with the Prop. Post #19 has code I used to read from three sensors using four I/O pins. Following suggestions made on the thread, I was able to increase the number of ultrasounds to four (with five Prop pins) by using diodes in post #26.