Maker Pro
Maker Pro

AK8963 Compass peripheral on 18F4620 intermittent error?

camerart

Aug 18, 2010
120
Joined
Aug 18, 2010
Messages
120
Hi,
Here's a puzzle!
I made some Compass breakout boards for an AK8963C chip. x5 (Iphone5)

I have PCBs x3, some with 3x different peripherals, using SPI. 1x PCB with only the Compass, and a simple program on the 18F4620.

I've been testing each peripheral on separate programs, till almost satisfied, they're working well. Untill I added them all into one program. Now the previouslt reliable Compass, sometimes works, some times doesn't, with no clue to why.

I've been on another forum, checking the PCBs continuity, also Digital analysis, oscilloscope, with no clear result.

If anyone has ideas what may be wrong, let me know, and I can repeat any test again, please?

Camerart.
 

Attachments

  • AK8963 Break out.jpg
    AK8963 Break out.jpg
    279.2 KB · Views: 4

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,743
Joined
Nov 17, 2011
Messages
12,743
The problem may as well be your program, not the hardware. How about posting the relevant code snippets? Together with a schematic of the actual wiring, of course.
 

camerart

Aug 18, 2010
120
Joined
Aug 18, 2010
Messages
120
The problem may as well be your program, not the hardware. How about posting the relevant code snippets? Together with a schematic of the actual wiring, of course.
Hi H,
I use Oshonsoft BASIC only.
Here is the main snippet:
And Schematic although as mentioned there are 3x different PCBs with slightly differing tracks.
----------------------------------------------------------------------
'READ COMPASS XYZ REGISTER


addr = 0x80 '!!!!!!!!!!!!!!!!!

compss = 0 'CHIP SELECT COMPASS ON
For i = 0 To 18 '5 'READ XYZ Xx2 Yx2 Zx2
SPISend addr
SPIReceive data
compss = 1
WaitUs 10
compss = 0
b(i) = data
addr = addr + 1
Next i
compss = 1 'CHIP SELECT COMPASS OFF


'compss = 0 'CHIP SELECT COMPASS ON
'For i = 0 To 7 '18 '5 'READ XYZ Xx2 Yx2 Zx2
'addr = 0x80 + i
'SPISend addr
'SPIReceive data
'Next i
'compss = 1
'WaitUs 10

wIa_raw = b(0)
info_raw = b(1)
st_1_raw = b(2)

x_raw.LB = b(3) 'BYTE
x_raw.HB = b(4) 'BYTE
y_raw.LB = b(5)
y_raw.HB = b(6)
z_raw.LB = b(7)
z_raw.HB = b(8)

Hserout "WIA ", #wIa_raw, " ", "INFO ", #info_raw, " ", "XRAW LB ", #x_raw.LB, " ", "XRAW HB ", #x_raw.HB, " ", "YRAW LB ", #y_raw.LB, " ", "YRAW HB ", #y_raw.HB, " ", "ZRAW LB ", #z_raw.LB, " ", CrLf

-----------------------------------------------------------------------------
NOTE: [ ' = Commented out ]
C
 

Attachments

  • SCH.jpg
    SCH.jpg
    261.6 KB · Views: 5

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,743
Joined
Nov 17, 2011
Messages
12,743
The schematic doesn't show how the compass modules are connected to the processor. Especially how the chip selects are connected.
There are two ways to connect multiple SPI slaves to one SPI master controller:
independent: requires three independent chip select signals. This is incompatible with your code as obviously you have only one compss signal.
daisy chained: This incurs a delay of one clock cycle per component, which in my view is incompatible with your code as in your code each SPI slave is treated in the same way.
 

camerart

Aug 18, 2010
120
Joined
Aug 18, 2010
Messages
120
The schematic doesn't show how the compass modules are connected to the processor. Especially how the chip selects are connected.
There are two ways to connect multiple SPI slaves to one SPI master controller:
independent: requires three independent chip select signals. This is incompatible with your code as obviously you have only one compss signal.
daisy chained: This incurs a delay of one clock cycle per component, which in my view is incompatible with your code as in your code each SPI slave is treated in the same way.
Hi H,
If you check centre of the Schematic you can see the 3x SPI connectors, plus a list of C/S for each of the peripherals, on PORTD.

The COMPSS is the C/S for the Compass and the sequence is the READ of the REGISTERS on the Compass in turn (LOOP).

Here's the PCB if that makes it clearer.
C
 

Attachments

  • PCB.jpg
    PCB.jpg
    355.1 KB · Views: 2

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,743
Joined
Nov 17, 2011
Messages
12,743
check centre of the Schematic you can see the 3x SPI connectors, plus a list of C/S for each of the peripherals, on PORTD.
I have seen the SPI connectors, but the assignment to CS on port D is not very obvious.
However, your code does not show the activation of the differnet CD signals for each module. You always activate the single signal compss.
I'd expect activation of different CS signals for each iteration of the loop according to the assignment of chip select signals to Port D.
 

camerart

Aug 18, 2010
120
Joined
Aug 18, 2010
Messages
120
I have seen the SPI connectors, but the assignment to CS on port D is not very obvious.
However, your code does not show the activation of the differnet CD signals for each module. You always activate the single signal compss.
I'd expect activation of different CS signals for each iteration of the loop according to the assignment of chip select signals to Port D.
Hi H,
I've attached the full program:
NOTE TRISD and SYMBOLS.
C.
 

Attachments

  • 18F4620 8MHz XTL TRANSMITTER 231019 0900.txt
    25.5 KB · Views: 1
Last edited:
Top