Go Down

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

kas

#225
Jan 16, 2011, 07:33 am Last Edit: Jan 16, 2011, 01:12 pm by kas Reason: 1
..........   continued


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


[size=14]Part seven: Xbee wireless control, KasBot V 3.0[/size]



[size=14]2) Robot side:[/size]

On the bot side, the Xbee module is set as per post #107

The datastream is decoded within getMotion()
Code: [Select]
void getMotion() {
 if(!Serial.available())      return;
 delay(5);                  
 int controlByte = Serial.read();              // get control byte
 if(!Serial.available())      return;
 int dataByte_1 = Serial.read();               // get data byte 1
 if(!Serial.available())      return;
 int dataByte_2 = Serial.read();               // get data byte 2
 Serial.flush();                                

 if(controlByte == 'd')   {                    // Nunchuk joystick data
   setPoint = -(dataByte_1 - 20)/2;          // get forward/backward motion byte
   if(abs(setPoint) > 2)  {
     count = 0;
     last_count = 0;
   }
   turn = (dataByte_2 - 20);                   // get right/left motion byte
 }  else    bip(bipPin, 10, 1);                  // wrong header
}


setPoint is used to bias updatePid() and slithly move the bot from vertical, thus initiating the move

Code: [Select]
void loop() {
// ********************* Get Xbee data *******************************
 getMotion();

// ********************* Sensor aquisition & filtering ***************
.....

// *********************** Angle Control and motor drive *************
 drive = updatePid(setPoint, actAngle);                                // PID algorithm

 if(abs(actAngle) < 100)    {
   Drive_Motor(drive);
 }  else {  
   Drive_Motor(0);                                                    // stop motors if situation is hopeless
   setZeroIntegal();                                                  // reset PID Integral accumulaor
 }
// ********************* print Debug info ****************************
.....

// *********************** loop timing control ***********************
.....

}



turn becomes a new parameter in Drive_Motor(), to allow right and left motor to run at their own speed
Code: [Select]
int Drive_Motor(int torque)  {
 if (torque + turn >= 0)  {                                          // drive motors forward
   digitalWrite(InA_R, LOW);                        
   digitalWrite(InB_R, HIGH);
   torque_R = torque + turn;
   if (torque - turn >= 0)  {                                        // drive motors forward
     digitalWrite(InA_L, LOW);                    
     digitalWrite(InB_L, HIGH);
     torque_L = torque - turn;
   }  else  {
     digitalWrite(InA_L, HIGH);                      
     digitalWrite(InB_L, LOW);
     torque_L = abs(torque - turn);
   }
 }  else {                                                           // drive motors backward
   digitalWrite(InA_R, HIGH);                      
   digitalWrite(InB_R, LOW);
   torque_R = abs(torque + turn);
    if (torque - turn >= 0)  {                                       // drive motors forward
     digitalWrite(InA_L, LOW);                    
     digitalWrite(InB_L, HIGH);
     torque_L = torque - turn;
   }  else  {
     digitalWrite(InA_L, HIGH);                      
     digitalWrite(InB_L, LOW);
     torque_L = abs(torque - turn);
   }
}
 torque_R = map(torque_R,0,255,K_map,255);
 torque_L = map(torque_L,0,255,K_map,255);
 torque_R = constrain(torque_R, 0, 255);
 torque_L = constrain(torque_L * motor_Offset, 0, 255);
 analogWrite(PWM_R,torque_R);
 analogWrite(PWM_L,torque_L * motor_Offset);                      // motors are not built equal...
}



OK guys, this is probably my last significant contribution to this thread  :-/
I suddently realize that I have a real life and... some other projects to explore  ::) ::)

I am sure this thread will keep on, with new bright ideas coming on
What about non linear control ??
What about one wheeled bot as shown by Big Oil ??

"...Two wheeled balancing robots are an area of research that may well provide the future locomotion for everyday robots..."

I really enjoyed all these discussions we had on this common project
Thanks again to everybody for reading and contributing   :) :) :)

- Rubik's cube Robot solver                 forum.arduino.cc/index.php?topic=271827.0
- Android Bluetooth joystick               forum.arduino.cc/index.php?topic=173246.0
- Balancing robot for dummies           forum.arduino.cc/index.php/topic,8871.0

prof_jazz

wow kas!

any video of this new child?

bye

kas

I am better at photo than video  ;)
- Rubik's cube Robot solver                 forum.arduino.cc/index.php?topic=271827.0
- Android Bluetooth joystick               forum.arduino.cc/index.php?topic=173246.0
- Balancing robot for dummies           forum.arduino.cc/index.php/topic,8871.0

Ro-Bot-X

@osmaneralp

I have ordered my Chumby from Costco, it should arrive in 7-10 days at my friend in Florida then he will send it to me in Canada. So I expect about 3-4 weeks until I'll actually have it in my hands. Until then, I'll work on the chassis and the rest of the project. I would really like to take a look at your bot's build page, especially the way you used the Chumby as a robot controller. I have found some info on the net, but a more in depth info would be great.

Thanks!


osmaneralp

@Ro-Bot-X

One of the guys in the robotics club I belong to (The Silicon Valley HomeBrew Robotics Club) wrote an article on using the Chumby as a robot controller. You can find it on his web site: http://www.demandperipherals.com/docs.html#howto. He said you can contact him if you have any questions. I also have a fair bit experience using the Chumby as the brains of my robots. Feel free to PM me.

I don't want to hijack this thread with posts about the Chumby, so let's start a new topic or exchange PMs.

--Osman

prof_jazz

Hi,

the 1 x Dual VNH2SP30 Motor Driver Carrier MD03A  (49,95$) on Pololu is out of stock till March...

Could You suggest a valid backup solution ?

The "Pololu Qik 2s12v10 Dual Serial Motor
Controller" (74,95$) http://www.pololu.com/catalog/product/1112 uses the same VNH2SP30 chip.

I have to drive the same Kas motors (Pololu Metal Gearmotor 37Dx52L mm with 64 CPR Encoder), Could You give me a feedback and more information?
I'll be happy to add  25$ if the "Pololu Qik 2s12v10 Dual Serial Motor Controller" will drive the above motors  with no difference.

will be the arduino code the same?

Thanks

Ro-Bot-X

#232
Jan 21, 2011, 11:25 pm Last Edit: Jan 22, 2011, 12:09 am by Ro-Bot-X Reason: 1
I'm wondering how well a Brushed Motor ESC could work with the balancing bot? They take a servo signal between 1000-2000us and convert it to linear throttle curve, forward, backward and programmable break (jumper ON=break, Off=coast). Here is a link for such a device: http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=9090 It's just $5 for 20A! Of course, we need 2 of them, but they are cheaper than a 5 A dual motor driver...

Patrik

I think the problem with brush less motors is that they don't like low speeds where they will consume a lot amps..  
The balancing robot for dummies guide
http://www.x-firm.com/?page_id=145

Ro-Bot-X

Quote
I think the problem with brush less motors is that they don't like low speeds where they will consume a lot amps..


I was talking about Brushed motor ESC, not brush less...

kas

#235
Oct 28, 2014, 09:17 am Last Edit: Oct 28, 2014, 09:29 am by kas
-
- Rubik's cube Robot solver                 forum.arduino.cc/index.php?topic=271827.0
- Android Bluetooth joystick               forum.arduino.cc/index.php?topic=173246.0
- Balancing robot for dummies           forum.arduino.cc/index.php/topic,8871.0

Go Up