View Full Version : Working with Cosine
Ed Cannady
- 10th May 2005, 02:40
I would like to use the COS function to determine which part of a sine wave I am on. What I do not know is what the data is going to look like and how accurate the data will be. Thanks in advance for any and all help.
Best, Ed
mister_e
- 10th May 2005, 12:21
i'll suggest you something else, take a few reading of your signal with the internal adc, store those data into array or internal EPROM and play with. Refering to a table will be much easier and much code efficient. BUT it's my own opinion, probably Melanie or somebody else have a better solution.
Acetronics2
- 10th May 2005, 13:25
Hi,Ed
You'll get -127 to +127 as a result ... so, look at the highest digit to see where you are on your sine ( ascending = 1, descending = 0 ).
But do not forget to convert degrees as here:
Result = COS ( X * 256 / 360 ) ... for X in degrees.
Side = Result.7
Looking also to SIN highest digit will show you the quarter where you are ...
For accuracy ... 7 bits !!!
Alain
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.