|
Re: Slow down teh motors!
I'm so excited...something I can respond to.
We had the same problem with our robot. I doesn't give you the same variability as the other methods but it let us drive the robot.
Our driver motors are pwm01 and 02. The values that you set them for are the actual speed that you end up going. You are basically partitioning different areas of joystick placement to different output voltages (speed). Be carefull how you order each statement since its an if else if statement and it checks stuff in order that you put it in. You will also notice that the minimum amount of joystick movement before the robot actually moves is 27
going backward and 18 going forward. That way there was a little bit of dead stick in the middle since the sticks were too sensitive at the start. You can add more else if statements to put in more drive speeds. You could make the extreme ends ( 0 and 254) to actually go 0 and 254 (100% forward and backward).
if (p1_y < 50) //back fast
{
pwm01 = 120; //ange these values to the actual speed you want
pwm02 = 120; //"speed" is how far forward and backward you go
}
else if (p1_y < 100) // back slow
{
pwm01 = 123;
pwm02 = 123;
}
else if (p1_y >200) //forward fast
{
pwm01 = 155;
pwm02 = 155;
}
else if (p1_y > 155)//forward slow
{
pwm01 = 145;
pwm02 = 145;
}
else //stop and idle
{
pwm01=127; //left motor
pwm02=127; //right motor
}
|