Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

Anonymous
Not applicable

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. 

0 Likes
1 Solution
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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

View solution in original post

0 Likes
22 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello

   

 

   

Can you attach the complete project.

   

 

   

Thanks,

   

Hima

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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

Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

Anonymous
Not applicable

thanks to all.

   

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

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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. 

0 Likes
Anonymous
Not applicable

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 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

Anonymous
Not applicable

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

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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

rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Also update your PSoc Creator to PSoC Creator  3.3 CP3 (3.3.0.9604).  The reading I got where Ch1=.47 , Ch2=+0.90 and Ch3 +1.12.  I don't have a device on the Mux pins.

0 Likes
Anonymous
Not applicable

bob, i am finding update PSoC creator 3.3 CP2 only. Now downloading is going on. Is it possible to open/run your attached above file. 

   

Thank you so much bob for your selfless effort.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

No link for heap increase. I found out that the initial setting of 0x80 is too small. When sprintf() floats, program will hang. Verify for yourself if you do not believe.

   

 

   

Bob

Anonymous
Not applicable

Hi bobgoar, 

   

I couldnt open your attached file. Please help me how can i open that file. when i run the program it shows that like the below 

   

Unable to open the project ".\BasicDesign01.cydsn\BasicDesign01.cyprj": Could not find a part of the path 'C:\Users\MARIA SWANITTA\AppData\Local\Temp\Temp1_BasicDesign01.cywrk_.Archive02.zip\BasicDesign01\BasicDesign01.cydsn\BasicDesign01.cyprj'.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I just tried it by downloading the file from the forum post  and I unzipped it and then opened it and it loaded without issue.  Did you unzip the file first? Also I  would unzip it to a new Directory and then have PSoC Creator open it from there.

0 Likes
Anonymous
Not applicable

Thank you so much bob, its working now. I did as u said and i changed the lcd and x,y,z pin only for my PSoC 5lp board. It showing ch1 +0.59 ch2 +0.51  ch3 +0.8.  bob can you please help me for ECG measurement using PSoC 5lp. I picked the ECG signal using external circuit. Now i have to rectify the power supply noise by notch filter using PSoC component. I tried many times but the output is not showing in the DSO monitor. 

0 Likes
Anonymous
Not applicable

can any one tell how to convert my result of adxl335 into 360 degree changes. 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Do not use atan(), use atan2() instead.

   

 

   

Bob

Anonymous
Not applicable

Bob as u said i tried. but i am not sure it is correct or not. I attached my code is here. If i rotate the adxl335 it is changing +  or -  from 220. 2 value and not changing from 0 to 360 degree.  please check and tell me. 

   

I wrote this program with the help of the link below.

   

https://www.electronicsblog.net/simple-angle-meter-using-adxl335-accelerometer-arduino/ 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can't see anything wrong

   

except

   

                xv = (x/1024.0*1.65-1.569)/0.3;

   


where do these constants come from???

   

 

   

Bob

0 Likes
Anonymous
Not applicable

ADC reference voltage is 1.65 V.  0 g voltage after some simple calibration is set to be 1.569 V. The sensitivity for calculations is used as default – 300 mV/g. *57.2957795 – is conversation of radian to degree. +180 is for offset. 

   

these all constant values are taken from the above link BOb. Have u checked that link Bob. 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Check your zero_x,y and z.  Multiplying factors will be canceled out by atan2(). You are calculating in counts from ADC, not in Volts!

   

The ADC in the example can be quite different from that in the PSoC.

   

 

   

Bob