Quote:
|
Originally Posted by team 803
How would I arrange the programming so that one controller controls the robots movement.
We have the right side motors connected through with ONE wire and the same with the left. So:
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
How would I edit this since both the right side and the left side only use one port.
pwm01
pwm02
We are using the second stick for the launcher, I am not quite sure how to set that up (two weeks experience with programming). We need it so that when the top button is pressed, the motor starts. (I think that would be aux)
pwm 04
Then when the stick is pressed forward it moves the other motor forward and when moved backwards it goes backwards.
pwm 05
|
Whoa nothing like last minute programming! So for the drive motors just replace pwm13=pwm14= with pwm01 = and the same thing for the other side so that it looks like this:
pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm02 = Limit_Mix(2000 + p1_y - p1_x + 127);
For your pwm04 motor: remember pwm ports need a value from 0 to 254, 0 is full reverse, 254 is full forward, and 127 is neutral. The aux1 input is boolean, meaning it has a value of 1 or 0. Actually in C it is an unsigned char that can be evaluated as a boolean. So assuming your second joy is connected to port 2 of your OI:
if (p2_aux1)
{
pwm04 = 254; // full forward
} else
{
pwm04 = 127; //stop
}
For your pwm05 motor: Now you have to realize that moving the joy stick around returns a value of 0 to 254. When the joys are calibrated correctly, the center position should return p2_x = 127 and p2_y = 127:
// This makes your pwm05 speed proportional to joy position with a
// deadband that alleviates accidental actuation (147 - 107 sets
// pwm05 to 127;
if (p2_y > 147 || p2_y < 107)
{
pwm05 = p2_y;
} else
{
pwm05 = 127;
}
Alternatively if you just want to turn the motor on full blast:
if (p2_y > 147)
{
pwm05 = 254;
} else if (p2_y < 107)
{
pwm05 = 0;
} else
{
pwm05 = 127;
}
Notice all the examples have a way to stop the motor. Generally you want to send all your motors a 127 when the controls are released. This is especially important for the drive motors so that if the driver releases the controls for some reason (knocked senseless by a poof ball!) the robot will stop in a stable configuration.
Good luck!