Setting up AK8963C Compass chip SPI Oshonsoft

Discussion in 'Embedded Systems and Microcontrollers' started by camerart, Apr 11, 2019.

  1. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Last edited: Apr 11, 2019
  2. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi,
    I've just spotted this:
    LAYOUT CONSIDERATIONS Besides keeping all components that may contain ferrous materials (nickel, etc.) away from the sensor on both sides of the PCB, it is also recommended that there is no conducting copper under/near the sensor in any of the PCB layers. See recommended layout below. Notice that the one trace under the sensor in the dual supply mode is not expected to carry active current since it is for pin 4 pull-up to VDDIO. Power and ground planes are removed under the sensor to minimize possible source of magnetic noise. For best results, use non-ferrous materials for all exposed copper coding.

    I've made all of my modules with an underside ground plane, which I'll need to change.

    C.
     
  3. jpanhalt

    Expert

    Jan 18, 2008
    6,945
    1,451
    Have you tested that change? That is, a smallish drill will remove the copper easily. Most drills are 118° included angle, aircraft and sheet metal drills are often 135°. That will remove a wider area with less depth. Higher angles don't center as well. If you have access to a mill, of course you can use a 3 mm mill bit.
     
  4. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi JP,
    I've just scraped the copper off the bottom area of a test chip, with a scalpel. Now to test it.
    C
     
  5. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi,
    Just tried to run MAGMASTER, but get a 'serial port' error :( MAGVIEWER runs ok.
    Any ideas please?
    C.
     
  6. jpanhalt

    Expert

    Jan 18, 2008
    6,945
    1,451
    This is the Compass-Click bottom with the AK8963. unfortunately the RoHS label covers the area of interest. Top and bottom photos are on that site, if you need any help in routing. Apparently, it has a copper ground plane under the chip (circled area). Also confirmed by inspection of my board.

    upload_2019-4-11_7-32-25.png

    EDIT: I thought I had edited that comment out before posting. It was for a different BOB.
     
    Last edited: Apr 11, 2019
  7. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi JP,
    I made my own boards from the AK8963C chips. I have them routed and working, but the MAGMASTER settings are causing problems, so I'm going through the instructions again.
    C
     
  8. jjw

    Active Member

    Dec 24, 2013
    351
    37
    I changed the atn function to work CW.
    No need to subtract atn from 360. ( DEG=360-atn())

    Code (Text):
    1.  
    2. Function atn(x As Single, y As Single) As Single
    3.  
    4. Const b = 0.596227
    5. Dim tn As Single
    6. Dim at1 As Single
    7. Dim at2 As Single
    8.  
    9. If y = 0 Then
    10.   y = y + 0.000001  'to prevent divide by zero
    11. Endif
    12.  
    13. tn = x / y
    14. at1 = 90 * tn * (b + tn) / (1 + 2 * b * tn + tn * tn)
    15. at2 = -90 * tn * (b - tn) / (1 - 2 * b * tn + tn * tn)
    16.  
    17. If x >= 0 Then
    18. If y > 0 Then
    19.   atn = 360 - at1
    20. Endif
    21. Endif
    22.  
    23. If x >= 0 Then
    24. If y < 0 Then
    25.   atn = 180 + at2
    26. Endif
    27. Endif
    28.  
    29. If x < 0 Then
    30. If y < 0 Then
    31.   atn = 180 - at1
    32. Endif
    33. Endif
    34.  
    35. If y > 0 Then
    36. If x < 0 Then
    37.   atn = at2
    38. Endif
    39. Endif
    40.  
    41. End Function  
    42.  
    43.  
    44.  
    45.  
     
  9. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi J,
    Magic, thank you.
    C.
     
  10. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi,
    Is anyone using MAGMASTER/VIEWER?

    I can get Magviewer to work most times, but Magmaster has stopped working. I've tried a different computer, no change. I had a pair of HC-12 radios and FTDI USB adapters, then tried hard wiring, no change.

    I get serial port error each time.
    C.
     
  11. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi,
    It looks as though the best thing is, to open Magviewer/USB input, which is working, and Magmaster/no USB input, and manually input the viewer READings into Magmaster to get the calculation.

    Looking at the compass transmissions, I'm getting very varied outputs, so I'm now looking at the DRDY and HOFL in the AK8963C data sheet, to see if the READings can be less varied.

    C.
     
  12. jpanhalt

    Expert

    Jan 18, 2008
    6,945
    1,451
    Hi C,
    About 2 years ago I posted a movie of my AK8963. Here is a link to that movie (sorry it is zipped): https://forum.allaboutcircuits.com/attachments/my-movie-zip.116328/

    Here is a snippet from that post that describes my settings (e.g., 100 Hz readings, read x16 in 16-bit mode).
    You may want to compare your stability with what that shows.

    John

    EDIT: Here's a link to that original post: https://forum.allaboutcircuits.com/threads/ecompass-short-magnetometer-review.129961/#post-1067505
     
  13. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi JP,
    Thanks for the links.
    Your movie is much more stable.

    EDIT: Did you use SELF TEST MODE--------------SINGLE MEASUREMENT MODE----------HOFL---------- OR DRDY in your code ?
    C.
     
    Last edited: Apr 12, 2019
  14. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi,
    In #10, I reported that Magviewer is working, but Magmaster isn't.

    I had a section of code that does a DEG calculation, plus a DEG HSEROUT, along with the 3x compass READings. Once the DEG part is removed, Magmaster works ok now.
    C
     
  15. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi,
    I'm re-reading the AK8963C data sheet, and am trying the SELF TEST routine.

    Here is a program:
    Also the D/S SELF TEST page
    Also the result.
    Does this look correct?
    C
     
  16. jjw

    Active Member

    Dec 24, 2013
    351
    37
    The results are not ok. X, Y cannot both be zeroes.
    Should'nt the x, y, z values be b(0) to b(5) now they start from b(1).
     
    Last edited: Apr 16, 2019
  17. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi J,
    I changed the B() values to 0-5 and got all zeros.
    Then changed the b() values to 6-11 and got these results: 224, 96, 64, 64, 144, 240

    so 224 is position 6. These appear to be other register READings, which appears to mean that the DATA isn't being READ.


    C
     
  18. jjw

    Active Member

    Dec 24, 2013
    351
    37
    You don't check the rdy bit when reading xyz.
     
  19. camerart

    Thread Starter Senior Member

    Feb 25, 2013
    1,149
    38
    Hi J,
    Did you read number4 on the self test mode at #15?

    Just looking at those results #17 for clues.
    224 = 11100000
    96 = 01100000
    64, 64 = 01000000
    144 = 10010000
    240 = 11110000
    All of the '1's are at the higher end of the BYTE where e,g,0x09 should READ BITs 3 and 4?
    C.
     
    Last edited: Apr 17, 2019
  20. jjw

    Active Member

    Dec 24, 2013
    351
    37
    What is number4?
    In your program there is no check of drdy before reading x, y, z
     
Loading...