|
|
View previous topic :: View next topic |
Author |
Message |
xieliwei Guest
|
Largest array size? |
Posted: Mon May 18, 2009 8:49 am |
|
|
I'm attempting to create a scaled sinewave lookup table and it must be very precise. However, everytime I try to compile, the compiler hangs (100% CPU utilisation) attempting to parse the array. The array consists of 32768 16-bit integers.
I believe this should be possible on a 18f PIC, but CCS does not seem to like the size of the array. Any suggestions? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 18, 2009 11:46 am |
|
|
Break it up into two or more smaller arrays. |
|
|
Ttelmah Guest
|
|
Posted: Mon May 18, 2009 12:23 pm |
|
|
Also though, do consider using something better.
As it stands, a 16bit array is only going to give 16bit accuracy at the best. Now for 0 to 5 degrees, you can get this accuracy by simple linear multiplication. Even for the larger angles linear interpolation will give this accuracy for much less space. Using 65KB, for a solution seems wasteful.
There was a rather nice 15bit solution posted as part of an application note some time ago, which used just seven terms, and a handful of machine instructions. A web search should find it.
Are you 'dead sure', you have the maths limits on your array sizes really well done?. A 65KB array ought to work (if you look at how the code is done, it should handle this), but if you overflowed by even one entry it'd fail.
Are you really using a step size of just 0.0027 degree per entry?. If not, and the array actually corresponds to the full circle, remember that sin's for 90 to 180 degrees (or the equivalent in any other angular unit), are the same as for 90 to 0 degrees, while those for the other two quadrants can just be generated by inversion.
Best Wishes
Best Wishes |
|
|
|
|
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
|