Place the attached BMO055.js in the modules directory of your WebIDE project.
Run testBMO055.js.
Try editing the unit selections or the operating mode to see what happens. I’ve tested modes 7 and 12.
The test code follows
//testBMO055.js 7 Jun 2017
var W;
// For accelerometer slowly position chip on 6 faces of a cube.
// For magnetometer move chip in verical figure 8 pattern
// For gyroscope leve chip in one position for a bit
// When the calibration status numbers are all eqaul to three
//calibration has been achieved
function showCalibStatus(){
console.log("syscal= "+W.Bitread(W.REGval.SYS_Calib_Status)+
" Gyrcal= "+W.Bitread(W.REGval.GYR_Calib_Status)+
" Acccal= "+W.Bitread(W.REGval.ACC_Calib_Status)+
" Magcal= "+W.Bitread(W.REGval. MAG_Calib_Status));
}//end showCalibStatus
function showTemp(){
console.log("Temperature= "+W.getTemperature()+" "+W.Tunitstr);
}//end showTemp(
function showAMG(){
W.getAMG();
console.log("A=,"+W.ACC[0]+","+W.ACC[1]+","+W.ACC[2]+","+W.ACC_Unitstr);
console.log("M=,"+W.Mag[0]+","+W.Mag[1]+","+W.Mag[2]+","+W.Magunitstr);
console.log("G=,"+W.Gyr[0]+","+W.Gyr[1]+","+W.Gyr[2]+","+W.GYR_Unitstr);
}//end showAMG
function showIMU(){ //fusion modes
W.getIMU();
console.log("Heading=,"+W.Head[0]+",Roll,"+W.Head[1]+",Pitch,"+W.Head[2]+W.Anglestr);
console.log("Q=(,"+W.Quant[0]+","+W.Quant[1]+","+W.Quant[2]+","+W.Quant[3]+",)"+W.Qstr);
console.log("Lin=,"+W.Lin[0]+","+W.Lin[1]+","+W.Lin[2]+","+W.ACC_Unitstr);
console.log("Grav=,"+W.Grav[0]+","+W.Grav[1]+","+W.Grav[2]+","+W.ACC_Unitstr);
}//end showIMU
var Off;
function showOffsets(){
Off=W.readOffsets();
console.log("Aoffset=,"+Off[0]+","+Off[1]+","+Off[2]+
",Moffset=,"+Off[3]+","+Off[4]+","+Off[5]+
",Goffset=,"+Off[6]+","+Off[7]+","+Off[8]);
console.log("Aradius=,"+Off[9]+",Mradius=,"+Off[10]);
}//end showOffsets
function start(){
// define the I2C connection
I2C3.setup({ scl :A8, sda: B4} );
// define the bus address of the BNO055 chip
var BusAddress= 0x28;//If ADR pin at 3V 0x29
//load the BNO055 module
W=require("BNO055").connect(I2C3,BusAddress);
// W=new BNO055(I2C3,BusAddress);
W.run();//Get it started Needs work
//W.RST_SYS(); //not working yet
//display all knobs and indicators
W.showBits();
//W.External_Clk(); //not working yet
//to configure the chip must be in Opmode 0
W.Bitwrite(W.REGval.Operation_Mode,0);
/* setupTemperature source 0= Accelerometer, 1= Gyro; unit 0=C, 1=F **/
W.setupTemperature(1,1);//(source,unit)
// choose units to display
W.setEULunits(0); //0 deg,1 rad
W.setGYRunits(0); //0 deg,1 rad
W.setACCunits(0); // 0 m/s,1 mg
//chip registers are paged
//to direct read output need to be on page 0
W.selectPage(0);
// choose am operating mode
/*
##### Operation_Mode
0=CONFIG MODE
1=ACCONLY
2=MAGONLY
3=GYROONLY
4=ACCMAG
5=ACCGYRO
6=MAGGYRO
7=AMG
8=IMU
9=COMPASS
10=M4G
11=NDOF_FMC_OFF
12=NDOF
*/
W.Bitwrite(W.REGval.Operation_Mode,12);
//do a timed loop that acquires and displays data
var i;
setInterval(function () {
console.log(" ");
showAMG();
showIMU();
showTemp();
showCalibStatus();
showOffsets();
}, 500);
}//end start
//function startPgm(){
//Wait for program to load
setTimeout(function () {
start();
}, 1000);
//}//end startPgm
The output follows
Note the all three values in syscal, showing that the chip is calibrated.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
BMO055 Module progress
Place the attached BMO055.js in the modules directory of your WebIDE project.
Run testBMO055.js.
Try editing the unit selections or the operating mode to see what happens. I’ve tested modes 7 and 12.
The test code follows
The output follows
Note the all three values in syscal, showing that the chip is calibrated.
Not finished yet
Some links
https://www.bosch-sensortec.com/bst/products/all_products/bno055
Quaternions
https://github.com/kriswiner/LSM9DS1/commit/73a372a62c166a79fbdac46b8d3322430bf75428
http://x-io.co.uk/res/doc/madgwick_internal_report.pdf
http://diydrones.com/profiles/blogs/sebastian-oh-madgwicks-filter
http://vigir.missouri.edu/~gdesouza/Research/Conference_CDs/RehabWeekZ%C3%BCrich/icorr/papers/Madgwick_Estimation%20of%20IMU%20and%20MARG%20orientation%20using%20a%20gradient%20descent%20algorithm_ICORR2011.pdf
2 Attachments