Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Reversing controls? (http://www.chiefdelphi.com/forums/showthread.php?t=35728)

Calvin 02-03-2005 23:34

Reversing controls?
 
Ok we shipped the robot, and now our team decided that they want to redefine which side of the robot is the front. I don't have anything to test this.. but would this work:

pwm01 = ((-1 * p2_y) + 255);
pwm02 = ((-1 * p1_y) + 255);

Mike Betts 02-03-2005 23:40

Re: Reversing controls?
 
Quote:

Originally Posted by Calvin
Ok we shipped the robot, and now our team decided that they want to redefine which side of the robot is the front. I don't have anything to test this.. but would this work:

pwm01 = ((-1 * p2_y) + 255);
pwm02 = ((-1 * p1_y) + 255);

I usually do:

pwm01 = 254 - p2y;

et cetera...

255 is usually a reserved value for these types of speed controllers.

Regards,

MikeDubreuil 02-03-2005 23:40

Re: Reversing controls?
 
Quote:

Originally Posted by Calvin
pwm01 = ((-1 * p2_y) + 255);
pwm02 = ((-1 * p1_y) + 255);

You almost have it, add 254 instead. The controls and victors operate on values from 0 to 254. To test whether this works, try your formula in excel; it can be a great tool for determining if your algorithms are correct.

ldeffenb 03-03-2005 07:20

Re: Reversing controls?
 
Actually, testing in Excel won't fix this one. MPLAB and the IFI environment makes the pwm and joystick values unsigned chars. I'm not sure if the -1* will change this, but the 254-p1_y is certainly a safer way to go and executes faster than a multiply anyway.

Cody Carey 03-03-2005 21:13

Re: Reversing controls?
 
Wouldn't you be able to just switch the output wires on the speed controller(s),or would that be illegal?

EricS-Team180 03-03-2005 22:06

Re: Reversing controls?
 
Not only do you want to reverse the output pwm values, you will also want to swap the left and right side

At the "swamp thing" scrimmage a few weeks ago, we decided to swap front and back in between rounds. After simply reversing the output pwms (255-output pwm), we found out much to our driver's amusement that not only were front and back reversed, but so were left and right :D


....it is also a good idea to "min/max" the outputs to stay between 1 and 254

eric

Calvin 03-03-2005 23:52

Re: Reversing controls?
 
Ok, Thanks

xchezhd 08-03-2005 21:26

Re: Reversing controls?
 
[/quote]

....it is also a good idea to "min/max" the outputs to stay between 1 and 254

eric[/quote]

I'm trying to use the min function on digital_in14 to limit the reverse on PWM11. The motor is activated by the p3_sw_trig.

Exactly how do I use it? just call it every loop in process_data_from_local_io

==> xchezhd

EricS-Team180 14-03-2005 22:05

Re: Reversing controls?
 
Quote:

Originally Posted by xchezhd

I'm trying to use the min function on digital_in14 to limit the reverse on PWM11. The motor is activated by the p3_sw_trig.

Exactly how do I use it? just call it every loop in process_data_from_local_io

==> xchezhd

...hmmm I suppose you are refering to:
void Limit_Switch_Min(unsigned char switch_state, unsigned char *input_value); ... in UserRoutines.c

so I'd try something like:
/* set up a temp char variable */
unsigned char lnTemp ;

/* with your input switch wired "normally open", rc_dig_in14 is normally pulled hi...ie 1 or the enum OPEN. So, closing the switch will set it 0, or CLOSED. Then if pwm11 is < 127, Limit_Switch_Min will set it back to 127
*/
lnTemp = pwm11 ;
Limit_Switch_Min(rc_dig_in14, &lnTemp) ;
pwm11 = lnTemp ;

We didn't use this function, and, in fact, chose to wire our limit switches, normally closed. That way, they return 0 or false all of the time and 1 or true, when tripped....just a matter of taste, really...

so looking at it our way:
if (rc_dig_in14)
{
if ( pwm11 < 127)
pwm11 = 127 ;
}

...hope that helps,
Eric

Kyle T 14-03-2005 22:22

Re: Reversing controls?
 
Couldn't you just flip the joysticks around in the controller? :-p

Rick TYler 14-03-2005 22:46

Re: Reversing controls?
 
Quote:

Originally Posted by Kyle T
Couldn't you just flip the joysticks around in the controller? :-p

We did this one round when the driver lost the arm (PWM plug problem) and decided the rear was the better choice for pushing people around. He ripped up the joysticks from the velcro and turned them around during the match.


All times are GMT -5. The time now is 04:42.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi