View Single Post
  #5   Spotlight this post!  
Unread 14-02-2007, 12:02
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: Banebots/Cim motor programming question

Quote:
Originally Posted by Japper View Post
I have checked for binding and we had this issue on one motor but then resolved it...

I also tried to scale up the slower motor and was not as successful at this and was wondering if there are any programming gurus out there that have mastered this technique that wouldn't mind sharing their secrets on how to do this...
Unfortunately there really isn't any magic piece of code to solve your problem simply. One aspect of robot building is discovering that even with perfect programming (if there is such a thing) you are still subjected to the vagaries of mechanical systems. No two motors will behave exactly the same due to machining and electrical tolerances. This statement is even more true when spinning motors in opposite directions because most motors naturally drive better in one direction than the other. This is called motor bias. So even if every thing is built beautifully and programmed perfectly, if both sides of the drive train get an equal signal, you will at the very best drive in an arc. I'm sure that a lot of newer teams out there end up with a robot that spins wildly the first time they try and drive.

So how to fix?

BEST way is to use your sensors. In this case the gyro can be your best friend. The gyroscope can tell you what direction your robot is pointing (relative to starting position) AND how fast it is turning (because the gyro is ACTUALLY a turn rate sensor, not a compass). So, if your robot is driving in a straight line, your gyro will provide feedback to your program: "driving in a straight line, don't need to change a thing". However, if it starts to veer off of the straight line: "turning at x rate" You take this information and adjust power to your motors to turn it back the other way. Simplified code:

error = gyroTurnRate*0.3;
leftMotor = joyYval - error;
rightMotor = joyYval +error;

Those 3 lines of code (implemented correctly for YOUR robot) will keep you driving straight.


Now if you AREN'T going to use sensors, your idea of scaling the slow motor is ok. The problems you have with making it work, though, is that the difference in speeds between the left and right sides might not necessarily be linear. In this case, the scaling factor will only work at one pwm value. To be very thorough, you can use a strobe light to get the speed of each wheel at all PWM inputs (0-255). Then adjust accordingly. If you use this method a lookup table can come in handy, or figure out an equation that approximates your data. Keep in mind, however, that as you drive your robot, this values will change significantly due to wear, or damage, or just breaking in. That is why I strongly encourage using sensor data, because even if the differences between the motors change over time, it can still be fixed easily with the software.

Hope this helps a little!