Pages: 1 ... 5 6 [7] 8   Go Down
 Author Topic: Balancing robot for dummies  (Read 17950 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 44
 « Reply #90 on: May 19, 2012, 11:45:18 pm » Bigger Smaller Reset

@Lauszus,
Quote
Okay, it seems alright then.
the code is correct, but the result is not correct.

Quote
But I really see no point of converting it to deg/s, unless you want a speedometer or something like that?
Because it really doesn't matter if just need it to make it balance.
But of course it's always nice to know what your robot is capable of
Is necessary to know the speed, because my control system are a LQR and pole placement.
These two control systems, can be applied to a dynamic system whose equations are written in the form of state.
In fact, after writing the dynamical system in the form of state (taking into account the masses, the moment of inertia, the motor inertia, the height of the robot, the radius of the wheels, the weight of the robot) I get the equations whose variables are precisely the state of the system. In my case they are
1) the position that the robot reaches (practically is a linear position, obtained by knowing the angular position multiplied by the radius, obtained in meters) = x1
2) the speed of the robot (ie, angular velocity multiplied by the radius obtained in m / s) = x2
3) the angular position (obtained in rad / s) = x3
4) the angular acceleration (obtained in rad / (s ^ 2)) = x4

Knowing these variables that represent the state vector x, I can provide a control action u =-k * x, where exploding are: u =-k1x1-k2x2-k3x3-k4x4,
then it is necessary that the values ​​x1, x2, x3, x4 are in units of measurement right.
The various k (k1, k2, k3, k4) are obtained by means of the algorithms LQR, or pole placement, which can be applied directly from matlab
I hope I made you understand something
 Logged

Denmark
Offline
Full Member
Karma: 7
Posts: 246
 « Reply #91 on: May 20, 2012, 09:02:18 am » Bigger Smaller Reset

@batista1987
That makes perfectly sense. I have never seen a implementation like that in action. I'm really looking forward to se the outcome and see how well it balances.
 Logged

Offline
Newbie
Karma: 0
Posts: 44
 « Reply #92 on: May 20, 2012, 09:05:31 am » Bigger Smaller Reset

@lauszus,

I hope to make it work.
For now I still have problems with the speed of the engine :-(
 Logged

Offline
Newbie
Karma: 0
Posts: 44
 « Reply #93 on: June 13, 2012, 02:39:50 am » Bigger Smaller Reset

hi my gyro ITG-3200 has this sensitivity 2000 [degrees/second]. As regards to you what is the sensitivity in [mV/degrees]? So why as regards to you the measures of gyro (that give an angle ) is explain in [degrees/second] and not only [degrees]?
 Logged

Denmark
Offline
Full Member
Karma: 7
Posts: 246
 « Reply #94 on: June 14, 2012, 05:29:46 pm » Bigger Smaller Reset

@batista1987
The sensitivity is 14.375 LSB/(º/s) - see the datasheet: http://invensense.com/mems/gyro/documents/PS-ITG-3200A.pdf
Also take a look at the following line of some code I wrote: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/Digital_IMU/Digital_IMU.ino#L31 for this guide: http://arduino.cc/forum/index.php/topic,58048.0.html
A gyro will always output in º/s and not in an angle - remember that if the gyro drift just a tiny bit the angle can be very incorrect. That's why you often use a filter to find the bias for the gyro - see the following line of the kalman filter for my balancing robot: https://github.com/TKJElectronics/BalancingRobotArduino/blob/master/BalancingRobotArduino.ino#L300

Regards
Lauszus
 « Last Edit: June 14, 2012, 05:54:52 pm by Lauszus » Logged

Offline
Newbie
Karma: 0
Posts: 44
 « Reply #95 on: June 23, 2012, 04:15:46 am » Bigger Smaller Reset

tks lauszus. I've some questions
1)If i set the PWM frequency on 20Khz as you say, the value to have max speed is 400. as regards to you 400 is corresponding to 100% of duty cycle? and 14 is corresponding to 0% of duty cycle? or aare corresponding to other %?

2)If the timing loop is 10 ms, so has a frequency of 1Khz, is possible use a PWM at 20 Khz?

3) can you explain the function void moveMotor(Command motor, Command direction, double speedRaw)? particularly the moveMotor function, this code
Code:
int speed = speedRaw*((double)PWMVALUE)/100; // Scale from 100 to PWMVALUE
i think is to have the value not in per cent. Is true? so i think that (F_CPU/PWM_FREQUENCY/2)/100=4000, but in your opinion should not be equal to 400?
 « Last Edit: June 24, 2012, 03:03:55 am by batista1987 » Logged

Denmark
Offline
Full Member
Karma: 7
Posts: 246
 « Reply #96 on: June 24, 2012, 06:53:04 am » Bigger Smaller Reset

@batista1987
1)
A 100% duty cycle is equal to 400, but a 0% duty cycle is equal to 0. That means 25% is equal to 100, 50% equal to 200, 75% equal to 300 and so on.

2)
Yes, the frequency of the PWM has nothing to do with the frequency of your loop. As long as your are using a hardware timer you can set the frequency to what ever you like, as it uses a timer to operate. But if you had to implement a software PWM you would rely on the frequency of your loop.

3)
It's pretty simple. The speedRaw is the duty cycle in percentage (0-100%), i just convert it to the right number corresponding to the percentage - so 50% would be converted to 200 and so on.
The reason why I implemented it that way, is because then you can easily change the CPU frequency or PWM frequency and the code would take care of the rest.

Where do you get that equation from? This is the right one (see https://github.com/TKJElectronics/BalancingRobotArduino/blob/master/BalancingRobot.h#L7):
Code:
F_CPU/PWM_FREQUENCY/2

And since my Arduino is running at 16MHz and the PWM frequency is 20kHz, the equation look like this:
(16*10^6)/(20*10^3)/2=400

You can use wolframalpha if you like: http://www.wolframalpha.com/input/?i=%2816Mhz%2F20kHz%29%2F2

Regards
Lauszus
 Logged

Offline
Newbie
Karma: 0
Posts: 44
 « Reply #97 on: June 24, 2012, 08:37:48 am » Bigger Smaller Reset

@Lauszus,
you are always very clear. thanks
So with my tecnique, i've many problem, so i would use your code, so i've a different imu(but works fine), and a different gearmotor (http://www.pololu.com/catalog/product/1442). according to you separately Ki, Kd and Kp, where do I go to edit?
 Logged

Denmark
Offline
Full Member
Karma: 7
Posts: 246
 « Reply #98 on: June 24, 2012, 08:44:39 am » Bigger Smaller Reset

@batista1987
You should see this reply on my blog: http://blog.tkjelectronics.dk/2012/03/the-balancing-robot/comment-page-1/#comment-20170 on how to tune the PID values.
 Logged

Sweden
Offline
Newbie
Karma: 0
Posts: 4
"Everything should be made as simple as possible, but no simpler"
 « Reply #99 on: July 20, 2012, 10:29:46 am » Bigger Smaller Reset

This forum post was probably the one I got most of my ideas from when I wanted to build my own robot. This is my how it looks right now:

In the video you can see that the robot stays at roughly the same spot on the floor and handles a lighter push without any problem. To achieve this I have two cascade PID controllers and low pass filter on both wheel speed and the robot's angle.

Now I am thinking about improvements. Better stabilization is a first. And radio control would be nice.

 Logged

0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
 « Reply #100 on: February 14, 2013, 11:12:43 am » Bigger Smaller Reset

Is this code available? When I click on the link on this page http://www.x-firm.com/?page_id=148 I get a an encoder test app.

regards Peter
 Logged

Denmark
Offline
Full Member
Karma: 7
Posts: 246
 « Reply #101 on: February 14, 2013, 11:19:04 am » Bigger Smaller Reset

@pseddon
Just click at the code labeled "KasBotV2" instead
 Logged

0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
 « Reply #102 on: February 14, 2013, 11:23:41 am » Bigger Smaller Reset

Thanks!
 Logged

0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
 « Reply #103 on: February 14, 2013, 11:30:22 am » Bigger Smaller Reset

The KasBotv2 code does not include for steering only standing. Were there any developments done to allow the BalBot to be driven around?

regards Peter
 Logged

Denmark
Offline
Full Member
Karma: 7
Posts: 246
 « Reply #104 on: February 14, 2013, 11:31:24 am » Bigger Smaller Reset

I don't know, but you should have a look at my robot: http://blog.tkjelectronics.dk/2012/03/the-balancing-robot/.
The code can be found at the following link: https://github.com/TKJElectronics/BalancingRobotArduino
 Logged

 Pages: 1 ... 5 6 [7] 8   Go Up