View Full Version : Controlling
team 803
21-02-2006, 11:46
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
team 803
21-02-2006, 11:47
I am really bad at describing.
TubaMorg
21-02-2006, 12:31
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!
team 803
21-02-2006, 12:52
I put this code in
pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm02 = Limit_Mix(2000 + p1_y - p1_x + 127);
and got this error
H:\Project\Project\user_routines.c:139:Error: syntax error
KenWittlief
21-02-2006, 12:59
I dont see anything wrong with those two lines of code
I think the error message is telling you there is a syntax error on line 139 of your code?
check your code and see what is on line 139
team 803
21-02-2006, 13:02
hmmm, my friend decided that it would be nice to insert a random period in the file.
team 803
21-02-2006, 13:03
Where would I insert the code for the 04 and 05 code lines?
KenWittlief
21-02-2006, 13:15
right after the other lines you added/edited.
also search your code for those pwms to make sure they dont get set to 127 right before the serial output.
If there are more than one pwm0x = nnn assignments in your code, the last one is the one that takes effect.
team 803
21-02-2006, 13:42
Okay, I put it all in, and built it, this error came up.
H:\Project\Project\user_routines.c:230:Error [1105] symbol 'p2_aux1' has not been defined
KenWittlief
21-02-2006, 13:50
look at the default code and see what the exact variable name is. I dont know off the top of my head, it should be something like p2_sw_aux1 ?
team 803
21-02-2006, 13:56
Well, I was just informed that that code will not be needed, Thx for the help
Cheers!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.