PDA

View Full Version : Range Finder with Laser pointers



serial_bug
- 12th February 2011, 05:35
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?

ScaleRobotics
- 12th February 2011, 15:44
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 (http://www.picbasic.co.uk/forum/showthread.php?t=7502) and PIC18 (http://www.picbasic.co.uk/forum/showthread.php?t=10528) 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

aratti
- 12th February 2011, 16:14
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.

ScaleRobotics
- 12th February 2011, 16:19
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 (http://www.picbasic.co.uk/forum/showthread.php?t=10528&p=70074#post70074) 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.

serial_bug
- 21st February 2011, 11:51
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.