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?
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…}
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?
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.
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…