BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 9:23 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Setting distance with Packet Serial
PostPosted: Mon Dec 12, 2011 12:14 am 
Offline
New User

Joined: Sun Dec 11, 2011 9:53 am
Posts: 2
Hi

When I tried to set a distance with the command number 46 ( or command 43), I got many differents results. For example:

At 2000 quad pulses per second for the speed, the robot turn 90° (exactly the deliberate distance)
but at 4000 quad pulses per second for the speed, the robot turn 140°

I tried to tune the PID constants but I don't arrive has to make the robot oscillate (like with a real PID controller)

How can I set the distance without depending on the speed?
Could you help me ?

PS : I use a RoboClaw 2x5A ( v2) and a RoboClaw 2x15A ( v1)


Top
 Profile  
 
 Post subject: Re: Setting distance with Packet Serial
PostPosted: Mon Dec 12, 2011 10:49 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Please post your code. Also you need to make sure your robot isn't slipping more when going over 90 degrees causing the major loss. Also when adjusting the PID you should adjust the I argument to be higher to hold the speed more accurately. If the I argument is too low your error over time will be greater. The P argument only gets you close so has the least effect. Also make sure your QPPS setting is correct. It needs to be the pulses per second when the motor is at 100% power. If you are getting oscilation you may need to lower I OR raise QPPS.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Setting distance with Packet Serial
PostPosted: Mon Dec 12, 2011 10:50 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Please post your code. Also you need to make sure your robot isn't slipping more when going over 90 degrees causing the major loss. Also when adjusting the PID you should adjust the I argument to be higher to hold the speed more accurately. If the I argument is too low your error over time will be greater. The P argument only gets you close so has the least effect. Also make sure your QPPS setting is correct. It needs to be the pulses per second when the motor is at 100% power. If you are getting oscilation you may need to lower I OR raise QPPS.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Setting distance with Packet Serial
PostPosted: Mon Dec 12, 2011 11:46 am 
Offline
New User

Joined: Sun Dec 11, 2011 9:53 am
Posts: 2
Hi

Code:
#include "BMSerial.h"
#include "RoboClaw.h"

#define address 0x80

#define Kp 0x00100000
#define Ki 0x00060000
#define Kd 0x00006000
#define qpps 12100

BMSerial terminal(0,1);
RoboClaw roboclaw(5,6);

void setup() {
  terminal.begin(38400);
  roboclaw.begin(19200);
 
  roboclaw.SetM1Constants(address,Kd,Kp,Ki,qpps);
  roboclaw.SetM2Constants(address,Kd,Kp,Ki,qpps); 
}

void loop() {

  roboclaw.SpeedDistanceM1M2(address,4000,2500,-4000,2500);

  while(1);
}


I used an arduino example.


Top
 Profile  
 
 Post subject: Re: Setting distance with Packet Serial
PostPosted: Mon Dec 12, 2011 5:08 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Ok, that looks ok. First thing I'd do is test the actual distacne the wheels turn and compare them to the encoder positions. Use the encoder reading commands to get the start positions and end positions of the move. Also check the actual movement on the wheels(with your robot off the ground). This should confirm if you have an encoder problem or a mechanical one. I would also run the same test but with both motors running the same direction. This should produce a perfectly straight movement. If it doesn't you may habe one wheel larger than the other by a small amount. You will need to compensate for this in your distance calculations.

Finally after doing all the above, you can start adjusting the I value by small amount. Increase in 0x1000 increments(eg 0x61000,0x62000, etc...) until you get bouncing in your speeds(use the speed read commands to check this because it will be noticable there before it's noticable at the wheel.

Also your qpps seems low. Did you run a test at 100% power and read back the speed to get that value? Small QPPS values can sometimes cause bounce as well. I recommend that you go over the caluclated value by 25 to 50% when the value is less than 20000. You can always bring it back down later but it will illiminate it as the cause of the speed bouncing.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO