Go Down

Topic: ADXL202 (Read 1 time) previous topic - next topic

Nelutu88

HEllo!
I' m new in "Arduino programing", I have " Arduino Duemilianove". I want to measuring acceleration with ADXl202, but the problem is ....i cant interfacing the ADXL202 with uC ATmega328. If somebody can help me,with a good code, or.... Thank u! Litel cod here...where I try to do this. U can contact me at e-mail adress trif_ioan88@yahoo.com also. Thank u again. Have a nice day!

AWOL

#1
Mar 22, 2011, 12:08 pm Last Edit: Mar 22, 2011, 12:55 pm by AWOL Reason: 1
You must like spam!
What is the problem?

printDouble only really works well if you pass it a double parameter (which you aren't doing). (and on the Arduino, double is the same as float)

Personally, I'd get rid of the LCD, and just use the serial monitor until I'd got the accelerometer working.

Code: [Select]
accelerationX = (raportX - 500) *8; //acceleratia pe X
   accelerationX = digitalRead(xPin);
   digitalWrite(xPin,accelerationX);

What's that supposed to do?

For persistent variables like your totals, you need to change their scope to global.

As a courtesy, it is preferable if you get rid of all the commented-out code before posting.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

WillR

What is wrong with the example code supplied with the version 022 compiler?

It worked fine for me.
Just another Hacker

Nelutu88

I want to read and measuring the duty cycle for can calculate acceleration like here http://datasheet.octopart.com/ADXL202AE-Analog-Devices-datasheet-64757.pdf ,then with LCD visualization that values. With this code my LCD displays "-4000.0" on both axes. I try exemple with "Memsic 2125 Accelerometer" from arduino exemples, and there LCD displays 0 and 1 :(. I dont now how to do !!
Here is a last version for this code! Thank u 4 attention! :)

AWOL

#4
Mar 22, 2011, 02:19 pm Last Edit: Mar 22, 2011, 02:31 pm by AWOL Reason: 1
You're still providing printDouble with "int" arguments.

What is this:
Code: [Select]
  accelerationX = digitalRead(xPin);
   digitalWrite(xPin,accelerationX);

supposed to do?  (I think I've already asked, but just to be sure, I'll try one more time)


This is how I read your code:
Code: [Select]
  int T1X = pulseIn(xPin,HIGH); 
   int T1Y = pulseIn(yPin,HIGH); 
   int T2X = pulseIn(xPin,LOW);  //I dont now if is necesary to measuring and T2 
   int T2Y = pulseIn(yPin,LOW); //for now what is the  period when pulse is LOW,
  //because in data sheet T is 1...10 ms
 
   int TX = T1X + T2X;
   int TY = T1Y + T2Y;
   int raportX = T1X/TX;
   int raportY = T1Y/TY;   
   int accelerationX = (raportX - 500) *8;
   int accelerationY = (raportY - 500) *8;
 
   
    accelerationX = digitalRead(xPin);
    digitalWrite(xPin,accelerationX);

    accelerationX = (raportX - 500) *8;
    accelerationY = digitalRead(yPin);
    digitalWrite(yPin,accelerationY);
   
    accelerationY = (raportY - 500) *8;
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nelutu88

ok. so in this code :read "accelerationX" and with digitalWrite() I want to send to xPin value of accelerationX , to LCD. I dont now if  is 100 %  OK :( or my interpretation isn't ok. :|

AWOL

Quote
I want to send to xPin value of accelerationX

You can't send an (effectively) analogue value to a digital pin - that doesn't make sense.
All that digitalWrite will do is send zero (iff accelerationX == 0) or one (if accelerationX != 0)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nelutu88

OK, understand, can u write me a parth of code where read the values of this sensor ADXL202, for initialisation  corect my application.? If u can, and have a time, of course :)

AWOL

Reply #2 suggests there already is example code (I don't use 022)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up