Go Down

Topic: Single Axis Accelerometer Breakout Board - ADXL193 +/-250g (Read 374 times) previous topic - next topic

Anish142

I need some help with this sensor. I can't seem to find any sample code and also am not an experienced programmer. If anyone has some sample code for this sensor your help would be appreciated.

knut_ny

#1
Feb 16, 2014, 08:00 pm Last Edit: Feb 16, 2014, 08:31 pm by knut_ny Reason: 1
Sensor output goes to an anlog input.
Read the datasheet..: It says ouput is 8mV/g
Code: [Select]
float a;

void setup()
{
Serial.begin(9600);
}

void loop()
{
a = (analogRead(A0)-511) * 4.8875855 ; //millivolt
// 5/1023=0,0048875855 V/step
a = a / 8; // 8mV/g
// all calc can be done in one calculation
Serial.println(a,2); // G-value
// shoud be 0 when not moving
// expect small values when 'shaking'
}
Ny


knut_ny

Read datasheet to find if ST shoud be wired hi og low.
Data out to A0 to match example..
Ny

Anish142

Thanks, I am still getting negative values. Im not sure as to why this is happening

knut_ny

small nes is OK .
Change the numer 511 up/down a litte till you get 0 out when still.
Ny

Anish142

thanks it works now. It moves about 1-2 everytime I shake it. Is this expected? thanks for your help.

knut_ny

OK... you mangage to shake it with 2G..
Tap it on the table.. you'll reach 10G+ (if program reads at the right momemt)

This sensor is best used to measure akseleration in rockets at launch..
..or inn collision tests
Ny

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy