WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Honeywell/HMC5883L.h

The HMC5883L compass sensor - replaces the HMC5843.
HMC5883L.jpg
The image shows a carrier board from Sparkfun.
Datasheet: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf
This compass is accessed over I2C at address 0x3C. Since the device is really a magnetometer then the floating point maths library is used to calculate the bearing, roll and pitch in degrees.
To create a device use:-
HMC5883L compass = MAKE_HMC5883L();
Example for the Axon:-
#include "sys/Axon.h"
#include "rprintf.h"
#include "Sensors/Compass/Honeywell/HMC5883L.h"

HMC5883L compass = MAKE_HMC5883L();


void appInitHardware(void){
   //setup UART
   uartInit(UART1, 9600);
   rprintfInit(&uart1SendByte);
   // Initialise compass
   compassInit(compass);
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
   return 0;
}

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
   // Take a reading
   compassRead(compass);
 
   // Print out the values in degrees
   rprintf("Compass Bearing = %d\n",compass.compass.bearingDegrees);
   rprintf("Compass Roll = %d\n",compass.compass.rollDegrees);
   rprintf("Compass Pitch = %d\n",compass.compass.pitchDegrees);
 
   // Or just use the dump command
   compassDump(compass);
 
   // Alternatively the raw x,y,z magnetometer values can be shown
   rprintf("Compass Raw: x=%d, y=%d, z=%d\n",
      compass.rawX,compass.rawY,compass.rawZ);
   return 0;
}

 

Function

 


void HMC5833L_1_5Hz(HMC5883L* compass)

Changes the default refresh rate to 1.5 Hz.

void HMC5883L_3Hz(HMC5883L* compass)

Changes the default refresh rate to three times per second.

void HMC5883L_7_5Hz(HMC5883L* compass)

Changes the default refresh rate to 7.5 times per second.

void HMC5883L_15Hz(HMC5883L* compass)

Changes the default refresh rate to fifteen times per second.

void HMC5883L_30Hz(HMC5883L* compass)

Changes the default refresh rate to thirty times per second.

void HMC5883L_75Hz(HMC5883L* compass)

Changes the default refresh rate to seventy five times per second.

Valid XHTML 1.0 Transitional