Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

oCompassDV Class Reference

Controls a Devantech Electronic Compass. More...

#include <ocompass.h>


Public Member Functions

 oCompassDV (IOLINE)
 TPU channel / Control channel.

MICROSECOND microseconds (void)
 Used to determine the correct value to use for callibrate. should be 1000-35999 microseconds.

void callibrate (float)
 adjusts the time so compass return 360 degrees. (default 1.0).


Detailed Description

Controls a Devantech Electronic Compass.

Operation
The oCompassDV uses the TPU programmable time accummulation (PTA) function to measure the pulse width modulated signal's high time. The value function will actually sit idle on the CPU and wait for the value to be calculated. Thus, you should expect this function to take about 100 or so milliseconds. May one day try the I2C method and see if it is any faster. Changing the system clock or TPU clock divider should not effect these methods.
Remarks
Since it's critical you truly get 360 degrees and not something more or less, as of revision 1.11, you can compensate for the inaccuracies in the compass time by using the callibrate method. On Mine, using PWM, it was from 1.007 ms - 36.607 ms. The begin was quite accurate, but the ending is off by a couple milliseconds; I redid everything to eliminate the round off error, so I must attribute remaining error to the compass. This assumes a linear error, which may not be true.
To obtain the correct calibratation value, first set the callibrate to 1.0; this will allow you to get the value in microseconds for the pulse. Just divide the value we want (36990) by the maximum value you can obtain from your compass, and this should give you the correct value for callibrate.
Note:
The default callibration is set to 1.0
Sample Code
#include <ocompass.h>
oCompassDV compass(0);  // TPU port channel 0.
oGreenLED green;
int main()
{
  green.off();
  compass.callibrate(1.0105);
  if (compass.value() > 180)
  {
    green.on();
  }
  exit(0);
}


The documentation for this class was generated from the following file:
Generated on Mon Oct 8 19:32:45 2007 for OOMRM Hardware API by doxygen1.3