Setting up AK8963C Compass chip SPI Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,730
What is number4?
In your program there is no check of drdy before reading x, y, z
Hi J,
I read your line: "You don't check the rdy bit when reading xyz." as I don't need to check DRDY bit, not that I hadn't done it. Now I understand.

I commented that line out, because all of my READ DRDY results failed, but the program worked with it gone.

I have found the problem see attached:
I had forgotten this, and I had made a note on the front of the D/S:mad:
C
 

Attachments

jjw

Joined Dec 24, 2013
823
You have a byte DRDY. You should check bit0 of it ( rdy bit) and bit1 (overflow)

Chapter 7.2.3 is about I2C interface.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
You have a byte DRDY. You should check bit0 of it ( rdy bit) and bit1 (overflow)

Chapter 7.2.3 is about I2C interface.
Hi J,
Yes, I understand, I normally use it, but forgot this time.

I think chapter 7.2.3 applies to i2c and SPI.

When using 1xxxxxxx I now can READ registers, and DRDY and HOFL, where I couldn't before..
C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I've been adding Hyperlinks to the AK8963C D/S to help me navigate a bit quicker, where I was loosing the thread while flipping paper pages, let's see if it helps.
Open with browser and click the links.
C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
Looking at the results at #27, while looking at the attached 'judgment' screen shot, I'm suspicious that all of the readings are '+'

Can someone explain how to look at the attachment please? for me it's written in in a difficult way.
C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,730
One Endif is missing.
This is not needed:
If addr = 0x89 Then addr = 0x83
Hi J,
LINE removed.
I don't see the missing ENDIF, and it compiles, so Oshonsoft doesn't EITHER.

Here is the SELF TEST RESULTS range again:

So far (with the OUTPUT BIT set to '1' =16BIT).
Here's how I see it: [ The result of HX (WORD) should be between -50 and 50 (Inclusive) if not then use SENSITIVITY ADJUSTMENT VALUE calculation (8.11.3) to correct. ]
As the RESULT is a WORD, I will change the program, and use Two's compliment to get the RESULT.

I will EDIT the description of the 'SELF TEST RESULT'S also my description here, as I find out how it works.
C.
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I'm getting these results from this program.
I'm suspicious that each of the 3x results is the same.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
No, it is not suspicious, because you print only x values :)

Hserout str_x_nc, ", ", str_x_nc, ", ", str_x_nc, ", ", CrLf
Hi J, Lesson1: 'Don't copy and paste when your tired' (I'm always tired;))

Here are the results to this program:

I added this section (ADDED INTO SELF TEST MODE), or it wouldn't READ DRDY

I've updated #30. I think I've got it now, and the results look ok.
C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
All results are jumping up to 5 digits +-, and I'm wondering how the results can be smoothed, probably by averaging them.

This will need to be carried out before the Magmaster correction, so most probably the RAW data.

Which is the best way to do this, please?

EDIT: It may be possible to only average the LOW BYTE??
EDITEDIT: Just realised, that if the result of an XYZ READing changes from 0 to 359 or 359 to 0, this will spoil the average.
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi,
All results are jumping up to 5 digits +-, and I'm wondering how the results can be smoothed, probably by averaging them.

This will need to be carried out before the Magmaster correction, so most probably the RAW data.

Which is the best way to do this, please?

EDIT: It may be possible to only average the LOW BYTE??
EDITEDIT: Just realised, that if the result of an XYZ READing changes from 0 to 359 or 359 to 0, this will spoil the average.
C
You can calculate separately the average of x and y and then the angle, arctan ( avgX, avgY)
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
You can calculate separately the average of x and y and then the angle, arctan ( avgX, avgY)
Hi J,
Just tried this, which kind of works, but not well enough, at the crossover point or if moved quickly, it can get completely way off results. Scroll down!
I'll stick to the 5DEG variant without it for now.
Thanks, C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi C,

As I can't read that code, are you taking multiple reads and averaging?
Hi JP,
The MAIN LOOP is continuous, and READs all of the XYX registers each time.
The example I showed, is only for the XL BYTE. I think only one of the X and Y BYTEs needs averaging.
But as mentioned, this may cause more problems that cures.
C
 

jjw

Joined Dec 24, 2013
823
Hi JP,
The MAIN LOOP is continuous, and READs all of the XYX registers each time.
The example I showed, is only for the XL BYTE. I think only one of the X and Y BYTEs needs averaging.
But as mentioned, this may cause more problems that cures.
C
You need the 16bit words x, y for averaging, because the signs are needed to separate the quadrants.
Use the singles, which have correct signs.

The averaging code looks strange. Where do you get the number 1275 from?
To average make a sum of N values and divide it by N.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
You need the 16bit words x, y for averaging, because the signs are needed to separate the quadrants.
Use the singles, which have correct signs.

The averaging code looks strange. Where do you get the number 1275 from?
To average make a sum of N values and divide it by N.
Hi J,
It looks to me that at 0 and 180Deg, the HB switches from 0 to 255, and the LB counts degrees, so I was only working on the LB, before the two'2 compliment calculation. Is this impossible?

Regarding my calculation #36. As the average number is, in this test, (5) when the compass switches from 255 to 0 the average XLAVE is 0X5 = 0 and from 0 to 255 the average is 255X5 = 1275.

On each LOOP I add XL to XLAVE, then divide by 6 to get the new XL, then multiply it by 5 to get the new XLAVE.
C.
 
Top