Calculation of GPS and Compass
how make gps , compass calculation or programming making autonomous robot to drive straight in programming using gps em406a
and compass hmc6352
and compass hmc6352
the gps produce strings include latitude , longitude. need parse strings know position , height.
iirc search word nmea
the compass 6352 more difficult 1 talk to. have worked 1 , took several days reasonable readings it. started library other issues came in between not finished. latest version find , might starting point you.
i recall setting different modes not easy , @ moment whole compass blocked. took me long running again, usage of code below @ own risk. means disclaimers apply, , won't fix code or blocking compass.
the query mode simplest.
code: [select]
//
// file: querymode.pde
// author: rob tillaart
// version: 0.1.00
// purpose: test app hmc6352 library arduino
//
// released public domain
//
#include <wire.h>
#include <hmc6352.h>
hmc6352 compass(0x21);
void setup()
{
serial.begin(115200);
serial.println("demo hmc6352: continuous mode");
serial.println(hmc_lib_version);
compass.setoperationalmodus(cont, 20, true); // 20 hz
serial.println(compass.getoperationalmodus());
compass.direction(); // first time
}
void loop()
{
int x = compass.qry();
serial.print("degree: ");
serial.println(x);
// serial.println(compass.getoperationalmodus(), bin);
delay(50); // 20 hz
}
and .h file
code: [select]
//
// file: hmc6352.h
// author: rob tillaart
// version: 0.1.03
// purpose: hmc6352 library arduino
//
// details: see cpp file
//
// released public domain
//
//#ifndef hmc6352_h
//#define hmc6352_h
#include "wprogram.h"
#define hmc_lib_version "0.1.01"
#define hmc_get_data 0x41
#define hmc_wake 0x57
#define hmc_sleep 0x53
#define hmc_save_op_mode 0x4c
#define hmc_callibrate_on 0x43
#define hmc_callibrate_off 0x45
#define hmc_update_offsets 0x4f
#define hmc_write_ram 0x47
#define hmc_read_ram 0x67
#define hmc_write_eeprom 0x77
#define hmc_read_eeprom 0x72
enum hmcmode { standby=0, query=1, cont=2, error};
class hmc6352
{
public:
hmc6352(uint8_t device);
// basic calls standby mode
int getheading(void); // merge of ask & read
int askheading(void);
int readheading(void);
int wakeup(void);
int sleep(void);
// expert calls
int factoryreset();
int setoperationalmodus(hmcmode m, uint8_t freq, bool periodicreset);
int getoperationalmodus();
int setoutputmodus(uint8_t om);
int getoutputmodus();
int callibrationon(void);
int callibrationoff(void);
int seti2caddress(uint8_t address);
int geti2caddress();
int writeeeprom(uint8_t address, uint8_t data);
int readeeprom(uint8_t address);
int writeram(uint8_t address, uint8_t data);
int readram(uint8_t address);
// not tested / unknown
int settimedelay(uint8_t msec);
int gettimedelay();
int setmeasurementsumming(uint8_t ms);
int getmeasurementsumming();
int saveopmode(void);
int updateoffsets(void);
private:
int cmd(uint8_t c);
int readcmd(uint8_t c, uint8_t address);
int writecmd(uint8_t c, uint8_t address, uint8_t data);
uint8_t _device;
};
//#endif
Arduino Forum > Using Arduino > Project Guidance > Calculation of GPS and Compass
arduino
Comments
Post a Comment