Connect with us

ultrasonic distance measurement using 89c51

Discussion in 'Electronic Basics' started by chetanthegreat, Feb 4, 2007.

Scroll to continue with content
  1. Hey folks!
    I am set out to build an ultrasonic distance
    measurement module using 89c51.
    The range I hav in my mind is about 1 inch to say 25 inches. Is the
    speed 89c51 offers enough for such kind of ventures? If not what would
    be the solution? Also some help regarding which trasducers to use
    would be welcomed.
    Regards!
     
  2. John Fields

    John Fields Guest

    ---
    The velocity of sound in air is about 1100 feet per second, which is
    about 76 microseconds per inch. That means that for a two-way path
    of 2 inches you've got 152µs to chop up into slices thin enough to
    get the resolution you want.

    Assuming that you're going to use one of the internal timers to do
    the time measurement, that's going to depend on how fast they can
    run and the frequency of your clock source. That data should be
    available on the data sheet.
     

  3. Just to be a little clear(maybe for my own benefit than others) is that
    speed of sound through air is 344 m/s = 13540 in/s. (it doesn't mater how
    far the distance is except for atmospheric effects and such)

    Assuming a resolution of x in, one has 13540/x hz. So if you want an
    accuracy of 1 micron = 1/1000 in then that is 1.35*10^7 or 13 mhz. There is
    going to be a point where its useless to get a faster clock but I have no
    idea what this is.

    Thats pretty resonable for the accuracy. Ofcourse I doubt one could get that
    accuracy but maybe.

    I'm not sure how accuracy one can do this using passive components but maybe
    its worth a shot? If one can get a precise current source and charge up a
    capacitor and then read the voltage precisely then the voltage will be
    proportional to the distance(charge rate would depend on C and R which can
    be used to keep the voltage in range of an ADC if needed).

    Also, since your distances measured is fairly short maybe you can use an
    laser? (not sure if it works with your application but I thought I'd mention
    it. )
     
  4. John Fields

    John Fields Guest

    ---
    1 micron = 1E-6 meter, not 1E-3 inch
    ---
    ---
    If it's pretty reasonable then why do you doubt if anyone could get
    it?

    If you wanted an accuracy of +/- 0.001" out of 2 inches, that's
    +/- 0.05%, which I think is highly unlikely to be attainable since
    the air temperature, pressure, and humidity would have to be known
    to , say, twice that accuracy in order for the reading to be
    believed.

    I think something like +/- 5% is achievable, so that comes out to
    0.1" for a 2 inch path, which is 7.6µs.

    Assuming a hardware counter with enable gated on by the transmitter
    and gated off by the receiver, its clock should be running four
    times faster than 7.6µs, or 526.316kHz, and for a 25 inch target
    would need to be 9 bits wide
     
  5. Stef Mientki

    Stef Mientki Guest

    don't forget that the accuracy in this practical case is mainly limited
    by the bandwidth of the ultrasonic transducer,
    which isn't much at 40 kHz (and can't go much higher than a few hundred kHz).
    Or you can use special tricks to create US,
    like electronic generated sparks (works great)
    and use high frequency US receivers.

    Stef
     
  6. John Fields

    John Fields Guest

     
  7. yeah, I ment a mil ;/ Was converting from speed of light in m/s to in and
    guess I got the units mixed up.

    I never said its reasonable. I said its resonable for accuracy. I guess YOU
    didn't CARE to read the SECOND SENTENCE?

    Yes, but you do not know the conditions in which the device will be used so
    this is all speculation. You might be entirely right. I was just trying to
    give him an estimate on the clock speed that he asked for. What it does show
    is that its entirely reasonable because its not like 13Thz or something.
    13Mhz for a mil accuracy is pretty reasonable. This means that should easily
    be able to get it within reasonable conditions. (I mean get within good
    accruacy, maybe 1/100 in)
     
  8. Chris

    Chris Guest

    Including time for the echo return, sound takes about 170us per inch.
    I'd assume you can get reasonable accuracy with just about any uC
    timer.

    I'd guess your biggest difficulty is going to be with your minimum
    distance. It's going to be difficult to separate sensing the chirp
    echo from the chirp itself at that distance. If you were to change
    your specs to, say, 4" to 100", it will be a pretty simple project.

    If you're looking for an easy, "spam-in-a-can" ultrasonic setup, you
    could do worse than the Parallax "PING))) Ultrasonic Sensor". It will
    give you the whole thing (transmitter, interface circuitry, and
    receiver) for less than $30 USD. Just hook up one bidirectional I/O
    pin from your uC, and you're ready to program. This is a pretty good
    deal. And if nothing else, you might want to take a look at it to
    give you some ideas.

    http://www.parallax.com/detail.asp?product_id=28015

    Of course, if this is a school project, you'll have to make the
    interface circuitry on your own.

    Good luck
    Chris
     
  9. Stef Mientki

    Stef Mientki Guest

    I'd guess your biggest difficulty is going to be with your minimum
    the short distance problem can relative simply be solved,
    by a piece of cardboard, foam or whatever blocks sound,
    place it in such a way,
    so half of the soundwave has travel distance x,
    and the other half of the wave has distance x + half wavelength.

    cheers,
    Stef Mientki
     
  10. Chris

    Chris Guest

    Hi, Stef. Underpromise, overperform. I'm thinking the OP might be
    looking at doing a school project. As a practical matter, it is
    usually difficult to get close-in measurements with standard send/
    receive 40KHz transducers. I'm hoping he can tweak his project spec
    to make things easier for himself.

    But if not, it's not outside the realm of possibility, as you
    mention. It's just more difficult. Class projects should be
    straightforward if at all possible.

    Cheers
    Chris
     
  11. John Fields

    John Fields Guest

    ---
    Not at all. What I was pointing out was that in order to be able to
    attain +/- 0.05% accuracy (your +/- 0.001" example) environmental
    conditions in the sound path would have to be known to an accuracy
    of +/- 0.025%, which is equally ridiculous.
    ---
     
  12. You can be very annoying John. I was talking about the clock speed only
    since that is what he asked. If we were dealing with light then it would be
    on the order of 13 THz instead of 13mhz for the same accuracy. (hence even
    at 1000 times worse accuracy your still dealing with a 13ghz clock.)

    You seem to read what you want just so you can make a point that doesn't
    exist. (I never claimed that one could get accuracy of 0.05% in the real
    world)

    My claim is simply to give a reasonable upper bound on the clock speed for
    accuracy given everything else is ideal. When it is computed it is
    perfectly reasonable. Do the same with the speed of light and it is not.

    WHAT DOES THIS MEAN? It means he can use a 20mhz clock and not have any
    issues(except maybe one of latency but thats not the clocks fault). 20mhz
    clocks are easy to come by but 13Thz clocks are not.

    You seem to think that I am saying that it is reasonable to actually get
    that type of accuracy in the real world. I assume you do this for attention
    or to feed your ego because you ignore my statements that say its probably
    not.

    http://scitation.aip.org/getabs/ser...00073000010003671000001&idtype=cvips&gifs=yes

    They seem to get 0.05% accuracy.

    http://www.unisa.edu.au/seec/pubs/01papers/Two tone system.PDF
    http://www.sensorsmag.com/articles/0299/acou0299/index.htm

    Read the first sentence of the introduction and compute the accuracy
    requirements they are required to get. Ofcourse I'm sure you'll claim that
    these guys are fools and your the genius. (note that when they talk about
    the much larger accuracy on cm's they are refering to the robot and not the
    ultrasonic senser)

    You realy need to stop making such a fool of yourself. When you claim that
    such things aleast get them right. You think such things are impossible AND
    THEREFORE THEY ARE!!!

    Please, just because you think it can't be done doesn't mean it can't. This
    is not to say that it can't but instead of presenting facts you present your
    opinion as fact. I doubt you have ever messed with an ultrasonic sensor yet
    you seem to know all about them. Oh, ok. Maybe you have messed with them
    but since you couldn't get accuracy better than 10% it means that it can't
    be done any better, huh?

    My original post stated nothing about the real world accuracy of a
    ultrasonic sound system but only about the clock speed needed to obtain it.
    Instead you start talking about how in the real world one can't get that
    accuracy. Hey!! GUESS WHAT!!! I EVEN MENTIONED THAT IN MY ORIGINAL POST!!!
    You seem to pick and choose what you want to read and it happens all the
    time. Sheesh sometimes I doubt your sanity John. I used to think you were
    someone intelligent but I'm not sure if its an ego trip or maybe your just
    not as smart as I thought. That or maybe you need new glasses?
     
  13. John Fields

    John Fields Guest

    ---
    You're a liar. Here's his post, in toto:

    <OPEN QUOTE>

    Hey folks!
    I am set out to build an ultrasonic distance
    measurement module using 89c51.
    The range I have in my mind is about 1 inch to say 25 inches. Is the
    speed 89c51 offers enough for such kind of ventures? If not what
    would
    be the solution? Also some help regarding which transducers to use
    would be welcomed.
    Regards!

    <CLOSE QUOTE>

    Where does it say anything about clock speed? It doesn't. He asks
    if the µC is fast enough, which is what you should have addressed.

    In order to come up with an answer for that question you'd have had
    to look a little deeper and figure out what it is that needs to be
    happening while that acoustic pulse is making its way to the target
    and back, and to do that you'd need to know a little bit about the
    architecture of the 89C51. Specifically, what's the relationship
    between the input clock and the instruction cycle times and is there
    enough time in there to allow you to accumulate 0.001" ticks.

    Is there?
    ---
    ---
    If frogs had wings...

    We're not dealing with light, we're dealing with sound, so all of
    that diversionary crap is just that. crap.

    And get the suffixes right if you expect to be taken seriously, LOL!
    ---
    ---
    Sure you did.

    By suggesting that he use a 13MHz clock in order to get 0.001" thick
    slices of something that propagates through air at Mach1, you
    intimated as much.

    What you _didn't_ say was why that +/- 0.05% accuracy wasn't
    obtainable. You _guessed_ that it might not be, to your credit, but
    you gave no reason for your guess, which is the same sort of garbage
    science you railed against in another thread.
    ---
    ---
    See earlier 89C51 timing issues...
    ---
    ---
    See earlier "If frogs had wings" paragraph.
    ---
    ---
    That might seem to be the case to a neophyte lacking in reading and
    writing skills and unskilled in mensuration, but 0.05% _resolution_
    is not the same as 0.05% _accuracy_.

    Shall I explain the difference to you or would you rather keep your
    tail between your legs and hit Wiki?

    Also, they get that resolution in isothermal air (that means it's
    the same temperature everywhere in the flight path of the signal)
    and they get it using BPSK _and_ TOP. Judging from the primitivity
    of the OP's post, his application was strictly TOF.
    ---
    ---
    That application uses a phasing technique. I didn't care enough to
    read whether they also use TOF since the OP's application was,
    ostensibly, for TOF only.
    ---
    ---
    That's just a bunch of stuff about air acoustics that everybody who
    does air acoustics knows anyway.

    I guess you didn't know that.
    ---
    ---
    Oh, you want to play that way, do you?

    OK, moron, _They're_ not each fools, you are.

    They're doing cutting edge R&D and all you're doing is looking for
    ways to try to keep everyone from discovering what a stupid **** you
    really are.

    I don't think you've got the resources to hide that fault. Do you?
     
  14. Rich Grise

    Rich Grise Guest

    I'm wondering if, in a case like this, "chirping" rather than "pinging"
    might be of use. I've read that they do that for doppler radars, albeit
    this isn't a velocity measurement, but if, say, you sweep the transmit
    frequency, would the phase relationship between it and the received
    signal be useful? I would think it would take a ceratain amount of
    analog processing, but how hard would it be, and what kind of resolution
    could you get, or am I in fantasyland? ;-)

    Thanks!
    Rich
     
  15. Stef Mientki

    Stef Mientki Guest

    The idea is very good and even works in practice, but it's not very practical ;-)
    The basic idea to increase resolution is always to increase the information content,
    i.e. increase bandwidth and increase measurement (correlation) time,
    because information content = bandwidth * time.
    The main advantage of chirp or whatever unique modulation you want to choose,
    is that you can spread the power (=information) over time,
    giving you a much better signal to noise ratio (e.g. ADSL makes use of this).
    For ultrasonic transducers chirping can increase the bandwidth too,
    but because they have a very high Q, this is not very effective.
    One of the posts in this thread mentioned an article of a bifrequent modulation,
    showing indeed a very high resolution.
    In a lab environment I once managed to realize (with normal 40 kHz transducers, but very well
    damped, and phase detection over several periods) an accuracy of 1/500 of a wavelength.
    Unfortunately this is the short term stability and the long term stability (hours) is much worse.
    With sparks as the transmitter (very short and hard ultrasonic pulses), you can achieve about 10um
    accuary (this was used in a commercial products about 20 years ago: the first high resolution
    graphical tablets).
    But for simple electronics, the ideas behind MAXSONAR are quiet good. Although I would use 2
    transducers with a mechanical splitter, to increase close range, like done here
    http://oase.uci.kun.nl/~mientki/dat..._prototyping/rapid_prototyping_us_ranger.html
    If you can get hold of ultrasonic transducers of a 100..200kHz (higher has to much damping in air),
    you can easily increase your resolution (the bandwidth of these transducers is much better).

    cheers,
    Stef Mientki
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-