Saturday, February 11, 2012

Navigation Continued...

So why does the robot not turn consistently the same time, everytime? I sought to find out.
Here are the reasons I came up with.

1. The voltage drop when the battery gets drained makes the motors weaker
2. Both motors should be turning equal amounts when turning in place, but it's very difficult to get the motors to do this consistently no matters what motor power values are used.

In realizing two, it occurred to me that the encoder should be all that is necessary to get both wheels to turn the same amount. I then tried to devise a code that can do this. I figured that I can take the difference of the encoder values between the left and right side, and use this to power the weaker motor. Essentially this will give the weaker motor a boost until both sides are turning equally, then the power would diminish.

I was able to achieve this with two lines of code.

  int delta;
  delta = SensorValue[leftEncoder] - SensorValue[rightEncoder];
  motor[motorR] = 55;
  motor[motorL] = 55 + delta;



Sucess! Both sides turns evenly during a turn.

Testing this gave me consistent turns! I tested a left turn 25 times and it turned a perfect 90 degrees every time.

No comments:

Post a Comment