You are here

problem in ADXL 335 accelerometer interfacing | Cypress Semiconductor

problem in ADXL 335 accelerometer interfacing

Summary: 22 Replies, Latest post by Bob Marlowe on 25 Sep 2016 10:40 AM PDT
Verified Answers: 8
Last post
Log in to post new comments.
user_259690047's picture
User
40 posts

Hi all

I used the analog adxl335 accelerometer for measuring the tilt angle. Formula i used for this is theta = xout  /  square root(y2+z2). when i displaying the result to LCD it showing 1  1  0 or  0  0 1 or  0  1  0 of x, y, z angle value. any one tell me what mistake in that. 

HIMA's picture
Cypress Employee
244 posts

Hello

 

Can you attach the complete project.

 

Thanks,

Hima

user_242978793's picture
User
1102 posts

Make these changes to PSoC Creator #define <math.h>

1) Click Project

2) click Build Settings

3) open the Linker Settings under ARM GCC 4.9-2015-q1-update

4) under Additional Libraries add an m

user_242978793's picture
User
1102 posts

Also turn newlib-nano Float Formatting to true this is set to false as a default.  Also define  the Variable to float in the program

user_1377889's picture
User
9829 posts

And do not forget to increase the heap size to 0x200 (.cydwr view, System tab)

 

Bob

user_259690047's picture
User
40 posts

thanks to all.

I attached here my code.  please any one check and tell me the problem in that.

user_242978793's picture
User
1102 posts

Please send the complete program  by pressing file and then select workplace bundle and select minimal and send that too us so we can check the code. 

user_259690047's picture
User
40 posts

Hi bob.

i have changed my code once again now it not showing anything. only the x, y, z values are getting but not others like aglx or result1.

i added the math.h library also. i am hoping  you may solve this problem. 

                                                                                        thanks in advanced 

user_1377889's picture
User
9829 posts

You assign float values from functions as sqrt(), atan() to unsigned integers. This will drop (cut off) the fractional part.

Because you do not check the divisions for divide-by-zero it would be better using atan2.

as I suggested before: And do not forget to increase the heap size to 0x200 (.cydwr view, System tab)

Printing floats: Use sprintf() and write the resulting string to your LCD.

 

Bob

 

user_259690047's picture
User
40 posts

Hi BobMarlowe,

Sir, i didn't understand why i should increase the heap size to 0x200. Give some link to understand this. 

Thank you so much Bob.....

user_242978793's picture
User
1102 posts

I am sending you your program back with changes and it is working.  You had to many channels in your Mux the channels start at 0 not 1.  You only need 3 channels X , Y and Z.  I changed the program as I don't have a 100 Pin PSoc 5.  I changed the program to run on 5lp device.  I also changed the ports for the LCD to P2[7:1]. 

Log in to post new comments.