Home › Forums › Forums › Technical Support for BerryGPS and BerryGPS-IMU › Question about the compass_tutorial01.c › Reply To: Question about the compass_tutorial01.c
July 27, 2022 at 9:29 pm #17371
Mark Williams
Keymaster
Hi…. I am so sorry you are having a trouble. this would be the first I have heard of a compass not working. Ill have to ask my colleagues to see if they have seen this before.
In the mean time, can you do a test?
Can you remove the current print statement from compass_tutorial03.c
and put in the below print statement.
while(1){
readMAG(magRaw);
printf("Raw,%i,%i,%i,",magRaw[0],magRaw[1],magRaw[2]);
//Apply hard iron calibration
magRaw[0] -= (magXmin + magXmax) /2 ;
magRaw[1] -= (magYmin + magYmax) /2 ;
magRaw[2] -= (magZmin + magZmax) /2 ;
printf("Cal,%i,%i,%i,",magRaw[0],magRaw[1],magRaw[2]);
//Apply soft iron calibration
scaledMag[0] = (float)(magRaw[0] - magXmin) / (magXmax - magXmin) * 2 - 1;
scaledMag[1] = (float)(magRaw[1] - magYmin) / (magYmax - magYmin) * 2 - 1;
scaledMag[2] = (float)(magRaw[2] - magZmin) / (magZmax - magZmin) * 2 - 1;
printf("Rscaled,%f,%f,%f\n",scaledMag[0],scaledMag[1],scaledMag[2]);
recompile and then start the program again, rotate the compass 180 degrees and send the output to sales@ozzmaker.com. please also include you calibration values
Mark --OzzMaker.com --
