Go Down

Topic: Balancing robot for dummies (Read 145 times) previous topic - next topic

beautifulsmall

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.

kas

- 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:

http://www.youtube.com/watch?v=zyslsBd8J5c

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


beautifulsmall

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. :D

kas

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   ::) ::) ::)

kas

#124
Nov 28, 2010, 08:20 am Last Edit: Nov 28, 2010, 12:25 pm by kas Reason: 1
      [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  >:(
Without encoders the best achivable attitude is  Nahua implementation
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: [Select]
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: [Select]
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: [Select]
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

Go Up