Log in

View Full Version : C programming problem...


wasabi824
07-02-2004, 15:43
hey we're trying to use a simple cosine function call in our code, and we've done the "#include <math.h>" already but we keep getting an error of

"Error - could not find definition of symbol 'cos' in file 'C:\Program Files\MPLAB IDE\default\user_routines.o'. "

when we try to compile. obviously, this is using the MPLAB IDE v6.30... has anyone else successfully used the math functions in their code, or any suggestions on how to fix this?

thanks in advance,
jason

phrontist
07-02-2004, 15:45
and we've done the "#include <math.h>"

Where did you get this math.h library? Unless it was specifically written to adhere to the C18 standard, it won't work. :rolleyes:

ShadowKnight
07-02-2004, 15:52
You could try making a table lookup. Basically make a table in Excel then copy it into your code. the problem with this is you only have the values you put in the table.

rom float costable[numvalues] = {1, .985, etc., etc, etc...}

Check out this thread: math.h (http://www.chiefdelphi.com/forums/showthread.php?t=23172&highlight=math.h)

wasabi824
07-02-2004, 15:52
we thought that math.h was part of the default C programming library... but any advice on how to implement/call cosine in MPLAB assuming we can't use math.h?

thanks

KevinB
07-02-2004, 23:43
Nope ... there is no sine or cosine for the PIC. The best bet is to make a lookup table and just reference it. I would avoid using floating point variables though and stick to integers. Search CD for "lookup table" and you should be able to find what you need to know. This has been discussed several times.

steven114
08-02-2004, 01:04
And, if you do use floating point, use doubles not floats. I had a lot of troubles with roundoff errors until I switched. 100/25 = 3.99 apparently :) Must be Pentium-based... ;)