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
Bookmarks