Offline
Newbie
Karma: 0
Posts: 3
|
 |
« on: October 24, 2012, 08:03:54 am » |
Hello all,
I'm new to the forum and Arduino and general but I'm very interested and excited in a project I'm trying to complete using an Arduino Uno.
I am trying to build a circuit to automatically level my camper using the electric jacks by running them up or down based on the reading from an accelerometer. I've recently connected my ADXL 335 to my Arduino and monitoring the output thru the serial monitor. I've noticed that you have to move the board more than I expected to get a change in readings.
My question is if the ADXL 335 is sensitive enough to use as a level sensor ir there is another Analog Accelerometer out there more suited for the task. I've played around with bubble level apps on smartphones and they seem to be very sensitive. So I'm pretty sure an accelerometer could do the job.
Thanks in advance.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 4
Posts: 1131
If you're not living on the Edge, you're taking up too much space!
|
 |
« Reply #1 on: October 25, 2012, 12:11:53 pm » |
How level does a camper need to be? Should give you a degree or 2.
|
|
|
|
|
Logged
|
If you fall... I'll be there for you! -Floor
Skype Brighteyes3333 (262) 696-9619
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #2 on: November 01, 2012, 11:55:02 am » |
Within a few degrees would definitely be acceptable. I guess I was just concerned by not seeing much change tilting the sensor in my hand. Maybe I should temporarily clamp it to my camper frame and see how much change I get at different degrees from level. Seems like I've seen some sample code around using that accelerometer as an angle finder. Maybe I'll play around with that and see what kind of results I get. Thanks. 
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6820
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #3 on: November 01, 2012, 07:13:58 pm » |
I planned to do exactly the same and plugged in an ADXL335 to try. It was a while back but I think I found the same as you.
I still haven't got back to it and can't remember the numbers now but IIRC I decided that the output either needs to be amplified or you heed a higher res ADC.
There are digital output versions now (ADXL345) that would be a better choice these days I think.
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 3
Posts: 34
|
 |
« Reply #4 on: November 08, 2012, 01:19:15 pm » |
It works fine for me.
I am using Adafruit's ADXL335 breakout board for my level project. I am getting 1/2 degree accuracy. It will work fine.
|
|
|
|
|
Logged
|
That little black caterpillar you just stepped on will set you back a few bucks....
|
|
|
|
Germany
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #5 on: November 29, 2012, 08:24:17 am » |
@JD3: Sound interesting, do you use any kind of filtering in your software or amplifiying on the hardware site?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 2
Posts: 155
Arduino rocks
|
 |
« Reply #6 on: November 29, 2012, 11:11:20 am » |
@JC3,
like Darkside40 I would like to hear from you to see if you used any filtering and what type you used. Can you elaborate how you got 0.5° accuracy for the unwashed massses like myself. Thanks wade
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 3
Posts: 34
|
 |
« Reply #7 on: December 04, 2012, 12:21:41 am » |
I use adafruits ADXL335 board. I have a resistor and capacitor filtering the 3v reference going into the AREF pin, that's it. 3 axis directly to the analog pins. I use a shielded cable to connect the accelerometer to my duemilanove. I think it was from an extra serial cable I had laying around.
No software filtering, very basic.
You need to use 3v reference to get 1/2 degree resolution. If you use the 5v reference it works out to be around 7/8 degree.
I have my board mounted flat. X is left right, Y is forward back, Z is up down. If you have the board mounted different then the LR & FB formulas need to be changed.
I used the AN-1057 application note from analog devices to figure out the dual axis calculations.
float LR = 0.00; // left-right angle float FB = 0.00; // front-back angle int Xaxis = 0; // fresh data from accelerometer int Yaxis = 0; int Zaxis = 0; int Xcal = 506; // calibration data, zero g int Ycal = 506; int Zcal = 518;
void setup() { analogReference(EXTERNAL); // uses 3.3v from accelerometer for reference voltage }
void loop() { Xaxis = analogRead(2); // read analog inputs Yaxis = analogRead(1); // average & filter readings Zaxis = analogRead(0); LR = (atan(((Xaxis-Xcal)/Xres) / ((Zaxis-Zcal)/Zres))) *57.2957; FB = (atan(((Yaxis-Ycal)/Yres) / ((Zaxis-Zcal)/Zres))) *57.2957;
and then print to serial monitor or LCD screen...
|
|
|
|
« Last Edit: December 04, 2012, 12:43:09 am by JD3 »
|
Logged
|
That little black caterpillar you just stepped on will set you back a few bucks....
|
|
|
|
0
Offline
Full Member
Karma: 2
Posts: 155
Arduino rocks
|
 |
« Reply #8 on: December 04, 2012, 09:45:32 am » |
How have you verified 0.5° accuracy? Have you calibrated the unit?
Thanks
wade
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 3
Posts: 34
|
 |
« Reply #9 on: December 04, 2012, 05:11:37 pm » |
How have you verified 0.5° accuracy? Have you calibrated the unit?
I never said 1/2 degree accuracy, I said 1/2 degree resolution. I know this because I can move the accelerometer around and I get 1/2 degree movements. Also I have a granite surface plate with angle blocks. When zeroed on the granite all the angle blocks measure right. The calibration is in the software. Look at the X,Y, & Z cal values. Those are set to 0 g. When you mount the accelerometer, first write a sketch that outputs only the value of analogRead in all 3 axis. If the object that the accelerometer is mounted to is level then the 3 numbers you get would be the calibration data.
|
|
|
|
|
Logged
|
That little black caterpillar you just stepped on will set you back a few bucks....
|
|
|
|
0
Offline
Full Member
Karma: 2
Posts: 155
Arduino rocks
|
 |
« Reply #10 on: December 06, 2012, 09:43:15 am » |
The calibration data should also taken after the sensor is mounted on the board or in the system.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 3
Posts: 34
|
 |
« Reply #11 on: December 06, 2012, 07:04:33 pm » |
Yup - that's what I wrote before.
"If the object that the accelerometer is mounted to is level then the 3 numbers you get would be the calibration data."
|
|
|
|
|
Logged
|
That little black caterpillar you just stepped on will set you back a few bucks....
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6820
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #12 on: December 11, 2012, 03:31:54 am » |
Please use code tags.
Edit the post, select the code, and click the # button on the toolbar.
_____ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #13 on: January 08, 2013, 04:05:28 pm » |
Can you please tell me how can i measure z axis up,down rotation. Using ADXL335 I could measure pitch and roll angle. But i dont no how to measure yaw angle. If i place a sensor in flat surface and rotate the sensor in yaw angle rotation , sensor does not gives me any change in value. my robot car instead of driving in straight line, it has angle deviation from straight line while travelling. so i wanted to measure the angle deviation. please any one help me in calculating yaw angle. https://developer.valvesoftware.com/w/images/7/7e/Roll_pitch_yaw.gif
|
|
|
|
« Last Edit: January 08, 2013, 04:12:40 pm by sana »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 3
Posts: 34
|
 |
« Reply #14 on: January 08, 2013, 07:47:10 pm » |
Hi Sana, you are looking for a Magnetometer (Compass) Board. Adafruit and Sparkfun offer them.
The accelerometer is using gravity to determine the angles, but you need to use a different force to calculate yaw.
The Magnetometer senses magnetic forces, and hopefully it will sense magnetic north and not anything else. Especially the magnetic fields of the motors. You could set a direction and have the robot go to that heading.
If you are looking just to find out what the angle of deviation is, just send the robot out a known distance along a straight line. mark a starting spot, send it off, mark the finish spot. Then measure how far it's off from the line. Using geometry you can calculate the angle. inverse tangent (tan-1) multiplied by (length the robot traveled along straight line / distance robot veered ). Both measurements must be the same units, ex. inches, feet, etc. (6 inches is .5 feet)
That will give you the angle.....
|
|
|
|
|
Logged
|
That little black caterpillar you just stepped on will set you back a few bucks....
|
|
|
|
|