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 ... 14 15 [16]   Go Down
Author Topic: Balancing robot for dummies  (Read 140752 times)
0 Members and 2 Guests are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 18
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

« Last Edit: January 16, 2011, 07:12:21 am by kas » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

wow kas!

any video of this new child?

bye
Logged

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

I am better at photo than video  smiley-wink
Logged

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

@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!
Logged


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

@Patrick

here is a link to my attempt: http://seriousrobotics.wordpress.com/2011/01/17/balancing-octobot/
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

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...
« Last Edit: January 21, 2011, 06:09:24 pm by Ro-Bot-X » Logged


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

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

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

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

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...
Logged


Pages: 1 ... 14 15 [16]   Go Up
Jump to: