Hi all,
I've built a device, using an ADXL335 accelerometer running into the Bela. I ran a number of tests a few days ago, where the 'resting' values for the device sitting flat on the table looked like this:
(Note that the horizontal axis is time (from 0 to 1 second), and the vertical axis is the unadulterated value coming in from the ADXL335. Unfortunately I wasn't smart enough to label the individual axes before wiring, so I'll need to work out which is x, y, and z experimentally.)
A few days later, I've come back to re-test the device, and the resting values are looking completely different:
In order to get the raw numerical data to analyse, I'm using this C++ code:
#include <Bela.h>
#include <OSCServer.h>
#include <OSCClient.h>
OSCServer oscServer;
OSCClient oscClient;
int remotePort = 11535;
const char* remoteIp = "192.168.7.1";
bool setup(BelaContext *context, void *userData)
{
oscClient.setup(remotePort, remoteIp);
return true;
}
void render(BelaContext *context, void *userData)
{
oscClient.queueMessage(oscClient.newMessage.to("/analog0").add(analogRead(context, 0, 4)).end());
oscClient.queueMessage(oscClient.newMessage.to("/analog1").add(analogRead(context, 0, 4)).end());
oscClient.queueMessage(oscClient.newMessage.to("/analog2").add(analogRead(context, 0, 4)).end());
oscClient.queueMessage(oscClient.newMessage.to("/analog3").add(analogRead(context, 0, 4)).end());
}
void cleanup(BelaContext *context, void *userData)
{
}
And this Pd patch to receive it:
Both of these are working fine. I then format the text and import it into Numbers.
I was hoping you could shed some light on this - have you encountered this problem before? Does it have something to do with the way the signals are interpreted by the C++ code? Or have I just, somehow, broken the accelerometer?
I've used the same C++ code for all of the tests so nothing has changed there. I've heard that you can calibrate the ADXL335 in different ways depending on how it's connected, but the language of the ADXL data sheet is absolutely foreign to me, and I hoped you might be familiar with this problem, as you'd used the ADXL335 in one of your examples.
Thanks so much for your help!