Hi,
I have an ADXL202JE accelerometer from Analog Devices in my hands right now and I'm trying to figure out exactly how it works. I have it connected to a Basic Stamp II as follows:
I have four leads coming off the ADXL connected to my Stamp.
ADXL STAMP
+5 Vdd (+5V DC)COM Vss (Gnd)
Xout Pin 4
Yout Pin 5
I'm using this code:
'{$STAMP BS2}
FREQ VAR WORD
T1x VAR WORD
T1y VAR WORD
T2 VAR WORD
LOW 7
HIGH 3
INPUT 4
INPUT 5
COUNT 8,500, FREQ (Not sure what this is for...)
T2=25000/(FREQ/20)
T1_LOOP:
PULSIN 5,1,T1x
T1y = 2 * T1x
PULSIN 4,1,T1y
T1x = 2 * T1y
DEBUG "FREQ: ",DEC FREQ, " ", "T1x: ", DEC T1x, " ", "T1y: ", DEC T1y, CR
GOTO T1_LOOP
I'm not sure where T2 comes into play. I know that X and Yout are giving me the Pulse Width Duty Cycle, so I need to know T2 in order to determine the Width of T1x or T1y with respect to T2. But how do I determine T2?
Right now when I run this code I get lots of zeros, but not much else. If I shake the ADXL quite hard I can get the numbers to change - but I must be doing something wrong. I know that the ADXL is more sensitive than this!!
If anyone has interfaced with the ADXL could you please lend me a hand!!!
My end goal is to build a balancing bot - If I can get the accelerometer to work!
Kelly