Electronic – Measuring accelerometer frequency with an oscilloscope


I've got a VTI CMA3000-D01 digital accelerometer and I'm controlling it via SPI from a Texas Instruments CC2540 chip using the embedded 8051 MCU.

In the datasheet for the CMA3000, it mentions that in 2g mode, the output sample rate is 400 Hz or 100 Hz (depending on how the accelerometer is configured). There's also a "Motion Detection Mode" which works at 10 Hz sample rate.

What I'd like to do is change the configuration of the accelerometer to either 400 Hz mode or 100 Hz mode and measure the frequency on an oscilloscope to verify that I've actually made such a change. This is mostly for me to better understand how to make useful measurements with an oscilloscope, and to get a better grasp on SPI.

I've recently purchased a Rigol DS1052E oscilloscope, so I'd like to know how to hook this up to my accelerometer to measure the output frequency, and what settings I need to use on the oscilloscope to make such a reading, and if it's even possible.

I've tried connecting the probe (at 10x attenuation) on the scope to the SCK lead on the accelerometer and the ground lead from the probe to the ground on the circuitboard, then hitting the "Auto" button on the oscilloscope, but it gives me a waveform with a frequency and voltage that jumps around:

enter image description here
enter image description here

I was expecting to see a square wave with a frequency of 100 Hz (this is what the accelerometer is currently set to in my software), but I got a sine-looking wave. Now the above images may actually be correct, but I don't know enough to determine if they are, which is why I was hoping someone more knowledgeable in regards to SPI and oscilloscopes might be able to give me some direction, or tell me what I need to read to better understand this stuff.

It would also be great to know how to read output from the MISO port on the accelerometer to see what data is being sent back to the MCU. I'm not sure if this is possible to do with only a scope, or if I'd need a logic analyzer to see this data. Thanks in advance.

Best Answer

The problem is that you are using a MEMS digital accelerometer, and what you are reading is the SCK (serial clock) pin of the serial interface. In order to function, that sensor needs to be interfaced with a microcontroller, that sets it for the sampling frequency, the range and so forth.

So you don't have to expect a square wave with 100Hz frequency, but a fast (depending on the bus bitrate) spike, corresponding to a transmission. Expanding the spike, if the scope is fast enough, you should then see the clock square wave inside the spike.

Moreover, if you don't set the SPI interface correctly, the uC will not generate the clock (the sensor operates in slave mode), and you won't read any value.

If you want to see a 100Hz signal, you could probe the Int pin, which sends an interrupt to the microcontroller every time a measure is available. Then, if you handle the interrupt from the microcontroller properly, you wil see the pulse corresponding to the transmission every 10 ms (100Hz).

But make sure that you're not using motion detection; in that case, only when an acceleration is measured, it will generate the interrupt.

To read the data at the SPI port, the simplest thing is to configure the communication with the sensor; otherwise, it won't send data at all. Then, check if the microcontroller is getting the interrupts and if it's reading the data the sensor gives; you can use a timer to add a timestamp to values and check the frequency they come.

(still WIP)