![]() |
[FTC]: Slow Down Max Speed!!
in robotC what is the code you need to put in to make your Max speed decrease?
|
Re: [FTC]: Slow Down Max Speed!!
Divide the input by a constant before sending the value to the motors. I'm not too familiar with FTC, but in RobotC for Vex, it would look like something like this:
Code:
motor[port1] = vexRT[Ch3] / 1.5; |
Re: [FTC]: Slow Down Max Speed!!
We need to slow the drive motors because we are using a 4:1 ratio and it's still too fast. i want to make the joysticks max be a certain speed.
|
Re: [FTC]: Slow Down Max Speed!!
The code i put above would scale the input to the output. To limit it without scaling, do something like this:
Code:
if(vexRT[Ch1]>80){ |
Re: [FTC]: Slow Down Max Speed!!
Quote:
|
Re: [FTC]: Slow Down Max Speed!!
Quote:
That or use a predefined speed constant with a simplified on/off control. |
Re: [FTC]: Slow Down Max Speed!!
Quote:
|
Re: [FTC]: Slow Down Max Speed!!
Quote:
Code:
int simpleScale(int joyVal) {You can call the function from your main task similar to this: Code:
//scale output to someMotor based on joystick 1 analog stick 1 y axis |
Re: [FTC]: Slow Down Max Speed!!
Instead of using variables as in l0jec's example, you could use #define statements to reduce memory usage and potentially speed up the program execution some. With a #define statement, the compiler in RobotC will replace all instances of 'MAX_JOY_VAL', for instance, with the value defined in the statement. The robot will see the defined values and not the names for the values defined in the statements. Be sure not to use either equals signs or semicolons in these lines.
Here's the same code he posted, except with #define statments: Code:
int simpleScale(int joyVal) { |
Re: [FTC]: Slow Down Max Speed!!
Quote:
|
Re: [FTC]: Slow Down Max Speed!!
Quote:
If we're not changing the MAX_MOTOR_VAL or MAX_JOY_VAL, then we're still wasting CPU on a floating point calculation on each call though. The ratio variable could also be pulled out of the function and made a constant if we want to be crazy with optimization. Another more flexible option for such a method would be to take a joystick analog stick value as well as a max motor speed as arguments and calculate a custom scale on the fly. Would be useful if you want to provide multiple scales (based on max output) for different motors from a single function. |
| All times are GMT -5. The time now is 18:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi