- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Can you attach the complete project.
Thanks,
Hima
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And do not forget to increase the heap size to 0x200 (.cydwr view, System tab)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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].
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
can any one tell how to convert my result of adxl335 into 360 degree changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not use atan(), use atan2() instead.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can't see anything wrong
except
xv = (x/1024.0*1.65-1.569)/0.3;
where do these constants come from???
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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