10 years, 8 months ago.

Adxl335 Outputting Faulty Data

Hello Developers,

I have connected an adxl335 accelerometer to an mbed microcontroller (LPC1768). The accelerometer is powered using the 3.3V pin from the LPC1768. The accelerometer is connected to a breadboard using long centered pins (https://www.sparkfun.com/products/12693). I have the following 2 questions:

1) What is the expected output from the x,y and z pins when the microcontroller is flat? I expect the x and y pins to be approximately 0 and the z pin to be 1g (0.1V?)

2) A lot of the time when I am moving the accelerometer I start to get output values that make no sense. And sometimes I get different results when the accelerometer is in the same position (for example after rotating 360 degrees the reading are no longer the same as before)? Could this be caused due to the method I have connected the accelerometer to the breadboard? How can I fix this problem (solder the pins to the accelerometer)?

#include "mbed.h"
 
AnalogIn inputx(p20); // input pins 20,19,18 for x,y,z axis respectively.
AnalogIn inputy(p19);
AnalogIn inputz(p18);
Serial pc(USBTX,USBRX);  //Serial class for transmission of serial data
 
int main() {
    pc.baud(9600);   // fixing a constant baud rate of 9600 bps at which mbed will interact with computer
    float x=0,y=0,z=0; // variables for x,y,z axes
    
    while(1)
    {  
            
        x = inputx;
        y = inputy;
        z = inputz;
        pc.printf("%f,%f,%f *",x,y,z); 
        
    }   
}

Any help would be appreciated, Astryl

Be the first to answer this question.