Sign in

username:

password:



Not a member?

Search Comp.Arch.Embedded



Search tips

embedded by Keywords

68HC11 | 68HC12 | 8051 | 8052 | ARM | ARM7 | Asic | AT91 | AT91RM9200 | Atmel | AVR | AVRStudio | Bootloader | CFP | CompactFlash | Cygnal | Cypress | Dataflash | DSP | eCos | EEPROM | Embedded Linux | Emulator | Endian | Ethernet | Firewire | FPGA | Freescale | GCC | GNUARM | GSM | H8 | HDLC | I2C | Infineon | Interrupts | Java | JTAG | LCD | LED | LPC2000 | MCU | Microchip | MMC | MPLAB | MSP430 | PC104 | PCB | PCI | PCMCIA | PowerPC | Rabbit | RS232 | RS485 | RTOS | SBC | SDRAM | Sensor | SPI | STK500 | UART | UML | USART | USB | Verilog | VHDL | VxWorks | Xilinx

Ads

Discussion Groups

See Also

DSPFPGAElectronics

There are 30 messages in this thread.

You are currently looking at messages 0 to 10.

sine routines - CAFxX - 2004-01-14 15:43:00

does anybody know where to find some FAST sine routines to be run on an
8052? sdcc's math.h is just an empty file... just an #error directive! thank
you in advance.





Re: sine routines - Jack Klein - 2004-01-14 21:58:00

On Wed, 14 Jan 2004 21:43:20 +0100, "CAFxX" <c...@n-side.it> wrote in
comp.arch.embedded:

> does anybody know where to find some FAST sine routines to be run on an
> 8052? sdcc's math.h is just an empty file... just an #error directive! thank
> you in advance.

There are no FAST routines for calculating sine with the 8051
instruction set, and probably no fast ones either.  How much accuracy
and precision do you need?  The fastest approach would be a look-up
table.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

Re: sine routines - CBFalconer - 2004-01-14 23:47:00

Jack Klein wrote:
> "CAFxX" <c...@n-side.it> wrote
> 
> > does anybody know where to find some FAST sine routines to be
> > run on an 8052? sdcc's math.h is just an empty file... just an
> > #error directive! thank you in advance.
> 
> There are no FAST routines for calculating sine with the 8051
> instruction set, and probably no fast ones either.  How much
> accuracy and precision do you need?  The fastest approach would
> be a look-up table.

and what sort of floating point arithmetic has he available, if
any?  Does he have polynomial evaluation routines? etc.  What
input range is required?

-- 
Chuck F (c...@yahoo.com) (c...@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>;  USE worldnet address!



Re: sine routines - Jack Klein - 2004-01-15 01:48:00

On Thu, 15 Jan 2004 04:47:12 GMT, CBFalconer <c...@yahoo.com>
wrote in comp.arch.embedded:

> Jack Klein wrote:
> > "CAFxX" <c...@n-side.it> wrote
> > 
> > > does anybody know where to find some FAST sine routines to be
> > > run on an 8052? sdcc's math.h is just an empty file... just an
> > > #error directive! thank you in advance.
> > 
> > There are no FAST routines for calculating sine with the 8051
> > instruction set, and probably no fast ones either.  How much
> > accuracy and precision do you need?  The fastest approach would
> > be a look-up table.
> 
> and what sort of floating point arithmetic has he available, if
> any?  Does he have polynomial evaluation routines? etc.  What
> input range is required?

All good questions, but do you know of any fast routines to calculate,
as opposed to look up, sines on an 8051?  Any floating point is
hideously slow on that platform, I know, I've used it a few times.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

Re: sine routines - Wim Ton - 2004-01-15 03:41:00

> does anybody know where to find some FAST sine routines to be run on an
> 8052? sdcc's math.h is just an empty file... j

You can use a Taylor series. And if your angles are small you can get away
with a limited number of terms, depending on the required precision. You may
do it with integer math and the approprate scaling.

For example, for small angles, sin(x)=x  (in radians)

The next refinement: sin(x) = x - x*x /2 For angles below 1 radian this may
be sufficient.

Wim



Re: sine routines - CBFalconer - 2004-01-15 05:38:00

Jack Klein wrote:
> CBFalconer <c...@yahoo.com> wrote in comp.arch.embedded:
> > Jack Klein wrote:
> > > "CAFxX" <c...@n-side.it> wrote
> > >
> > > > does anybody know where to find some FAST sine routines to be
> > > > run on an 8052? sdcc's math.h is just an empty file... just an
> > > > #error directive! thank you in advance.
> > >
> > > There are no FAST routines for calculating sine with the 8051
> > > instruction set, and probably no fast ones either.  How much
> > > accuracy and precision do you need?  The fastest approach would
> > > be a look-up table.
> >
> > and what sort of floating point arithmetic has he available, if
> > any?  Does he have polynomial evaluation routines? etc.  What
> > input range is required?
> 
> All good questions, but do you know of any fast routines to calculate,
> as opposed to look up, sines on an 8051?  Any floating point is
> hideously slow on that platform, I know, I've used it a few times.

I was thinking of some Tchebychev polynomials or ratio of
polynomials I used 25 years ago for 4.5 digit accuracy.  I have
the source somewhere for the 8080 code I developed for them, which
took about 10 millisec on a 2 Mhz 8080, as I recall.  Floating
multiply was in the order of 300 uSec. and divide headed for 1
millisec.

-- 
Chuck F (c...@yahoo.com) (c...@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>;  USE worldnet address!



Re: sine routines - Albert Lee Mitchell - 2004-01-15 06:30:00

On Wed, 14 Jan 2004 21:43:20 +0100, CAFxX wrote:

> does anybody know where to find some FAST sine routines to be run on an
> 8052? sdcc's math.h is just an empty file... just an #error directive! thank
> you in advance.

	Sorry, no such animal.  The fastest way to calculate sines is table
lookup and interpolation.  Also think 'octents' rather than quadrants to
preserve accuracy.
 
-- Regards, Albert
----------------------------------------------------------------------
AM Research, Inc.    			  The Embedded Systems Experts
http://www.amresearch.com          			  916.780.7623
----------------------------------------------------------------------


Re: sine routines - Morris Dovey - 2004-01-15 06:35:00

CAFxX wrote:

> does anybody know where to find some FAST sine routines to be
> run on an 8052? sdcc's math.h is just an empty file... just an
> #error directive!

Fastest I've seen was look-up with linear interpolation on a 
twice-folded (at pi and pi/2) table of numerators for a fraction 
with denominator 65535. All of the processing was performed in 
integer math except the final division. Accuracy was pretty good 
and the code was completely portable (the application wasn't for 
an 8052).
-- 
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.


Re: sine routines - Paul Keinanen - 2004-01-15 06:45:00

On Thu, 15 Jan 2004 06:48:19 GMT, Jack Klein <j...@spamcop.net>
wrote:

>On Thu, 15 Jan 2004 04:47:12 GMT, CBFalconer <c...@yahoo.com>
>wrote in comp.arch.embedded:
>
>> Jack Klein wrote:
>> > "CAFxX" <c...@n-side.it> wrote
>> > 
>> > > does anybody know where to find some FAST sine routines to be
>> > > run on an 8052? sdcc's math.h is just an empty file... just an
>> > > #error directive! thank you in advance.
>> > 
>> > There are no FAST routines for calculating sine with the 8051
>> > instruction set, and probably no fast ones either.  How much
>> > accuracy and precision do you need?  The fastest approach would
>> > be a look-up table.
>> 
>> and what sort of floating point arithmetic has he available, if
>> any?  Does he have polynomial evaluation routines? etc.  What
>> input range is required?
>
>All good questions, but do you know of any fast routines to calculate,
>as opposed to look up, sines on an 8051?  Any floating point is
>hideously slow on that platform, I know, I've used it a few times.

If only sin/cos is required (and not tan), then why use floating point
numbers in the first place. Use some fixed point format e.g. the
decimal point to the _left_ of the most significant bit or two bits
for the integer part and 30 bits for the decimal part, thus avoiding
any normalisation and denormalisation required by floating point
additions. 

The fixed point arithmetic can be done with integer hardware, but some
rounding due to discarded low order decimal bits must be done after
multiplication and some shifts with a predetermined number of bits may
be required if the number of integer bits is something else than 0 or
8. 

The polynomial method is just an refined table look up with some
multiplications and additions. The quadrant (0..90 degrees) is divided
into a few ranges and the polynomial coefficients are extracted from
the table. A fourth order polynomial is usually sufficient for single
precision accuracy, while 6-8 order is required for double precision.
By dividing the quadrant into a larger number of ranges, a lower order
polynomial can be used. 

Paul
   

Re: sine routines - CAFxX - 2004-01-15 08:04:00

what i need to do is to generate a custom-frequency sine wave to be
outputted at CD-quality frequency (44100 samples/second) to a DAC.
If possible i'd prefer working with 16 bit integers since float needs
cpu-time-expensive libraries.
thanks to all of you for your replies.
"Jack Klein" <j...@spamcop.net> ha scritto nel messaggio
news:b...@4ax.com...
> On Wed, 14 Jan 2004 21:43:20 +0100, "CAFxX" <c...@n-side.it> wrote in
> comp.arch.embedded:
>
> > does anybody know where to find some FAST sine routines to be run on an
> > 8052? sdcc's math.h is just an empty file... just an #error directive!
thank
> > you in advance.
>
> There are no FAST routines for calculating sine with the 8051
> instruction set, and probably no fast ones either.  How much accuracy
> and precision do you need?  The fastest approach would be a look-up
> table.
>
> --
> Jack Klein
> Home: http://JK-Technology.Com
> FAQs for
> comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
> comp.lang.c++ http://www.parashift.com/c++-faq-lite/
> alt.comp.lang.learn.c-c++
> http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html



| 1 | 2 | 3 | next