Go to Post Feelings are like the laws of physics: if some one feels offended or alienated, then they are offended or alienated - it doesnt matter why you dropped a hammer, if it falls on someones head they will be hurt. You cant expect it to not hurt, because you did not intend to hurt them. - KenWittlief [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 01-02-2008, 18:58
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
Need Help with Sensitivity of Joysticks

I'm trying to decrease the maximum range of the joystick on the x-axis using EasyC because the robot turns too fast on the x-axis. I tried using arcade mode at first, but I don't see a way of limiting the joystick range or the PWM output via the Arcade function.

What I tried to do was limit the PWM input. As a test, instead of being 0 (Minimum output), it is now 77, and it is 177 as a maximum. I used the following code and it doesn't seem to work. Does anyone know how I can do this?

Code:
unsigned char Port1XAxis = 127; 
while ( 1 ) 
{ 
OIToPWM ( Port1XAxis , 1 , 1 , 0 ) ; 

if ( Port1XAxis <= 77 ) 
{ 
Port1XAxis = 77 ; 
//SetPWM ( 2 , 177 ) ; 
//SetPWM ( 1 , 177 ) ; 
} 

else if ( Port1XAxis >= 177 ) 
{ 
Port1XAxis = 177 ; 
//SetPWM ( 2 , 77 ) ; 
//SetPWM ( 1 , 77 ) ; 
} 
Arcade2 ( 1 , 2 , 0 , 0 , 2 , 1 , 1 , 1 ) ;
I know this code has some errors, but can someone help me figure out how to do something like this?

Thanks a lot.
  #2   Spotlight this post!  
Unread 01-02-2008, 19:14
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: Need Help with Sensitivity of Joysticks

We used this to scale our drive last year. The "Offset" is referring to how far the joystick's Y-axis potentiometer is from 127.

Code:
int Scale_Offset(int initialValue, double scaleFactor) {
	return ((double)(initialValue-127)/scaleFactor)+127;
}
In context, it looked like this:

pwm05 = Scale_Offset(p1_y,3.);
__________________
What place are we at? ... TODAI!
  #3   Spotlight this post!  
Unread 02-02-2008, 01:49
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: Need Help with Sensitivity of Joysticks

That's right and I actually tried to do a function like that, but I am using EasyC's 'Arcade 2-motor' function to be able to control all motors through one joystick and it doesn't seem to allow for any input like that.

In Arcade mode, Y-Axis movement indicates forward/reverse, and X-Axis indicates right/left, and what I want to do is limit the X-Axis max PWM to something to slow it down (maybe minimum value of 77 and max of 177).

Does anyone know if/how I can do this in EasyC?
  #4   Spotlight this post!  
Unread 02-02-2008, 13:36
xrabohrok's Avatar
xrabohrok xrabohrok is offline
hunter of errors
FRC #1208 (The Metool Brigade)
Team Role: Programmer
 
Join Date: Jan 2006
Location: O'Fallon
Posts: 62
xrabohrok is an unknown quantity at this point
Re: Need Help with Sensitivity of Joysticks

My team has been using a speacial sin curve array to tone down the sensitivity. It has kind of been a hand-me-down for four years now.

Code:
const rom unsigned char joystick_values[256] =  {  
0,   0,   0,   0,   0,   0,   0,   0, // 0   - 7
 
0,   0,   0,   0,   0,   8,  16,  24, // 8   - 15
     
30,  36,  41,  45,  50,  53,  57,  60, // 16  - 23
    
63,  65,  68,  70,  72,  74,  76,  78, // 24  - 31
 
80,  81,  83,  84,  86,  87,  88,  89, // 32  - 39
    
90,  91,  92,  93,  94,  95,  96,  97, // 40  - 47
  
98,  98,  99, 100, 101, 101, 102, 102, // 48  - 55
 
103, 104, 104, 105, 105, 106, 106, 107, // 56  - 63
  
107, 108, 108, 109, 109, 110, 110, 110, // 64  - 71
  
111, 111, 112, 112, 112, 113, 113, 114, // 72  - 79
   
114, 114, 115, 115, 115, 116, 116, 116, // 80  - 87

117, 117, 117, 117, 118, 118, 118, 119, // 88  - 95
 
119, 119, 120, 120, 120, 120, 121, 121, // 96  - 103
 
121, 121, 122, 122, 122, 122, 123, 123, // 104 - 111
  
123, 124, 124, 124, 124, 125, 125, 125, // 112 - 119
  
125, 126, 126, 126, 126, 127, 127, 127, // 120 - 127
   
127, 127, 128, 128, 128, 128, 129, 129, // 128 - 135
   
129, 129, 130, 130, 130, 130, 131, 131, // 136 - 143
     
131, 132, 132, 132, 132, 133, 133, 133, // 144 - 151
     
133, 134, 134, 134, 134, 135, 135, 135, // 152 - 159
     
136, 136, 136, 137, 137, 137, 137, 138, // 160 - 167
     
138, 138, 139, 139, 139, 140, 140, 140, // 168 - 175
     
141, 141, 142, 142, 142, 143, 143, 144, // 176 - 183
     
144, 144, 145, 145, 146, 146, 147, 147, // 184 - 191
     
148, 148, 149, 149, 150, 150, 151, 152, // 192 - 199
     
152, 153, 153, 154, 155, 156, 156, 157, // 200 - 207
     
158, 159, 160, 161, 162, 163, 164, 165, // 208 - 215
     
166, 167, 168, 170, 171, 173, 174, 176, // 216 - 223
     
178, 180, 182, 184, 186, 189, 191, 194, // 224 - 231
     
197, 201, 204, 209, 213, 218, 224, 230, // 232 - 239
     
238, 246, 255, 255, 255, 255, 255, 255, // 240 - 247
     
255, 255, 255, 255, 255, 255, 255, 255  // 248 - 255
};
It's worked for us. Just put the array like this:

Code:
pwm_01 = joystick_values[p1_y];
Do this for all pwm's you want dampend. Hope it works.

As for limiting speed, I have no idea what the arguments of the Arcade function are. If set pwms are what you are using to change the pwm values, they are commented out (you probably know that already). You also have it set 177 on the 77 if statement and 77 on the 177 if statement. Would switching those two help?
__________________
"It's programming's fault" may be a viable excuse for just about everything, except the robot falling apart.

It will 'cause it can!

constants aren't. variables won't.

Last edited by xrabohrok : 02-02-2008 at 13:42. Reason: oops
  #5   Spotlight this post!  
Unread 02-02-2008, 13:43
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Need Help with Sensitivity of Joysticks

As far as joystick sensitivity goes, our team has been using this:

Code:
long ramping (unsigned char ramp)
{
    long answer = 0;
    answer =  ((long)ramp - 127);
    answer = ((answer) * (answer) * (answer));
    answer = ((answer) / (128 * 128));
    answer = (answer) + (127);
    return answer;
}
It's not a sine function, but cubic. You should be able to have max speed at full forward, but also have better control with lower values. Something like:

http://www.chiefdelphi.com/forums/at...9&d=1201127844
  #6   Spotlight this post!  
Unread 02-02-2008, 14:21
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: Need Help with Sensitivity of Joysticks

Quote:
Originally Posted by psy_wombats View Post
As far as joystick sensitivity goes, our team has been using this:

Code:
long ramping (unsigned char ramp)
{
    long answer = 0;
    answer =  ((long)ramp - 127);
    answer = ((answer) * (answer) * (answer));
    answer = ((answer) / (128 * 128));
    answer = (answer) + (127);
    return answer;
}
It's not a sine function, but cubic. You should be able to have max speed at full forward, but also have better control with lower values. Something like:

http://www.chiefdelphi.com/forums/at...9&d=1201127844
We're using a quadratic function. The only problem is that x*x is always positive, so we defined an absolute value function and do x*abs(x).
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
Sensitivity Wheels - help please naor52 Programming 6 20-01-2006 09:13
Help with Joystick Axes and Sensitivity bglass Programming 6 06-02-2005 14:01
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46
Need help with C++ Tton Programming 7 04-11-2003 19:15
Could use some help with joysticks . . . archiver 2001 5 23-06-2002 23:36


All times are GMT -5. The time now is 19:07.

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