Pages: 1 ... 27 28 [29] 30 31 ... 37   Go Down
Author Topic: Guide to gyro and accelerometer with Arduino including Kalman filtering  (Read 298290 times)
0 Members and 2 Guests are viewing this topic.
Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@doantrungnghia05
I'm pretty sure the boards which only got a gyro on them don't even convert the gyro readings into degrees, but uses the rate as the input to there PID loop.

You can find plenty of firmware for you board. There is no need to write your own. For instance I found this using Google: https://github.com/DaneGardner/KKMulticontroller

You should ask at a quadrocopter forum or something like that instead.
« Last Edit: March 30, 2013, 02:17:24 pm by Lauszus » Logged

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

Hi Lauszus
when i try to compile your sketch for the mpu6050  i get the error Kalman does not name a type and line 4 is flashing , i am new to Arduino and not shure how to correct it,

thanks Garwalt
Logged

Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@garwalt
Remember to download this file as well: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/Kalman.h
Logged

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

Thanks Lauszus  i had thet file but it didnt work, so i downloaded it again and all is well.
I want to add servo controll to this sketch could you give advice on how i might do this?.

Thanks
Logged

Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@garwalt
Simply use the output from the Kalman filter as you input to your servo. See: http://arduino.cc/en/Reference/ServoWrite
Logged

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

Thanks Lauszus ,  sorry to be a pain but this is very new to me, the only thing i have a problem with is, is where in the sketch, is the best place to put the servo write command, at the moment i am using this line from another post.

servo1.writeMicroseconds(1560+kalAngleX*9.55);

i have tried it in various positions within the loop function, and all it does is send the servo full one way , i am getting data on the serial moniter.

Thanks
« Last Edit: April 04, 2013, 03:33:22 pm by garwalt » Logged

Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@garwalt
Simply add:
Code:
servo1.write(kalAngleX/2.0);
servo2.write(kalAngleY/2.0);

Just below:
Code:
timer = micros();
Logged

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

Thanks Lauszus, all is working as it should.
Logged

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

Hi Laszus the mpu6050 is working fine with your sketch, is there any way to match the angle of the servo to the angle of the gyro, at the moment if the gyro tilts to say 45 degrees the servo only moves to approx 30 degrees.
Logged

Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@garwalt
Just multiply the angle by a constant, as all Servos are a little different.
If you want more control use the writeMicroseconds function: http://arduino.cc/en/Reference/ServoWriteMicroseconds.

For instance you could fine the maximum and minimum values and then use map (http://arduino.cc/en/Reference/map) to map the angle to these values.
Logged

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

The post is very informative. Thank you so much.
I am working on something similar to it.

I am working on a self-balancing bicycle which is my final year project.The main idea is to run the bicycle,powered by a motor, in balanced position by measuring the tilt when ever the cycle tend to fall and using steering control to balance it. In my project, I am using two sensors gyro meter
http://www.nex-robotics.com/products/sensors/l3g4200d-3-axis-digital-gyroscope-with-voltage-regulator.html

and accelerometer
http://robokits.co.in/shop/index.php?main_page=product_info&cPath=11&products_id=39

to measure the tilt angle.

roll angle of the gyro along the front wheel and 'x-axis' of the accelerometer perpendicular to roll angle,towards the right side of the cycle,parallel to the ground so the roll angle will give the degree/sec and accelerometer will give the displaced angle or tilt angle when the bicycle tends to fall. 'y-axis' of the accelero also comes along the roll angle(I m not using it).


so, firstly I want to know whether the program you used to measure the tilt angle (in your case front and back) is applicable to sensors to accurately measure the tilt angle? (I m not using a imu). It would be of great help if you can make me figure out working of my sensors properly.

nowhere i could get the information about how you placed the axis of gyro and accelero....can you please tell me

please help me
« Last Edit: April 24, 2013, 09:07:39 am by madalam » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
very interesting post, a bit offtopic but I d need to build a 3 axis angle sensor, which should pass me the pitch and yaw of the sensor in real time. I understand that part of this project iwll do exactly that but I am concerned about multi-turn sensing, so to say. I see the sensor will report easily the angles o a "floating" platform where angles go positive and negative starting for a zero/center, but how will it react when going over 360 degrees? Is i tpossible to sense this kind of rotations? Any hint is much appreciated.
Simone
Logged

Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@madalam
I'm not totally sure what you question is? Are you talking about the physical placement of the gyro and accelerometer or something else?
Btw an IMU is simply a device that reports a crafts velocity, angle etc. In this context consist of the accelerometer and gyro that is used to calculate the angle of the device. See wiki for more information: http://en.wikipedia.org/wiki/Inertial_measurement_unit.

@io
I had the exact same problem with my Balancing robot. This is how I solved it: https://github.com/TKJElectronics/Balanduino/blob/711ef4484173694815e27a78f7cbf0dec4911c90/Firmware/Balanduino/Balanduino.ino#L201-L207.
Also check out the Kickstarter for more information about the project: http://www.kickstarter.com/projects/tkjelectronics/balanduino-balancing-robot-kit/posts.
Logged

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

Hello guys. I have been following this post for quite a time. Now that i had the gears , i have begun to play with mpu6050 . And i have recently  run the code successfully given in this post. Thanks for sharing.
Eventually what i am trying to do with mpu6050 is to measure sea wave data. An make a wave buoy. Since i am only a newbie in electronics and coding. I made some research on the web and found a scientific article about it. In this article they use an accelerometer to measure wave height and period. Main problem is that while buoy drifts with the wave , wave changes its position relative to the ground. So that acc data can not be used to measure wave accurately. They managed to find a way to compensate directional forces applied to buoy and measure z axis . But off course neither the code  nor how to do info are given. But equations in this project are shared fortunately. I am adding the image to the post. I am now trying to integrate these equations to the mpu6050 's acc readings. First equation is interesting i think i can measure the acc data with it  regardless of tilt or yaw. But i am getting 16xxx something number instead of g. According to mpu 's sensitivity level i am supposed to divide the number to get the g number. If you are interested. Your help would be much appreciated. Thanks in advance.


* accdata.jpg (108.61 KB, 531x660 - viewed 80 times.)
« Last Edit: May 05, 2013, 06:08:14 am by tamayaytam » Logged

Denmark
Offline Offline
Sr. Member
****
Karma: 10
Posts: 287
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@tamayaytam
The MPU-6050 will output it's values as a 16-bit signed number (-32768 to 32767). Depending on the which scaling you use 1g is a certain value. The default is +/-2g. Then 1g would be equal to 16384. Simply divide your readings by 16384 if you want to convert the reading into g's and are using the default setting.
For more information see the datasheet: http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A.pdf at page 13.
Logged

Pages: 1 ... 27 28 [29] 30 31 ... 37   Go Up
Jump to: