Thursday 7 July 2016

More MMA8452 accelerometer (and Arduino) testing

In "real work" we got a prototype device working for  a client who said they loved the idea and commissioned a set of audio devices. The idea is that each device is a ceramic shell-like shape, with an mp3 audio player, speaker and accelerometer (plus, of course, an Arduino, urgh!) embedded inside.

The shells sit in a vertical position, in their holders, but when they are lifted up and placed against the ear, the mp3 player triggers a short audio sample. Because the shell acts like a natural amplifier, and we want the audio to only be audible when it is placed right up against the ear, a tiny 1cm piezo speaker connected directly to the pwm outputs of the audio module is plenty loud enough.

There is more than one sound file in the mp3 module/player. To play different sounds, you simply rotate the shell as it is pressed against your ear.

So we poll the accelerometer and when the y-axis is zero, we take it that the device is "horizontal". We then read the x and z axis values to work out the amount of rotation applied.



In recent testing (albeit with a different accelerometer module for the actual prototype) we simply plotted the x, y and z axis values over time, while rotating the accelerometer around the y-axis. The results looked something like this.


Which is pretty much what we were expecting.
So we ordered up a bunch more MMA8452 accelerometers and prepared to make a few of these devices for the project.

Except this time, something weird happened with the x,y,z results.
When placed on a flat surface, and we expected all values to read zero, there was a constant "flickering" on each axis - it would occasionally go from near zero to near maximum.



These values were arrived at while the accelerometer was on a flat surface and not moving!
For some reason, the x-axis value hovers around zero. But every now and again, spikes to the full/max value, around 1, then quickly falls back to zero.

We thought that perhaps this  is something we might be able to take out in software. But it's not. If we rotate the accelerometer around the y-axis, as before, and plot the x and z values, we get this;



You can sort-of see the 90-degree offset in the x- and z- axes. But the constant spiking is something of a worry. It's as if the axis values are getting "mixed up" - the x value is being reported as the y value and so on.

Whatever it is, it's a mess.
And has put a bit of a question mark over the whole thing!
Unless we can be guaranteed that our accelerometers can be relied upon, we could end up with audio devices that trigger at random, and play any old mp3 file, in any old order.

In which case we should just ditch the accelerometer and write a random number generator in firmware! More investigations will continue over the coming days....

No comments:

Post a Comment