|
Re: Programming a Devantech Magnetic Compass - CMPS03
You have datatyping issues. The result of Get_Analog_Value() (if its like the one in the '06 controller) returns an unsigned integer... and your dividing by a floating point... and assiging to an unsigned character!
You might try:
{
unsigned int temp;
temp = Get_Analog_Value(Compass);
temp *= 4023; //fraction version of
temp /= 1000; //your conversion factor - avoid floating point
pwm13 = (unsigned char)temp;
printf("%d", pwm13);
}
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
|