i just bought very inexpensive long range ultrasonic range finders, but they come just plain with their 2 pins hanging out, no pcb, no nothing. I was woundering how to hookem up to an arduino. My only guess was that i connect 5v to one side to an analog input, but i don't want to break them so input would be apreciated.
They came in 1 set of 2 finders and i got them from here :
and also, i'm wondering what i need 2 for?
like 2, i use one as an output and 1 as an input? or can i use both at the same time? i'm not quite sure how they work, but they were a good price lol...
These are just the ultrasonic sensors and not a complete range finder. You could build a complete ranger finder with an Arduino along the lines of what was done here:
see the srf04 schematic on the link I pasted above. You need to feed 40khz into one, then amplify the other and listen for a reply. The time between transmission and reception gives you distance, based on speed of sound.
For anyone who hasn't yet bought their range finder.....
I bought two from Pololu.com... very reasonable shipping terms, by the way.
a) Pololu - Maxbotix LV-MaxSonar-EZ0 Sonar Range Finder MB1000
Ultrasonic. Really cool. Multiple outputs, but for Arduino the analog output is the easiest to use.
$26
Measures from 6 inches to 254 (6.4 m), 1 inch resolution. (Things closer than 6 inches report as at 11 inches)
b) Pololu - Sharp GP2Y0A21YK0F Analog Distance Sensor 10-80cm
Infra red beam system.
$10
Detection range of 4" to 32". An analog voltage indicates the distance. (I haven't played with this one yet.) I'm awaiting delivery of some connectors... You can just solder wires to the device, but I thought I'd do it the "nice" way. Pololu doesn't have them. I have a few on the way. Send PM if you want one or two, $4 or GBP2, to USA or UK address.
I have additional questions about programming the arduino to read the ultrasonic range finder. I have one that measures up to 15 ft and I only know enough about writing the loops to read HIGH and LOW. How does the information from the ranger finder tell the arduino chip the distance an object is at? I was thinking I could be less ten or equal to, or from one number to another, but I'm not sure if it is going to give back information in integers. Then of course once I know how to program the INPUT I'll need help with the OUTPUT information but I think I'll have to go to the software forum for that?
Thanks for any help.. I tried the links above and seem to just keep finding advertisements
so i have to buy a crystal that is at 40 khz, feed power through it, and connect ground to the other side, then by some amplifier and connect it to the other range finder, and pump power through it also?
and keep them perfectly level next to eachother?
will it matter how close they are to eachother, like 3 inches next to eachother, or 5 inches?
hoepfully i dont have to replicate that exact shcematic, cuz that is really confusing....
Nope, just generate a signal using one of the timers or a separate microcontroller or whatever. You could probably even do an oscillator since the transducers act like ceramic resonators tuned to 40khz already, although it would be difficult getting a nice sharp pulse.
, feed power through it, and connect ground to the other side, then by some amplifier and connect it to the other range finder, and pump power through it also?
yep
and keep them perfectly level next to eachother?
They don't have to be perfectly level, see the beam pattern in the datasheet to find out how much leeway you have.
will it matter how close they are to eachother, like 3 inches next to eachother, or 5 inches?
That depends entirely on your detection circuit. You get a huge pulse during transmission from direct coupling, then the received pulse is much lower, so you need to be able to ignore one and pick up the other. If you mechanically isolate them with rubber mounts and foam and stuff, the direct coupled pulse will be much smaller and easier to ignore.
Another thing to note is that the received pulse will get weaker and weaker with both distance and the smallness of whatever the signal bounces off. The srf04 uses a very clever method to start off with a very low sensitivity and increase it over time to compensate.
All these considerations are why people usually buy a premade unit that simply gives you a digital high as long as it's waiting for the reply so you can just time it and not have to worry about the analog stuff.
ok, that seems pretty simple... but the question i have for using the microcontroller is : how would i know what 40 khz is in delays? is it just plain old 40 milliseconds, so all i have to do is write delay (40) and then turn it off and on every 40 millisecond delay?
and for the amplifier, will any amplifier work? like any amplifying chip, or do i need a sepcific one, or a kind of chip? also, can the arduino maybe amplify it, by possible multiplying the analog input coming in by a value?
btw, thanks alot for the help, and sorry i havent posted here, i dident notice there was a reply lol
ok, that seems pretty simple... but the question i have for using the microcontroller is : how would i know what 40 khz is in delays? is it just plain old 40 milliseconds, so all i have to do is write delay (40) and then turn it off and on every 40 millisecond delay?
period = 1/frequency.
1/40KHz = 25uS (uS is microseconds).
period = Ton + Toff, so for a 50% duty cycle, Ton = Toff = 1/2 period = 12.5uS * 16MHz = 200 clocks.
you'll have to use a PWM output for that sort of delay.
and for the amplifier, will any amplifier work? like any amplifying chip, or do i need a sepcific one, or a kind of chip? also, can the arduino maybe amplify it, by possible multiplying the analog input coming in by a value?
You could theoretically use an analog input, but since its sensitivity to high frequency low level signals is basically abysmal, you would get only very short range readings, maybe a foot or two, and that's with lots of tweaking and messing around. You really need an analog amplifier like an op-amp to boost that signal up, and may as well do simple thresholding after all that trouble, just like the SRF04. Then, you simply send a ping, and time how long it takes to get back. You'll need an op-amp with decent gain at 40khz, so 741 and LM324 are no good (only 20dB gain at 40KHz), and something like LM833 should be better (50dB gain at 40KHz)
lol that was like Spanish to me ( i'm passing Spanish with a 65... ), but i think i get the general idea:
so i need to make a delay that is 25 microseconds, so i can just use delay microseconds or however the command go's, and then i need that chip ( LM833 ) you talked about. That's pretty strait forward. And once i have the chip hooked up to the other range finder, do i hook up the amplifier's output to the arduino analog input?
or digital since all it needs to know is when a value is returned?
i'm sure i'm forgeting to ask something, but i'm super tired so that's all i can remember right now lol
thanks for all the current help, it's very usefull ,and if it turns out to be this easy, then i will definitly reccomend these range finders, becuase theyre cheap and are long range! ( cant say from fact since i dident recieve them yet...
12.5 microseconds delay. The period is 25 microseconds, and there are 2 transitions in the period. Since it's so short, you must use a PWM output to generate the frequency. doing it in normal code will introduce too much jitter. see the atmega168 datasheet for how to set PWM outputs to particular frequencies.
Connect it to a digital port, preferably with input capture feature so you don't get interrupt latency in your readings. The transducer itself will filter out most other frequencies for you, and like I said before, the analog ports are useless for short pulses.
The SRF04 I linked is a great example of an ultrasonic ranging module, read its article closely
Triffid Hunter posted a link in his first post in the thread with some details of a range finder using the items you have.
He has since gone into more details and it seems you are now understanding what is required.
Might I suggest you look at his link again - that solution has some good ideas. For starters, in order to get a longer range you need to apply a larger voltage across the pins. The designer has used a MAX232 equivalent IC (usually used for serial communications) to drive the sensors harder than just using 5V from a MCU. They also use the same max232 chip to generate a -ve supply for the amplifier.
All the blocks needed are in there - it'd be worth looking through again.