Balancing Robot

11 Sep 2011

I just got my mbed a few days ago and started looking through the guide,cookbook,etc. for related topics on the things I'm doing but I can't find the information I needed.

I intend to make a balancing robot. I'm going to use:

2x single axis accelerometer ADXL193 (arrow pointing upward and arrow pointing forward)

1x dual axis gyroscope LPY530AL (using 1 axis because only 1 degree of freedom, leaning forward and backward)

As I know, the output from those sensors are in analog. Which means it has to go through the ADC first. After that, I want to fuse the data using Kalman Filter before feeding it to the PID and lastly generate PWM to control the stepper motor. Is the sequence correct?

Questions:

From the handbook, AnalogIn are represented in 0.0 - 1.0 rather than 0V - 3.3V. I've tested the accelerometer, the voltage in different positions are 1.637V +-0.006V

1.How do I convert the values to the floating point numbers 0.0-1.0?

2.How does this value use for further processing?(in my case, just plug into Kalman Filter?)

3.Do I use the same method to convert the gyroscope's value?

4.I've found a few "Filters" in the forum, they doesn't look like Kalman Filter, or are they?

IMU filter from Aaron Berk

http://mbed.org/users/aberk/libraries/IMUfilter/lebv20/docs/IMUfilter_8cpp_source.html

5.I have a sample of Kalman Filter programming written by Trammell Hudson for PIC in C programming, can I just use them?

http://www.rotomotion.com/downloads/tilt.c

http://www.rotomotion.com/downloads/tilt.h

From the Cookbook, there is sample programming on ADXL345(3 axis).

6.With some modification,can I use that to program my ADXL193(1 axis)?

Sorry for the long post with many and long questions.

10 Sep 2011

This sounds like a cool project, keep us up to date with how you get on.

To answer some of your questions...

Ivan Chan wrote:

1.How do I convert the values to the floating point numbers 0.0-1.0?

When read in they will be in the range from 0 - 1. Use something like...

#include "mbed.h"

AnalogIn ain(p20);

int main() {

    float reading = ain.read();
    // do some more stuff...
}

Ivan Chan wrote:

3.Do I use the same method to convert the gyroscope's value?

Yes

Ivan Chan wrote:

5.I have a sample of Kalman Filter programming written by Trammell Hudson for PIC in C programming, can I just use them?

http://www.rotomotion.com/downloads/tilt.c

http://www.rotomotion.com/downloads/tilt.h

No, you will have to adjust these for the mbed platform

Hope that gets you started, Martin

11 Sep 2011

Thanks for the reply, at least I know where to start now (ADC).

I guess I'll experiment around with the stuff and hopefully will obtain something useful.

12 Sep 2011

http://mbed.org/cookbook/Student-Projects has a link to a similar project idea in the robot section.

12 Sep 2011

Thanks Jim, I did try to search for that project beforehand but apparently the link directs me to a "Error 401 - Unauthorized" page. Am I the only one that get that? Is there any other methods to access to the link/project?

Update for the project:

I've decided to change both of my accelerometer and gyroscope(I'm not paying), to another model which is easier to use and provided programs from the cookbook and other mbed users. The reason for that is because that I do not know how to make my own library file and to create the other functions.

I've decided to use

Accelerometer: ADXL335 (3 axis)

Gyroscope: IDG500 (2 axis)

I've got questions regarding sampling rate of ADC.

What I'm trying to do is, I want to get the analog value from the accelerometer and gyroscope for every 10ms(100Hz) and feed it to the Kalman filter.

http://mbed.org/forum/mbed/topic/557/

from the link above, they mentioned about burst conversion rate,interrupts,hw registers,etc.

How do I set my sampling rate for ADC for both accelerometer and gyroscope?

Is it necessary for me to do so? Or I'll just let it run and only call the Kalman filter's function at every 10ms to capture the value?

12 Sep 2011

I will try to get it fixed. The site seems to work internally here – will talk to the webmaster here. Will let you know when it should work again.