|
|
|
| I'm over the moon for you. |
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
EasyC Vex Programming help in RC Mode
My son and I are quite new to Easy C, so your help is greatly appreciated.
We are now programming our vex bot for the FIRST Quad Quandary competition. Our basic setup works fine, but one of our functions works poorly if the motor goes too fast. We don't have room to gear it down any more than it is, so we're wondering if there is a way to program a speed limit into RC mode. As it is, it's a little too easy to overdo it with the joystick. Also, is there a way to have the vex controller initiate a preprogramed sequence similar to autonomous mode? thanks, Nathan's Dad |
|
#2
|
|||||
|
|||||
|
Re: EasyC Vex Programming help in RC Mode
This thread addresses making a motor respond more slowly:
http://www.chiefdelphi.com/forums/sh...ad.php?t=53643 You can use the buttons on the back of the transmitter to signal your code to start a sequence of commands. |
|
#3
|
||||
|
||||
|
Re: EasyC Vex Programming help in RC Mode
Quote:
Did you check out the worm gear in the advanced gear kit? it provides a 24:1 reduction in a very small package. If you decide that you must slow down the motor in software, keep in mind that a DC motor reduces speed linearly with voltage but the power is reduced by the square of the voltage. In other words, you will also be reducing torque... Depending on your application, the mechanical option may be best. Mike Last edited by Mike Betts : 06-12-2007 at 09:13. |
|
#4
|
|||||
|
|||||
|
Re: EasyC Vex Programming help in RC Mode
If your mechanism does not need a lot of power (see Mike's post), then you can limit the speed in software. First you would map the Rx Input to a variable. Since the values coming back from the transmitter range from 0 to 255, with 127 neutral, we subtract 127 so our values are now centered around 0. (Don't declare your variable as an unsigned char, use int here!)
The next step is to multiply our new value times a coefficient between 0 and 1. But since the controller only likes to play well with integers, if we want the motor to only go 60% of max speed, we can multiply ourVariable = ourVariable * 6 / 10; with replacing ourVariable with whatever you declared your variable as. Then we add 127 back into this, and set this value to the motors. By adjusting the coefficient, you can narrow down or widen how much available speed you want to send to a motor. |
|
#5
|
||||
|
||||
|
Re: EasyC Vex Programming help in RC Mode
First of all, instead of just setting 60 in the code, wouldn't it be easier to #define it at the start of the code? That way if you want to change it, you can just change it there and don't have to fish for it in the rest of the code.
Code:
#define Percent_Speed 60 //defines the percent of max speed you want to go Quote:
Instead of declaring an int and wasting memory, why wouldn't you just declare the variable as an unsigned short and typecast the variable during the operation? Code:
unsigned short ourVariable; Assign it to your input(not shown here). Code:
ourVariable = (((int)ourVariable - 127) * Percent_Speed / 10) + 127; //calculations motor = ourVariable; //output ourVariable to motor. Inserting (int) in front of ourVariable makes the program treat ourVariable as an integer for that operation (to give it room to perform the operation), but once the operation is done, ourVariable will return to a nice little unsigned char that doesn't hog memory. Last edited by slavik262 : 06-12-2007 at 18:46. Reason: revisions |
|
#6
|
|||
|
|||
|
Re: EasyC Vex Programming help in RC Mode
How sensitive is it to a joystick?
If you are working where you only want it to react to the joystick to a point then what you could do is the following ... If GetRxInput (1,1) > Max Forward (you define) SetMotor (1,Max Forward) - If joystick is pushed farther than desired position do not let motor go any faster If GetRxInput (1,1) < Max Backwards (you define) SetMotor (1,Max Backwards) - Same as above only backwards Else MotorRcControl (0,1,1,0) - Respond to joystick value to value (180 on Joystick= 180 to motor) If you are Not using most of the joysticks movement before it gets out of hand then you could do the following ... If GetRxInput (1,1) > 135 -Allow play in joystick SetMotor (1,speed desired forward) - you define If GetRxInput (1,1) < 120 -Allow play in joystick SetMotor (1,speed desired backwards) - you define Else SetMotor (1,127) This gives the motor only two speeds that it is allowed to run. Hope that helps. If you have any questions about this feel free to PM me. -Sam |
|
#7
|
||||
|
||||
|
Re: EasyC Vex Programming help in RC Mode
That code is much easier to manage as well. The code for that would be:
Code:
#define Motor_Max (put your maximum value here) #define Motor_Min (put your minimum value here) Code:
if (GetRxInput(1,1) > Motor_Max) SetMotor(1, Motor_Max); //Don't go any faster than your max else if (GetRxInput(1,1) < Motor_Min) SetMotor(1, Motor_Min); //Likewise, don't let the motor go slower than the min, regardless of what the joystick says. else SetMotor(1, GetRxInput(1,1)); //If the joystick is not above the max or below the minimum, assign it directly to the input. Last edited by slavik262 : 06-12-2007 at 17:41. |
|
#8
|
|||
|
|||
|
Re: EasyC Vex Programming help in RC Mode
Exactly
-Sam |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming help. EasyC Vex Robot. | OneCoolDude | Programming | 2 | 02-12-2007 17:54 |
| Need help with ramping in VEX EasyC | T. Maty | Programming | 4 | 03-11-2006 12:17 |
| Arrays in Vex Programming Kit EasyC? | gblake | FIRST Tech Challenge | 9 | 12-09-2006 17:05 |
| EasyC-Vex Rx/motor frustrations- please help! | Steve0100 | Programming | 10 | 08-07-2006 02:18 |
| White Paper Discuss: VEX / intelitek easyC programming document | dez250 | Extra Discussion | 3 | 15-09-2005 15:20 |