Pages: [1]   Go Down
Author Topic: ADXL202  (Read 844 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

* ADXL202 code.txt (3.18 KB - downloaded 10 times.)
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
« Last Edit: March 22, 2011, 06:55:07 am by AWOL » Logged

"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.

Georgina Ontario
Offline Offline
Sr. Member
****
Karma: 5
Posts: 437
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

It worked fine for me.
Logged

Just another Hacker

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad. I dont now how to do !!
Here is a last version for this code! Thank u 4 attention! smiley

* NEW ADXL202 code.txt (2.13 KB - downloaded 7 times.)
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're still providing printDouble with "int" arguments.

What is this:
Code:
  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:
  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;
« Last Edit: March 22, 2011, 08:31:46 am by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad or my interpretation isn't ok. smiley-neutral
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Reply #2 suggests there already is example code (I don't use 022)
Logged

"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.

Pages: [1]   Go Up
Jump to: