digikey dksb1002a evaluation board 3-axis accelerometer arduino uno microcontroller board acquiring...

7
DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the lab

Upload: herbert-sutton

Post on 18-Dec-2015

237 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

DIGIKEY DKSB1002A Evaluation Board3-axis accelerometer

Arduino Unomicrocontroller board

Acquiring Data from anADXL335 Accelerometer

living with the lab

Page 2: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

• DKSB1002A is a prototyping board purchased for $20 from Digikey • Screw holes for mounting board onto “object of interest”• Board is ~ 20mm square• ADXL335 3-axis accelerometer chip

• 3-axis• ±3g

• COM - ground• VSS - power (we will provide 5V)• X - acceleration in x-direction• Y - acceleration in y-

direction• Z - acceleration in z-direction

DKSB1002A Evaluation Board and ADXL335 Accelerometer

xy

z

this small chip is the ADXL335 accelerometer(this is an older model . . . they are even smaller now)

living with the lab

2

the DKSB1002A is a board used to evaluate the accelerometer; if you were putting an accelerometer in a device like a cell phone, you would only use the ADXL335 chip (and maybe some capacitors)

Page 3: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

COM - groundVSS - power (we will provide 5V)X - acceleration in x-directionY - acceleration in y-directionZ - acceleration in z-direction

Implementing a 3-axis Accelerometer: Wiring to Arduino

living with the lab

3

Page 4: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

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

void loop(){ int xaccel = analogRead(0); int yaccel = analogRead(1); int zaccel = analogRead(2); unsigned long timevar = millis(); Serial.print(timevar); Serial.print(" "); Serial.print(xaccel); Serial.print(" "); Serial.print(yaccel); Serial.print(" "); Serial.println(zaccel);}

Programming

living with the lab

4

associates a time witheach set of accelerations

Page 5: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

Calibration

xy

z

living with the lab

5

Page 6: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

Angle Measurement

xy

z

1g (perceived vertical acceleration)

ax

x

x

+x

θx = asin(ax/g)

living with the lab

6

Page 7: DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board Acquiring Data from an ADXL335 Accelerometer living with the

Example Application

living with the lab

7

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

void loop(){ int xaccel = analogRead(0); int freq = 1500+xaccel*2; tone(7,freq);

Serial.print(xaccel); Serial.print(" "); Serial.println(freq);}

The piezospeaker below outputs a frequency that varies with the acceleration in the x-direction. The equation for computing the frequency is chosen so that the device makes an audible noise that varies when rotating or shaking the device.