Post Go back to editing

ADcmXL3021_data_acquisition_issue

Background:

Raspberry Pi 2B to get the vibration data in ADcmXL3021 sensor via SPI, in RTS mode.

ADcmXL3021 datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADcmXL3021.pdf

Issue

When I send the command to the sensor, most data are 0s, as the data format should be

And the data I get as below:

As I show above, the data I get should have 200 bytes, include the header 0xAD00, -x -y -z Vibration data and Temperature data, CRC bits. But now seems like almost all 0s.

Hardware connection:

ADcmXL3021 is powered by individual power supply(3.3V30.6mA)

NO

Raspberry Pi 2B

ADcmXL3021

1

SPICE0

CS

2

SPICE1

SYNC/RTS

3

SPI MISO

DOUT

4

SPI MOSI

DIN

5

SPI SCLK

SCLK

CS set as low, SYNC/RTS set as high(RTS need this pin high to keep conversion active).

Use python spidev for SPI communication, code as below:

=======================================================

# -*- coding:utf-8 -*-

#for ADcmXL3021 Sensor data acquistion

 

import time

from spidev import SpiDev

 

spi=SpiDev()  #build a slave

spi.open(0,0)  #Raspberry Pi SPICE0 Pin(the other is SPICE1), this is for CS

spi.mode=0b11  #RTS mode (SPI mode3)

spi.max_speed_hz=7800000  #for Raspberry Pi is 7.8,15.6MHz, but for ADc should be 12.5~14MHz, so I set as 7.8M, as a little slower should be ok

spi.lsbfirst = False   #msb,high bits first

spi.cshigh=False  #cs set as low

spi.bits_per_word=8   #Raspberry only support 8 bits, even ADc output data is 16 bits, I think just need to combine 2 received data

spi.writebytes([0xBE,0x08,0x00])  #send command to get the data

time.sleep(0.012)  #12ms delay between command and data receiving

data=spi.readbytes(200)  #read data in RTS mode,and then conbine 2 data into 1(here I not give out the code as I think it's easy to do)

print(data)

==================================================================

Here, why I send the command is form the info in datasheet:

1011 1110 0000 1000 0000 0000:0XBE 0x08 0x00

From my side, maybe it’s caused by the commands format I send to the sensor is wrong.

also, different from other register map, the map of ADcmXL3021, has 7 pages, not sure how to send the command to tell the sensor which page I select, as I think before write and read to the register, need to give the register is in which page.

Hope you can share your point, many thanks.

Edit Notes

forget to post the timing diagram
[edited by: WallXu at 3:51 AM (GMT 0) on 22 Sep 2019]
  • Hi,

    I am moving this thread to its proper community https://ez.analog.com/mems. Someone here might be able to help you.

    Thanks,

    Jellenie

  •  I have been working on raspberry pi 4 and after a week of struggle, I decided to check the SPI output of EZUSB-FX3 and the evaluation software provided by analog devices and found out that the control frequency is about 14MHz and somehow the output format for cs, sclk and MOSI is very different than of spidev of raspberry pi module. The SYNC/RTS pin also enabled throughout the read process in the eval software. I tried to emulate the similar spi behavior using python and spidev a(big failure somehow spidev doesn't  show the same behavior as fx3u).

    I believe that it has something to do with the SCLK frequency. Have you ever got your code to work? Me with my limited knowledge of visual basic. It's almost impossible for me to reverse engineering the evaluation program source code provided on GitHub. Worst case scenario a c++ source code for fx3 controller would have been easier for developers to understand. And the support from 'analog devices' for such a premium sensor is non-existent. I wonder what's the reason?

  • Hi,
    according to the shown code, you are only reading the first frame, which is always garbage and should be ignored according to the data sheet.

    In my experience it helps to reset the sensor before initiating a spi transfer, because it clears the io-buffers.

    Regards,
    Ph