Alan B. Pearce wrote:

{Quote hidden}>> Unfortunately, I have never done math functions in PIC's before

>> so don't know how to do that yet. Maybe it's not math but a

>> simple conversion. Any pointers?

>

> Then this sounds like it is time to investigate a C or other high

> level language compiler that can do a module for the maths that you

> can link in, if you don't want to do the whole program in C.

>

> However there is another trick I have done to make a table. Use

> Excel. In my case I wanted to have a table for a 16 bit sine wave,

> with entries every 2 degrees. Using Excel it took me about a half

> hour to set up formulae that would automatically calculate the

> values, set up a column full of "DT ", then set up the next two

> columns to display the hex values as text, using two columns to split

> the value into high and low halves, with the formula putting a comma

> after the first data column. Once it was all calculated just

> highlight the three columns (DT and two data columns) and copy and

> paste into your favourite text editor. The other sneaky trick with

> this is it is easy to offset the data with constants as you go, in my

> case I needed to offset by 32768 because of the way I needed to drive

> a DAC.

>

> This makes doing tables real easy, and if you wish to rearrange the

> data because of a different strategy on your PIC, it takes a very

> short time to modify the Excel spreadsheet to regenerate the table.

Translating Alan's good example of table generation, into Qbasic;

Open "SinVal.Txt" for output as #1

For N=0 to 358 step 2

sinv = int(sin(n * 0.01745329251995) * 65535)

Sinvh = int(sinv/256)

Sinvl = sinv mod 256

Print #1, "DT "; sinvh;",";sinvl

Next N

Close #1

VV46NER

--

http://www.piclist.com#nomail Going offline? Don't AutoReply us!

email listservTakeThisOuT.....mitvma.mit.edu with SET PICList DIGEST in the body