Questions on ultrasonic distance finder


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    what hardware setup are you going to use?

    i have built one of these before. ive attached a pic if you are interested.

    the main problems i faced was to do with the detection of the reflection. i never managed to get the adc to detect a reflection, so i used amplification circuits and a comparator to detect the reflection and trigger an i/o pin.

    the detection part of my circuit was from this site:

    http://www.best-microcontroller-proj...pic-sonar.html

    I found, however that the transmitter side of that one wasn't great. the best result i got was from using an inductor to build up much larger voltages across the transducer.

    My results were good. I get +/- 1cm at most ranges. By changing the sensitivity of the detector I can shift the effective range. If i set it more sensitive, i get longer range but lose ability to detect short distances. If i set it less sensitive i can get shorter ranges but not long range.

    6cm may be tricky tho. the shortest range ive managed is around 15cm.

    I generate the pulse for 150uS. I found that for my purposes (not needing short range stuff at all - just ranges over 1m), i then wait about 1.5mS before looking for a reflection. Its best to experiment with different times to get the best result for you.

    Hope some of this helps you.
    Attached Images Attached Images  
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Angry

    Hi, Kamikaze,

    What a Bins to download the files from that site !!! ...

    and , in the end ... you get a code to download the " LCD + Keyboard " project ...

    Someting to correct, I wonder ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Not sure about that. I didn't use any of the code from that site - i wrote my own in PBP.

    All i used from that site was the receiver amplification/detection part of the circuit shown there.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Hi Kamikaze,

    I guess the answers to my questions is test and evaluate, in this case I am on the right track.

    I started to design arround This guy's project but I was never able to observe what I was expecting on the scope for the input amplification stages and I was not completely understanding what I was doing so I've decided to start with the basics and found this link from Les Johnson which is really basic and I am having some difficulties understanding 100% of his code but I do get the basics.

    I am pretty close to a newbe with PBP Pro and PICs, but I am really good at playing sounds on piezzo and blinking LEDs and I think now I am good with LCDs so like I said, I have a long way to go.

    I was wondering if it is better to do more hardware and less code or vice versa but I guess the opposite is better since it is faster to change code than it is to change hardware, I am just not sure yet where I have to draw the line.

    I am presently intensivelly playing with timers and interupts and I must say I am having a lot of fun trying to understand but as I am doing this on an average of 16 hours per day, I should get the hang of it in no time.

    While I am at it maybe if someone can explain something; in my code I have
    Code:
    CMCON = 7                   ' Disable comparator
    INTCON = $80                ' Disable interupts
    T1CON = 0                   ' Timer1 off, prescaler 1:1
    and then I do this:
    Code:
        
    TMR1H = 0:TMR1L = 0
    T1CON.0 = 1
    PAUSEUS 1
    LCDOUT $FE,$80,"TMR1H = ", dec TMR1H
    LCDOUT $FE,$C0,"TMR1L = ", dec TMR1L
    I get: TMR1H = 4 and TMR1L = 23

    What I understand from the datasheet is TMR1H cycles when TMR1L overflows so the value I am getting is actually:
    4 x 65535 +23 ?

    how did it get do far with PAUSEUS 1 ?

    Then if I do PAUSEUS 2
    I get: TMR1H = 4 and TMR1L = 24

    I am confused!

    Mike

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    TMR1H increments when TMR1L overflows at 256. So its 4x256+23.

    Keep in mind that the timer will run at 1/4 the frequency of your main oscillator.

    edit: also, pauseus 1 will not result in a 1us pause because pauseus has a minimum pause time. have a look at pauseus in the PBP manual.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Do you really have to built it yourself?

    Look at the http://www.robot-electronics.co.uk/a...c_Rangers.html

    Once I had to built that ranger in 1990 but then I could not find ready made modules.

    After a few year I tested the modules of the above link and was surprised.

    First of the idea to drive the Tx US transducer by the well known MAX232 chip (it can produce fast +/- 10 volts of pulses!) and second by its simplicity and performance.

    Ioannis

  7. #7
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Well the main reason why I want to build it myself is to learn everything about it, I really like the challenge and when I go to bed just about every other day or so I sleep well because I like the feeling of having learned something new.

    Now trying to calculate and figure how I got this result on my display is probably going to keep me up for a few days because even after Kamikaze's response I am still confused. Maybe it's all about the timing differences between the speed my brain works and the speed of a PIC at 4MHz.

    Or maybe I am trying to calculate something that is uncalculatable!

Similar Threads

  1. Ultrasonic distance sensor with PIC16F84A
    By MrRoboto in forum mel PIC BASIC
    Replies: 3
    Last Post: - 29th June 2009, 09:01
  2. Sharp GP2D12 Range Finder???
    By Gixxer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th December 2007, 09:21
  3. sensor ultrasonic 8051&PIC
    By hd_uni_pro in forum Schematics
    Replies: 1
    Last Post: - 13th September 2006, 12:58
  4. ultrasonic sensor
    By PoTeToJB in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th May 2006, 20:26
  5. SRF04 Range Finder 16F628 R18iXL Board
    By Spindle in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th June 2005, 02:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts