Go to Post The game is going to be exciting. I want a front row seat and a big box of buttered popcorn. - JaneYoung [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-11-2009, 18:46
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,573
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Exclamation [FTC]: Slow Down Max Speed!!

in robotC what is the code you need to put in to make your Max speed decrease?
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #2   Spotlight this post!  
Unread 13-11-2009, 18:55
NickE's Avatar
NickE NickE is offline
_
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: San Jose, CA
Posts: 620
NickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond repute
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;
A better solution would probably be to re-gear the robot for the desired speed. In changing the maximum speed in code, you cannot use the maximum power of the motors.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-11-2009, 21:06
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,573
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
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.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #4   Spotlight this post!  
Unread 13-11-2009, 21:10
NickE's Avatar
NickE NickE is offline
_
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: San Jose, CA
Posts: 620
NickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond repute
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){
   motor[port1] = 80;
}else if(vexRT[Ch1]<-80){
   motor[port1] = -80;
}else{
   motor[port1] = vexRT[Ch1];
}
Reply With Quote
  #5   Spotlight this post!  
Unread 13-11-2009, 21:18
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,573
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Slow Down Max Speed!!

Quote:
Originally Posted by NickE View Post
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){
   motor[port1] = 80;
}else if(vexRT[Ch1]<-80){
   motor[port1] = -80;
}else{
   motor[port1] = vexRT[Ch1];
}
i will try and see if i can make this into FTC code thanks.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #6   Spotlight this post!  
Unread 14-11-2009, 07:49
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Slow Down Max Speed!!

Quote:
Originally Posted by John_1102 View Post
i will try and see if i can make this into FTC code thanks.
I would recommend you take the scaling route (NickE's first example) as the second example will limit the output to the motor by only listening to 2/3 of the range of your analog stick (less control).
That or use a predefined speed constant with a simplified on/off control.
Reply With Quote
  #7   Spotlight this post!  
Unread 14-11-2009, 09:08
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,573
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Slow Down Max Speed!!

Quote:
Originally Posted by l0jec View Post
I would recommend you take the scaling route (NickE's first example) as the second example will limit the output to the motor by only listening to 2/3 of the range of your analog stick (less control).
That or use a predefined speed constant with a simplified on/off control.
do you know the FTC code for that?
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #8   Spotlight this post!  
Unread 14-11-2009, 21:31
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Slow Down Max Speed!!

Quote:
Originally Posted by John_1102 View Post
do you know the FTC code for that?
There are many ways to go about it, but I would create a scaling function. Here is an example with the important constants defined within the function. For best performance, I would recommend you calculate the ratio with the constants defined staticaly outside of the function (avoid calculating the ratio on each call).

Code:
int simpleScale(int joyVal) {
  
  const int MAX_JOY_VAL = 127;
  const int MAX_MOTOR_VAL = 100;
  const int DEADZONE = 5;
  
  //check for deadzone
  if(abs(joyVal) < DEADZONE) {
    return 0;
  }
  
  //calculate ratio based on max motor speed and max analog stick value
  float ratio = (MAX_MOTOR_VAL/MAX_JOY_VAL);
  //apply ratio to actual joystick value
  int result = (joyVal)*ratio;
  return result;  
 
}
Note that you should adjust the MAX_MOTOR_VAL constant to whatever max power output you want. Remember that the motors go from -100 to +100, so if you leave it at 100, you get 100% of your power; setting it to 80 gives you 80% and so on.

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
  motor[someMotor] = simpleScale(joy1_y1);
If you want to turn the motors on/off with a toggle button instead, you should create an if/else set of statements in your main task to check if the on or off buttons have been pressed and set the motors to either the desired max output (on) or to zero (off).
Reply With Quote
  #9   Spotlight this post!  
Unread 16-11-2009, 02:35
NickE's Avatar
NickE NickE is offline
_
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: San Jose, CA
Posts: 620
NickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond repute
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) {
  
#define MAX_JOY_VAL 127
#define MAX_MOTOR_VAL 100
#define DEADZONE 5
  
  //check for deadzone
  if(abs(joyVal) < DEADZONE) {
    return 0;
  }
  
  //calculate ratio based on max motor speed and max analog stick value
  float ratio = (MAX_MOTOR_VAL/MAX_JOY_VAL);
  //apply ratio to actual joystick value
  int result = (joyVal)*ratio;
  return result;  
 
}
Reply With Quote
  #10   Spotlight this post!  
Unread 16-11-2009, 10:46
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,573
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Slow Down Max Speed!!

Quote:
Originally Posted by NickE View Post
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) {
  
#define MAX_JOY_VAL 127
#define MAX_MOTOR_VAL 100
#define DEADZONE 5
  
  //check for deadzone
  if(abs(joyVal) < DEADZONE) {
    return 0;
  }
  
  //calculate ratio based on max motor speed and max analog stick value
  float ratio = (MAX_MOTOR_VAL/MAX_JOY_VAL);
  //apply ratio to actual joystick value
  int result = (joyVal)*ratio;
  return result;  
 
}
Thanks i shall try these .
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #11   Spotlight this post!  
Unread 16-11-2009, 13:24
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Slow Down Max Speed!!

Quote:
Originally Posted by NickE View Post
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.
That is true of normal C, but ROBOTC claims that their scalar constants work like true constants and will not allocate additional memory/etc. Notice that I used the "const" keyword when defining those variables.
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: January Run Down and New FTC Pictures ttldomination FIRST Tech Challenge 6 04-02-2009 13:18
Slow down teh motors! brennerator Programming 21 18-01-2007 23:30
Cheapest and easiest way to slow down a motor sanddrag Technical Discussion 41 21-12-2005 07:26
speed controller max speed Team 668 Programming 15 13-02-2005 14:05
Segway max speed? Morgoth Dean Kamen's Inventions 2 15-04-2003 20:11


All times are GMT -5. The time now is 18:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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