View previous topic :: View next topic |
Author |
Message |
dave180sx
Joined: 29 Aug 2012 Posts: 2
|
question about ccs function |
Posted: Thu Aug 30, 2012 12:14 pm |
|
|
Is it possible to generate a sine signal through an electrical function using the sine function of the math.h library?
The function is A*sin(2*pi*f*t+ß) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 30, 2012 12:41 pm |
|
|
Do a search on the forum for: sine table
Set it to "Search for all terms". You will find many threads on it.
Here's the search page:
http://www.ccsinfo.com/forum/search.php |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Thu Aug 30, 2012 2:26 pm |
|
|
and the reason is 'sloth'. Calculating a sin, takes 77uSec, even on a DSpic at 80MHz. On a PIC 18, it takes nearly 700uSec, at 40MHz. Not fast enough, unless you want to synthesise a very low frequency. Using the look-up table, a value can be returned in just a couple of uSec.
Best Wishes |
|
|
dave180sx
Joined: 29 Aug 2012 Posts: 2
|
Re: question about ccs function |
Posted: Thu Aug 30, 2012 3:10 pm |
|
|
My question is focused on obtaining a low-frequency signal from 0 to 100 hertz, but the main reason is to create a gap through the function and also create harmonics in the signal.
I have managed to make this signal by means of tables, but this resource uses a lot of memory in my program. So I want to know if it is possible to do through a function. |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Thu Aug 30, 2012 3:57 pm |
|
|
Ttelmah wrote: | and the reason is 'sloth'. Calculating a sin, takes 77uSec, even on a DSpic at 80MHz. On a PIC 18, it takes nearly 700uSec, at 40MHz. Not fast enough, unless you want to synthesise a very low frequency. Using the look-up table, a value can be returned in just a couple of uSec.
Best Wishes |
How long would a 4th-order Taylor approximation take, assuming you tweak it out to use integer math? |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri Aug 31, 2012 2:29 pm |
|
|
I don't really see what you're wanting.
You need to tell us a lot more about your constraints.
At this stage you're making us all second guess.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Sat Sep 01, 2012 1:29 am |
|
|
sseidman wrote: | Ttelmah wrote: | and the reason is 'sloth'. Calculating a sin, takes 77uSec, even on a DSpic at 80MHz. On a PIC 18, it takes nearly 700uSec, at 40MHz. Not fast enough, unless you want to synthesise a very low frequency. Using the look-up table, a value can be returned in just a couple of uSec.
Best Wishes |
How long would a 4th-order Taylor approximation take, assuming you tweak it out to use integer math? |
Very many orders of magnitude slower than the look-up table....
For the exponents, assume these are 'pre-solved', so in a look up table. 4 look ups. Then the powers. Obviously you can't do these using logarithms with an int, so you'd have to simply multiply. You can store the products as you progress, so a total of 9 multiplications, four divisions and one subtraction. I'd estimate, about 600uSec. Not much better than the existing function....
Best Wishes |
|
|
|