Poll
Question: I will need help with my project ?
With the programing part - 47 (58%)
With the DC motors - 34 (42%)
Total Voters: 26

Pages: 1 ... 7 8 [9] 10 11 ... 16   Go Down
Author Topic: Balancing robot for dummies  (Read 139481 times)
0 Members and 2 Guests are viewing this topic.
West Yorkshre UK
Offline Offline
Newbie
*
Karma: 0
Posts: 17
faster, smaller, more beautiful
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

comment on brushless motors vs coreless,
ive been looking at brushless and im still unsure, I think the fundemental question for balancing robots is "what is smallest torque" and also "the highest (stall) torque". for that perfect balance point a motor that steps is no good, you need a motor that can be adjusted by 1degree/sec and also can do 200mNm and reverse in 1/100 s , the problem with the "off the shelf " brushless motors is the driver controls that have set levels of acceleration, as Homer says "I want it now" which only coreless can give you. The sensor type of brushless are getting better but ive emailed the best and they cant do what coreless can, they can do low rpm but only with big amps! they are still a stepper at heart.  maybee im being a pedantic git and to balance you don't need 0.1 deg/sec control but thats just me.  just bought 2 RE-max graphite,22W, 16Amax, VNA30A dual control fron spark and ITG-3200 for my next 4-wheel balancer, I need to learn about li-po
whats that coming over the hill, is it a monster, its a BF952.
Logged

0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 - plain DC motors
 - coreless motors
 - brushless motors
 - continuous rotation servos
 - spurs gearbox
 - planetary gearbox
 - belt transmission
 - ...
the perfect cinematic chain still needs to be identified  :-?

patrik, I also noticed that motors have different forward/backward response.
Make sure that you use the total potential power of your motor. Monitor you PWM output, and check that value is not clipped by the K parameter.

The answer is software or hardware related (or a combination of those)
Low RPM with high torque can be obtained through an additional PID loop
see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1282384853/0

Backlash may be addressed within the code
Look at this one:



cheap motors with plastic gears, small wheels, excellent results  :o
I hope Dominic will jump in and share his experience


Quote
just bought 2 RE-max graphite,22W, 16Amax, VNA30A dual control fron spark and ITG-3200 for my next 4-wheel balancer, I need to learn about li-po
whats that coming over the hill, is it a monster, its a BF952.
beautifulsmall, This new digital output gyro looks promising.
Please let us have a link to the motors you mentioned

Logged

West Yorkshre UK
Offline Offline
Newbie
*
Karma: 0
Posts: 17
faster, smaller, more beautiful
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Kas, i guess i have given the impression that only expensive motors are good for balancing , im sure this is not true, to get balance any motor geared , plastic or whatever , will get there.
I dont want to balance, I want not to be knocked over!
60:1 plastic gears will never cut the mustard., i know im over egging the pudding with coreless, but you cant get that reaction from any other motor, they are astoundingly fast to change , they will buzz at 1KHz and the bot dances like a wild thing. I think 15:1 gearbox with a standard DC motor will give good balance results. I dont want that, I want to beat a cat, to hit a ball , 60g tennis ball at 4m/s. we can do this, you me and everyone here. Blues brothers. smiley-grin
Logged

0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I dont want that, I want to beat a cat, to hit a ball , 60g tennis ball at 4m/s. we can do this, you me and everyone here. Blues brothers.
+1  My final goal is definitly perfect balancing - long is the road   :smiley :smiley :smiley
Logged

0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

       [size=14] ** Balancing robot for dummies **[/size]


[size=14]Part six: Motor encoders and V2.0 code[/size]

Before even thinking about R/C wandering, a  well-mannered balancing robot has to learn to stand still  >smiley-sad
Without encoders the best achivable attitude is  
The bot is aware of his vertical tilt angle, he does know anything about his position.
Lets add motor encoder(s)

Look here and here for encoders basics:


A two-channel Hall effect encoder is used to sense the rotation of a magnetic disk on a rear of the motor shaft.
The quadrature encoder provides a resolution of 64 counts per revolution of the motor shaft.
To compute the counts per revolution of the gearbox output, multiply the gear ratio by 64.
The A and B outputs are square waves from 0 V 5 Vcc, 90° out of phase.
The frequency of the transitions tells you the speed of the motor, and the order of the transitions tells you the direction.
The oscilloscope capture shows the A and B (yellow and white) encoder outputs.



By counting both the rising and falling edges of both the A and B outputs, it is possible to get 64 counts per revolution of the motor shaft.
Using just a single edge of one channel results in 16 counts per revolution of the motor shaft (16 X 29 = 464 counts per wheel rotation).


For the code implementation, first create an interrupt based on DI3 state change (see interrupt Arduino reference)

Code:
void setup() {
 
  ..................

  pinMode(encodPinA1, INPUT);
  pinMode(encodPinB1, INPUT);
  digitalWrite(encodPinA1, HIGH);                    // turn on pullup resistor
  digitalWrite(encodPinB1, HIGH);
  attachInterrupt(1, rencoder, FALLING);
}

the rencoder function is called 464 times per wheel rotation, keep it small !!!
Code:
void rencoder()  {              // pulse and direction, direct port reading to save cycles
  if (PIND & 0b00000100)    count++;                  
  else                      count--;        
}
if (PIND & 0b00010000)  is equivalent to  if(digitalRead(2)==HIGH)
Accessing DI's state through the PIND register is just faster

The count variable is injected in the PID function in the same way as we did for the bot angle:
 - as such (wheel rotation)
 - as its first derivative (wheel speed)

Code:
int updatePid(int targetPosition, int currentPosition)   {
  int error = targetPosition - currentPosition;
  pTerm = Kp * error;
  integrated_error += error;                                      
  iTerm = (Ki/5) * constrain(integrated_error, -GUARD_GAIN, GUARD_GAIN);
  dTerm = Kd * (error - last_error);                            
  last_error = error;
  pTerm_Wheel = Kp_Wheel * count;          
  dTerm_Wheel = Kd_Wheel * (count - last_count);                            
  last_count = count;
  return -constrain(K*(pTerm + iTerm + dTerm + pTerm_Wheel + dTerm_Wheel), -255, 255);
}
After properly tuning the 6 ( :o) parameters of the PID algorithm, your bot should finally stand still.

I will send kasBot V2.0 to Patrik for publishing in his blog
Patrik please add the encoders PID parameters as tunable values in BalancingBotGUI v1.3
« Last Edit: November 28, 2010, 06:25:54 am by kas » Logged

Toronto, Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So Kas, you are using only one encoder, right? And you are using it to count only one transition of one channel, right? I suppose it's because you have many counts generated per wheel rotation. In my case, I have only 141 counts in single channel, single transition. I use 2 transitions (change) to get double of that, but I suppose I shoul use the full quadrature to get four times 141 to get close to what you're getting with your setup.

Anyway, to understand better, any time an interrupt is generated by pin D3 (interrupt 1) you check the logic state of pin D2 (interrupt 0) and increment or decrement the counter to get the speed and direction at the same time. I do the same thing, but I use a regular I/O pin for the second channel of the encoder and the interrupt 0 for the other motor's encoder. Then I compare the 2 encoder counts to see if the motors are running at the same speed or need to be compensated somehow, usually I speed up the slower motor. But this is for a regular robot. Is it worth the trouble to go all this way for the balancing robot?
Logged


0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Ro-Bot-X,

I use one encoder, one channel only. As you say, 464 counts per wheel revolution is more than adequate.
In your case, quadrature (look here) will definitly increase resolution.
I currently use only one interrupt (#1) and check, whithin rencoder, the other channel logic state (regular I/O).
I make a first right/left motor speed adjustment within code, and fine tuning through micro joystick trim:


The second encoder can also be used for this task, but I hesitate to create a second interrupt within the code.
Logged

0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If your boot tells you he can fly  smiley-razz, [size=14]don't trust him[/size]
The takeoff from the mezzanine was OK, only the landing 3 meters below did create problems  smiley-wink



Well c'est la vie  :-/


I have to stop active development for some days (Xbee wireless RC is 90% completed)
For those who have started building a balancing bot, please register and share your design and/or your source code.
Any new development ideas are also welcome.

I will be back soon...
« Last Edit: December 05, 2010, 11:59:24 am by kas » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh no! That didn't look so nice.. Hopefully it was not to much damage to more then the obviously.  :-[
Logged

The balancing robot for dummies guide
http://www.x-firm.com/?page_id=145

Bor
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is my first try to tune the PID by following your tuning tips (thank you very much for that). I have so far not used the values from the encoders because I want a little moer stability before I do that. Do you have more tips on how to find the best values? I have also tried to google about it but it is hard to follow when it is about other stuff than balancing bots...

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@GuzZzt

Looks like a good start, could you take some pictures on the bot and post your construction.. Do you have some instructions and pictures on the bot on some blog or on LMR?

Logged

The balancing robot for dummies guide
http://www.x-firm.com/?page_id=145

0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Hopefully it was not to much damage to more then the obviously
Thanks for the empathy, I just needs a new frame, a motor (bent shaft) and a wheel


Back to (nearly smiley-wink) square one


Quote
I have so far not used the values from the encoders because I want a little moer stability before I do that.
Do you have more tips on how to find the best values?
Time for encoders  :smiley
As mentioned by Patrik, please post photos of your setup.
I am curious about your motor positioning, looks like a belt transmission ??
Logged

Bor
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, here are some photos. I plan to write a little more on my site after I'm finished with the main stuff.

I use the same wheels and motors (but only 150RPM) as you do from pololu.com. the belt driving was inspired by the n-bot robot. If you look closely can you see that I in fact don't use an Arduino but a Maple board (an ARM Cortex M3 but the C code is still the same).




Logged

0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ GuzZzt
Quote
I use the same wheels and motors (but only 150RPM)
Your motors may be a bit slow, you may
 - try the 90mm wheels if you currently mounted the 80mm ones
 - increase the global PID parameter (K)
 - use a smaller pulley on the wheels shafts

Please let us have a link for the belts and pulleys hardware
Logged

Bor
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The mechanics comes from http://www.technobotsonline.com
Logged

Pages: 1 ... 7 8 [9] 10 11 ... 16   Go Up
Jump to: