CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

question about ccs function

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dave180sx



Joined: 29 Aug 2012
Posts: 2

View user's profile Send private message

question about ccs function
PostPosted: Thu Aug 30, 2012 12:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 12:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 2:26 pm     Reply with quote

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

View user's profile Send private message

Re: question about ccs function
PostPosted: Thu Aug 30, 2012 3:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 3:57 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 31, 2012 2:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Sep 01, 2012 1:29 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group