The idea is to have the argument of the function and the returned value in the range -32768 to 32767, no (real) floating numbers.
The existing sin() function from "math.h" described in PCD manual page 190, has as argument of the function and the returned value floating numbers:
https://www.ccsinfo.com/downloads/PCDReferenceManual.pdf
The way how I do it now is implicit, typecasting, by assigning the float variable value to an signed int16 variable:
You don't say which PIC you're using or the resolution you need but I'd think a lookup table for 0-90* would/could be very fast and efficient.
It would depend upon what you need the numbers for....
Decades ago there was an article about 'magic sine waves' by Don Lancaster.
Jay
viki2000
Joined: 08 May 2013 Posts: 233
Posted: Sun Jun 04, 2017 4:59 pm
I use PIC24HJ64GP202 or generally a PIC24 on 16 bit MCU.
I want to generate the sine wave using 1000 up to 10.000 points.
At 10K points the lookup table is not a nice option, actually even for 1000 points is big., so I decided to try a trigonometric function as sin().
I use 16bit for one DAC sample as resolution.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum