Range Finder with Laser pointers


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Location
    Myanmar
    Posts
    11

    Unhappy Range Finder with Laser pointers

    Can Any one help me?
    I've a project to make range finder with laser pointers. I used some mathematics concepts. u can see my diagram . I've problem with cos and sin value evaluating? I used PIC16F628A. I used POT command to know the resistance. I wish to convert this angle value to cos and sine value. Can any one?
    Attached Images Attached Images  

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Range Finder with Laser pointers

    Welcome to the forum.

    Your project sounds very interesting. But I would change chips to one that has an A/D converter, and if you were concerned about accuracy, a 12 bit one. A PIC18 would make the math easier, and more accurate. Then maybe try to find a pot that gives 0 to max in 90 degrees.

    Sin and Cos functions in PBP are a bit limited in resolution. Darrel helped me with some cordic include files for both the PIC16 and PIC18 that give much more resolution, which I think will be important for your application.

    Since I don't know of a high resolution plain tan function, we are going to have to do this in two steps.

    You have a known A length, and a known angle.
    Cos(angle)=A / hypotenuse

    So to figure the hypotenuse:
    A / Cos(angle) = hypotenuse

    Once we have the hypotenuse, we can solve for:
    Sin(angle) = B / hypotenuse

    So changing the above around, we get:
    Sin(angle) * hypotenuse = B

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Range Finder with Laser pointers

    First of all you need to convert the pot resistance into degree (your angle theta). To do that use, you can use few points as:

    90 degrees position = Ohms
    60 degrees position = Ohms
    45 degrees position = Ohms
    30 degrees position = Ohms
    0 degree position = Ohms

    Use the above value to find the regression curve (use excel) . If the regression is acceptable then you have the formula for converting your Ohms value into degree, if not you will need a lookup table.

    Once you have the degree value of the angle of your laser pointer #1 (theta), extract the tangent and do this simple math: Segment B = Segment A/tan (theta)

    If you will suceed in getting the hypotenuse (as suggested by scalerobotics) then

    Segment B = SQR(( hypotenuse * hypotenuse) - (Segment A * Segment A))

    Cheers

    Al.
    Last edited by aratti; - 12th February 2011 at 16:17.
    All progress began with an idea

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Range Finder with Laser pointers

    Ooops, I forgot my tan.


    Tan(angle) = Sin(angle) / Cos(angle)

    So to solve for B:

    (Sin(angle) * A)/Cos(angle) = B

    One thing kind of cool about using the PIC18 cordic for this is that is performs sin and cos at the same time, and it just takes about 185 uSecs on the faster chips. So it can do it over 5000 times per second, while giving you a pretty high resolution result (from 0 to 30,000). Then you can use the PIC18 cordic to solve the hypotenuse with the atan2 function. This saves you from having to use PBPL for accurate square root.
    Last edited by ScaleRobotics; - 16th February 2011 at 15:37. Reason: cordic details

  5. #5
    Join Date
    Feb 2011
    Location
    Myanmar
    Posts
    11


    Did you find this post helpful? Yes | No

    Talking Re: Range Finder with Laser pointers

    Quote Originally Posted by serial_bug View Post
    Can Any one help me?
    I've a project to make range finder with laser pointers. I used some mathematics concepts. u can see my diagram . I've problem with cos and sin value evaluating? I used PIC16F628A. I used POT command to know the resistance. I wish to convert this angle value to cos and sine value. Can any one?
    Thanks very much Aratti and Scalerobotics. The nice ideas I got from u. But I'm weak in digital electronics . So I'd a problem with sin and cos value to evaluate. Also compiler is not appropriate with fractional values. I've seminor for this project at March 1st weak. So my minds are burning everyday. Fortunately, I found the idea by reading Aratti's reply. So I adjust the potentiometer with 0°-90° by POT command and I got. This mean a potentiometer rotate 90°, the VAR value show 90, I was calculated the pre-define value sin/cos(with excel) and multiply with known distance. So I stored many distance values in PIC and give results on LCD by using many IF function. I think my strategies like a child. But this is only one way to do now. Thank you very much friends.

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