Go to Post Aaaah - interpersonal dynamics - the root of most problems on most teams. - UCGL_Guy [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-01-2008, 21:50
Neurovirus Neurovirus is offline
Registered User
FRC #0224
 
Join Date: Jan 2008
Location: Piscataway
Posts: 13
Neurovirus is an unknown quantity at this point
Reducing the sentivity of the joystick in easyC Pro

possible or not?

I read that you'll need to change the joystick's linear function to a cubic one?

so how do you do that in easyC?

I think you'll need a look up table to save processing power calculating it...so how do you implement that in easyC?
also I'm a newbie, so try to make it so that a 10 year old could understand it

or you can upload the easyC file =D

thanks for the help,
neurovirus
  #2   Spotlight this post!  
Unread 17-01-2008, 23:01
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: Reducing the sentivity of the joystick in easyC Pro

There are two things you can do fairly easily that might work for you:

1. Establish a deadband for your joystick. A deadband gives an area for your joystick that won't move the robot. For example you can set a deadband of 20 so that unless your joystick moves past 147 or 107, then it sends 127 to the robot. When past 147 input joystick -20 to the robot. When past 107 input joystick + 20 to the robot. This solution is easy, but you loose the extremes and your bot may still be too twitchy.

2. Use Excel to generate your lookup table. An array of 256 values. You may prefer to use a hyperbolic function so that values close to joystick center have very little effect, but extreme values will input full power to your motors. You could combine this with your deadband for best effect. Save the file as a comma delimited text for easier transfer into EasyC.

Hope this helps!

Dan
  #3   Spotlight this post!  
Unread 17-01-2008, 23:40
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Reducing the sentivity of the joystick in easyC Pro

I have been playing around with different functions for the joysticks as well. One method that I have been playing around with is a simple linear function that reduces the overall speed of the bot, with the deadband in there, and allowing it to go to full speeds when the driver holds down a button. I know you are using easy c, but this should be understandable:

Code:
if(p1_sw_trig==1)
{
	pwm01=Set_Neutral(p1_y);
	pwm02=Set_Neutral(p2_y);
}
	
else
{
	 pwm01 = Set_Neutral(  ( (.44)*p1_y)+70  ); 
 	 pwm02 = Set_Neutral(  ( (.44)*p2_y)+70  );   
}
Set_Neutral is my deadband function. So right now the maximum forward I can go is 181 and opposite with the reverse. If the driver wants to go full speed ahead right now they just hold down the left trigger. I have heard that too much floating point arithmetic puts more strain on the processor though, so just don't use too much. Hope this helps
  #4   Spotlight this post!  
Unread 18-01-2008, 00:50
JohnC's Avatar
JohnC JohnC is offline
my other name is nigel
FRC #0360 (360 Revolution)
Team Role: Programmer
 
Join Date: Mar 2005
Rookie Year: 2005
Location: user_routines.c
Posts: 100
JohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the rough
Send a message via AIM to JohnC
Re: Reducing the sentivity of the joystick in easyC Pro

This was last year's drive code:
Code:
if(p1_sw_trig && p2_sw_trig) {
  Left(p1_y);
  Right(p2_y);
} else {
  Left(Scale_Offset(p1_y,driveScale);
  Right(Scale_Offset(p2_y,driveScale);
}

//later, not in the routine that loops every 26.2 ms...

int driveScale = 3;

int Scale_Offset(int speed, int scaleFactor) {
  return ((speed-127)/scaleFactor) + 127;
}
It worked really well for us
__________________
What place are we at? ... TODAI!
  #5   Spotlight this post!  
Unread 18-01-2008, 13:27
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Reducing the sentivity of the joystick in easyC Pro

This is how this would look in easyC

Code:
void OperatorControl ( void )
{
      int joy_y_port1; 
      int joy_y_port2; 
      unsigned char left_output; 
      unsigned char right_output;
      while ( 1 )
       {
            joy_y_port1 = GetOIAInput ( 1 , 2 ) ;  // Get Joystick Data
            joy_y_port2 = GetOIAInput ( 2 , 2 ) ;  // Get Joystick Data
            /* Remove 127 Setting the joystick scale from 0-255 to -127 0 127. 
               Then Divide the output in half and then add 127 back to return the 
                scale to 0-255.*/
            left_output  = ((joy_y_port1 - 127 ) / 2) +127 ; //See Above
            right_output  = ((joy_y_port2 - 127 ) / 2) +127 ; // See Above
            SetPWM ( 1 , left_output ) ;  //Send left output to PWM1
            SetPWM ( 2 , right_output ) ; //Send right output to PWM 2
      }
}
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #6   Spotlight this post!  
Unread 18-01-2008, 14:17
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: Reducing the sentivity of the joystick in easyC Pro

Instead of using a floating point constant like this:
Code:
foo = bar * 0.44;
you can do this:
Code:
foo = bar * 44 / 100;
Note that the following, with the divide operation first, is not the same, because integer division throws away any remainder:
Code:
foo = bar / 100 * 44; // BAD IDEA!
Even better (if bar is always positive) you could do this:
Code:
foo = (bar * 113) >> 8;
The " >> 8 " divides the result by 256 (shifts the bits to the right eight places). The value 113 is .44 times 256. Be sure to use an int type for bar (16 bits), not a char type (8 bits); The shift operator " >> " behaves unpredictably for negative numbers.
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
  #7   Spotlight this post!  
Unread 18-01-2008, 19:33
iwin2000 iwin2000 is offline
Registered User
no team
 
Join Date: Dec 2007
Rookie Year: 2008
Location: CT
Posts: 23
iwin2000 has a spectacular aura aboutiwin2000 has a spectacular aura about
Re: Reducing the sentivity of the joystick in easyC Pro

Would simply configuring a Tank or Arcade function remove the need for all of that code, or is it necessary to do it like that?
  #8   Spotlight this post!  
Unread 18-01-2008, 22:27
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Reducing the sentivity of the joystick in easyC Pro

You can simply use a tank or arcade function to drive your robot. The poster in this case wanted to "numb" the output form the joystick for what ever reason so these are examples of how it can be done. This is defiantly not required....
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #9   Spotlight this post!  
Unread 18-01-2008, 22:56
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Reducing the sentivity of the joystick in easyC Pro

This was brought up in a previous thread. One of the easiest ways to do this is :

Code:
#define Motor_Max (put your maximum value here)
#define Motor_Min (put your minimum value here)
#define statements go at the top of your code

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.
__________________
  #10   Spotlight this post!  
Unread 19-01-2008, 09:30
robotrobot2's Avatar
robotrobot2 robotrobot2 is offline
Computer Overlord
FRC #0151 (Tough Techs)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Nashua NH
Posts: 14
robotrobot2 is on a distinguished road
Re: Reducing the sentivity of the joystick in easyC Pro

When you have the x and y coordinates, just multiply them by themselves minus a constant and then take the square root. It should look like:

Code:
joystickx=joystickx*(joystickx-2);
joystickx=squareroot(joystickx);
joysticky=joysticky*(joysticky-2);
joysticky=squareroot(joysticky);
then just use the coordinates as you normally would. This will reduce the sensitivity a little but will still allow extremes.
__________________
Everything can always be blamed on software:

The claw can't pick up the trackball-
programmers must have messed up the claw function.

The driver crashes the robot into a wall-
the drive code must not be responsive enough.

The robot repeatedly displays "HELLO WORLD"-
that probably is software.
Closed Thread


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
Question about the EasyC Pro CD-Key itsme Programming 9 11-01-2008 23:36
easyC PRO Tutorial - Including the Camera Kingofl337 Programming 4 21-08-2007 16:32
useful easyC Pro Functions not on the Tree Kingofl337 Programming 0 09-02-2007 00:01
Does EasyC Pro work with the USB-Chicklet? lightning_blast Programming 6 20-01-2007 23:39
Please post any new questions in the easyC PRO Forum Kingofl337 Programming 0 16-01-2007 11:43


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

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