Go Down

Topic: Robot.turn() not driving motors properly (Read 292 times) previous topic - next topic

cmsb

Hi,

When I tried to use the Runaway Robot sketch with the Arduino Robot, but modified to work with the PING ultrasonic distance sensor, I noticed that everything worked fine except one function in the sketch. The issue occurred when the Robot.turn() function was called as the motors didn't appear to be receiving enough power.

I searched for this problem but couldn't seem to find anything in forums.

I managed to use Robot.write() instead to get the robot to turn using one motor forward and the other motor backward, then delay() and finally calling Robot.motorsStop(). These three functions when called pretty much imitate Robot.turn() but are much simpler as they do not include the use of the on-board compass on the robot.

Hope this helps anyone else who seems to have 'weak motors' when using Robot.turn(). Also, does anyone know if there is a way to get that function to give more power to the motors?

Chelsea

johnwasser

The advantage of Robot.turn() is that it uses the compass to determine the current heading and use the compass to control the turn.  Are there any magnets on your robot that might interfere with the compass?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

cmsb

Yeah, I inderstand that advantage. There are no motors on the robot to my knowledge and none in the surrounding area to it either, so I couldn't justify putting this problem down to magnetic interference.

The issue doesn't seem to be with the compass though, it appears to be the amount of power supplies to the motors during Robot.turn() . Do you know of any way which the code can be hacked to change the speed of the motors when this function is called?

cmsb


johnwasser


The issue doesn't seem to be with the compass though, it appears to be the amount of power supplies to the motors during Robot.turn() . Do you know of any way which the code can be hacked to change the speed of the motors when this function is called?


Go to the Robot_Control library and change this line in Motors.cpp:

Code: [Select]
uint8_t speed=80;

If you want to get fancy you can replace the fixed-speed code with a PID loop to get to a more exact heading much faster.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

cmsb

Thank You for the suggestion, however does this mean there is a bug or flaw in the library because presumably everyone who tries to run this sketch on the robot will have the same issue?

Go Up