For anyone else like me that forgot all they learned about radians.... This should help. These go from 0 to 65,535.
For anyone else like me that forgot all they learned about radians.... This should help. These go from 0 to 65,535.
Last edited by ScaleRobotics; - 5th February 2011 at 18:05.
Thank You Walter,
It is definitely going to take some time to get my head around this, unfortunate side effect of growing up during the Vietnam war, where we were expected to become soldiers who got shipped there and returned in a nicely bagged and boxed container. My algebra teacher was a retired navel captain, who taught spit about the subject but spoke extensively about his career and travels in Tahiti. That notwithstanding I will get this. I am sure nobody who participates in this forum is going to point at me in the store and say "hey there is the dummy who couldn't understand that code Walter wrote . . . "<b>So Anyway</b> the numbers you plugged in represent . . .Units, of my choosing . . .and to use this
Correct? Figure I do not need to know how to build a truck to drive one.Code:include"trig.inc" main: ang=5461 x=0 y=0 asm call sin_cos endasm Lcdout $fe, 1 ' Clear LCD screen lcdout $FE,1,#x,",",#y lcdout $FE,$C0,#ang
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Hey Joe,
No you definitely do not need to know how it works. But if you find out, please let me know. The assembly code only seems to put me to sleep when I read it. Something about rotating angle, shifting bits zzzzz.....
Your code will work, but it can be even simpler since it has the includes file in it. You don't have to get in to the asm endasm, as the sincos function is already there.
It is that easy. Only a little bit harder if you want to do anything with the data returned in x and y (or ang and x for atan function)Code:include"trig.inc" main: ang=5461 x=0 y=0 call sincos Lcdout $fe, 1 ' Clear LCD screen lcdout $FE,1,#x,",",#y lcdout $FE,$C0,#ang
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
That is the hardest part. Darn radians are 90 degrees off from the start.
For example
0 = 90 degrees
5461 = 60 degrees
10922 = 30 degrees
16383 = 0 degrees (or North)
21844 = 330 degrees
32767 = 270 degrees
38228 = 240 degrees
and so on.....
You definitely do not have to know this, but I think it is interesting:
In the time it takes for a regular Sin, or Cos 16 bit function on a PIC18 to give a result, light travels 3000 kilometers
The time it takes for this cordic 16 bit result, light travels 33.3 kilometers.
How do you say "Your mileage may vary" when you use kilometers?
Last edited by ScaleRobotics; - 13th February 2009 at 20:20.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks