Go to Post All I have to say is --- Life == FIRST - Lora Knepper [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 23-04-2008, 21:09
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
FRC #2429 (LCEC)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Joystick Input Mapping

This last competition for 2008, in my teleop code I had around 2000 lines of code just basically going like this:
if (p1_y == 0)
{
pwm13 = 0;
}
and ect... for all of them, what I was trying to accomplish was a slow steady raise in speed the more you push the controller forward, the method I used proved to be ineffective. I might also add when I was programming for this I was using the controllers that came in the kit of parts. Has anyone had any success doing what I tried to achieve? If so plz either tell me or instruct me in a different path, on how to accomplish this task.
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
  #2   Spotlight this post!  
Unread 23-04-2008, 21:15
Branden Ghena's Avatar
Branden Ghena Branden Ghena is offline
Previously: tawnos23
FRC #0240 (TEMPEST)
Team Role: College Student
 
Join Date: Nov 2005
Rookie Year: 2004
Location: Houghton, Michigan (MTU)
Posts: 303
Branden Ghena has a spectacular aura aboutBranden Ghena has a spectacular aura aboutBranden Ghena has a spectacular aura about
Re: Joystick Input Mapping

Is there a reason why you couldn't put:

Code:
pwm13 = p1_y;
__________________
Branden Ghena - Michigan Tech Student and Team 240 Alumnus
Working Towards: Electrical Engineering and Computer Engineering Double Major

"All we have to decide is what to do with the time that is given to us." - Gandalf
  #3   Spotlight this post!  
Unread 23-04-2008, 21:26
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: Joystick Input Mapping

We do a few things, first we make everything into a signed char, and set the middle point of the joystick or PWM to 0, to get a range of -128 to 127, this makes things a bit easier to handle.

For our joystick input we put everything through a curve that we calc' in a speadsheet and then convert to a table like this:

#define curveXX curve18
char curve18[] =
{
0 , 0 , 0 , 1 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5 , 6 , 6 ,
7 , 8 , 8 , 9 , 10 , 10 , 11 , 12 , 12 , 13 , 14 , 15 , 15 , 16 , 17 , 18 ,
18, 19 , 20 , 21 , 22 , 23 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 ,
33 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 47 , 48 ,
49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 60 , 61 , 62 , 63 , 64 , 65 ,
66 , 68 , 69 , 70 , 71 , 72 , 74 , 75 , 76 , 77 , 78 , 80 , 81 , 82 , 83 , 85 ,
86 , 87 , 88 , 90 , 91 , 92 , 93 , 95 , 96 , 97 , 99 , 100, 101, 103, 104, 105,
107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120, 121, 123, 124, 126, 127
};

char GetCurve(char raw)
{
if (raw < 0)
return -curveXX[-raw];
else
return curveXX[raw];
}

This alows us to tweek the curve by hand if we need to.

-Jim
  #4   Spotlight this post!  
Unread 23-04-2008, 21:27
dtengineering's Avatar
dtengineering dtengineering is offline
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,829
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: Joystick Input Mapping

Quote:
Originally Posted by tawnos23 View Post
Is there a reason why you couldn't put:

Code:
pwm13 = p1_y;
I believe the goal here is exponential mapping... reducing sensitivity of the joystick near neutral values, while maintaing a full range of output values.

Some key terms to search CD for are:

joystick mapping exponential lookup

Using all of those or some combination thereof will provide lots of discussion on this topic.

Another good place to look is in the "white papers", where you will find resources far more extensive than in any one post. This one might be helpful.

Jason
  #5   Spotlight this post!  
Unread 23-04-2008, 21:30
Branden Ghena's Avatar
Branden Ghena Branden Ghena is offline
Previously: tawnos23
FRC #0240 (TEMPEST)
Team Role: College Student
 
Join Date: Nov 2005
Rookie Year: 2004
Location: Houghton, Michigan (MTU)
Posts: 303
Branden Ghena has a spectacular aura aboutBranden Ghena has a spectacular aura aboutBranden Ghena has a spectacular aura about
Re: Joystick Input Mapping

Quote:
Originally Posted by dtengineering View Post
I believe the goal here is exponential mapping...
Ohhhh.....

Well in that case an array is probably a good idea.
__________________
Branden Ghena - Michigan Tech Student and Team 240 Alumnus
Working Towards: Electrical Engineering and Computer Engineering Double Major

"All we have to decide is what to do with the time that is given to us." - Gandalf
  #6   Spotlight this post!  
Unread 23-04-2008, 21:54
programMORT11
 
Posts: n/a
Re: Joystick Input Mapping

Why not use a proportional increment like

Code:
static char flag;
if(joy_flag == 0) {
old_joy = p1_y; flag =1;
} else {
if(old_joy < p1_y && (p1_y != 127))
new_joy+=5;
else if (old_joy < p1_y && (p1_y != 127))
new_joy -= 5;
else
new_joy = 0;
flag = 0;
} p1_y = old_joy + new_joy;

Last edited by programMORT11 : 23-04-2008 at 22:06.
  #7   Spotlight this post!  
Unread 23-04-2008, 22:03
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
FRC #2429 (LCEC)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Re: Joystick Input Mapping

Quote:
Originally Posted by tawnos23 View Post
Is there a reason why you couldn't put:

Code:
pwm13 = p1_y;
The reason was because I was trying to make it less sensitive then it was, it was really sensitive. (Basically it seemed to just go full blast just by slightly moving the joysticks forward and back.)
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
  #8   Spotlight this post!  
Unread 23-04-2008, 23:43
yongkimleng yongkimleng is offline
deus ex programmeur
AKA: James Yong
FTC #0747
Team Role: Mentor
 
Join Date: Aug 2006
Rookie Year: 2004
Location: Singapore, West
Posts: 134
yongkimleng is a jewel in the roughyongkimleng is a jewel in the roughyongkimleng is a jewel in the rough
Send a message via MSN to yongkimleng
Re: Joystick Input Mapping

I think the lookup table as JimWright949 suggested is the right way to go. You could put the values in an Excel sheet and tweak it until it gives you the graph you want, and then put it back into your code.

As a side note, this would go in before any PID, accel/decel, limiting code you may have.
__________________
| jamesyong.net |
FVC2007, FTC2008
  #9   Spotlight this post!  
Unread 24-04-2008, 10:54
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Joystick Input Mapping

The lookup tables suggested earlier are definitely the way to go.

If you're looking for a quick and dirty method to test things out, you can also try:

Code:
temp_p1_long = (signed long)p1_y - 127;
pwm01 = (unsigned char)(((temp_p1_long * temp_p1_long * temp_p1_long)  >> 14) + 127);

temp_p2_long = (signed long)p2_y - 127;
pwm02 = (unsigned char)(((temp_p2_long * temp_p2_long * temp_p2_long)  >> 14) + 127);
It's a cubic transfer function that we've used since 2004. If it works for you, you're eventually better off calculating the values from the function, and using a look-up table for competition. The long integer operations are a bit wasteful, but it's four quick lines of code for testing!
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
  #10   Spotlight this post!  
Unread 24-04-2008, 21:05
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
FRC #2429 (LCEC)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Re: Joystick Input Mapping

Code:
if (p1_y == 0)
			{
				LEFT_MOTOR = 0;
			}
			if (p1_y == 1)
			{
				LEFT_MOTOR = 1;
			}
			if (p1_y == 2)
			{
				LEFT_MOTOR = 2;
			}
			if (p1_y == 3)
			{
			 	LEFT_MOTOR = 3;
			}
			if (p1_y == 4)
			{
				LEFT_MOTOR = 4;
			}
			if (p1_y == 5)
			{
				LEFT_MOTOR = 5;
			}
			if (p1_y == 6)
			{
				LEFT_MOTOR = 5;
			}
			if (p1_y == 7)
			{
				LEFT_MOTOR = 5;
			}
			if (p1_y == 8)
			{
				LEFT_MOTOR = 5;
			}
			if (p1_y == 9)
			{
				LEFT_MOTOR = 5;
			}
			if (p1_y == 10)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 11)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 12)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 13)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 14)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 15)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 16)
			{
				LEFT_MOTOR = 10;
			}
			if (p1_y == 17)
			{
				LEFT_MOTOR = 20;
			}
			if (p1_y == 18)
			{
				LEFT_MOTOR = 20;
			}
			if (p1_y == 19)
			{
				LEFT_MOTOR = 20;
			}
			if (p1_y == 20)
			{
				LEFT_MOTOR = 20;
			}
			if (p1_y == 21)
			{
				LEFT_MOTOR = 20;
			}
			if (p1_y == 22)
			{
				LEFT_MOTOR = 30;
			}
			if (p1_y == 23)
			{
				LEFT_MOTOR = 30;
			}
			if (p1_y == 25)
			{
				LEFT_MOTOR = 30;
			}
			if (p1_y == 26)
			{
				LEFT_MOTOR = 30;
			}
			if (p1_y == 27)
			{
				LEFT_MOTOR = 40;
			}
			if (p1_y == 28)
			{
				LEFT_MOTOR = 40;
			}
			if (p1_y == 29)
			{
				LEFT_MOTOR = 40;
			}
			if (p1_y == 30)
			{
				LEFT_MOTOR = 40;
			}	
			if (p1_y == 31)
			{
				LEFT_MOTOR = 40;
			}
			if (p1_y == 32)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 33)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 34)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 35)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 36)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 37)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 38)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 39)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 40)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 41)
			{
				LEFT_MOTOR = 50;
			}
			if (p1_y == 42)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 43)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 44)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 45)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 46)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 47)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 48)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 49)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 50)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 51)
			{
				LEFT_MOTOR = 60;
			}
			if (p1_y == 52)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 53)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 54)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 55)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 56)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 57)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 58)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 59)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 60)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 61)
			{
				LEFT_MOTOR = 70;
			}
			if (p1_y == 62)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 63)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 64)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 65)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 66)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 67)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 68)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 69)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 70)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 71)
			{
				LEFT_MOTOR = 85;
			}
			if (p1_y == 72)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 73)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 74)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 75)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 76)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 77)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 78)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 79)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 80)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 81)
			{
				LEFT_MOTOR = 95;
			}
			if (p1_y == 82)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 83)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 84)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 85)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 86)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 87)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 88)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 89)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 90)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 91)
			{
				LEFT_MOTOR = 105;
			}
			if (p1_y == 92)
			{
				LEFT_MOTOR = 110;
			}
			if (p1_y == 93)
			{
				LEFT_MOTOR = 110;
			}
			if (p1_y == 94)
			{
				LEFT_MOTOR = 110;
			}
			if (p1_y == 95)
			{
				LEFT_MOTOR = 110;
			}
			if (p1_y == 96)
			{
				LEFT_MOTOR = 110;
			}
			if (p1_y == 97)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 98)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 99)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 100)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 101)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 102)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 103)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 104)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 105)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 106)
			{
				LEFT_MOTOR = 115;
			}
			if (p1_y == 107)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 108)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 109)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 110)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 111)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 112)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 113)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 114)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 115)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 116)
			{
				LEFT_MOTOR = 120;
			}
			if (p1_y == 117)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 118)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 119)
			{
				LEFT_MOTOR = 127;
			}				
			if (p1_y == 120)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 121)
			{
			LEFT_MOTOR = 127;
			}
			if (p1_y == 122)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 123)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 124)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 125)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 126)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 127)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 128)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 129)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 130)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 131)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 132)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 133)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 134)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 135)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 136)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 137)
			{
				LEFT_MOTOR = 127;
			}
			if (p1_y == 138)
			{
				LEFT_MOTOR = 130;
			}
			if (p1_y == 139)
			{
				LEFT_MOTOR = 130;
			}
			if (p1_y == 140)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 141)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 142)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 143)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 144)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 145)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 146)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 147)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 148)
			{
				LEFT_MOTOR = 135;
			}
			if (p1_y == 149)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 150)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 151)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 152)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 153)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 154)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 155)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 156)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 157)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 158)
			{
				LEFT_MOTOR = 140;
			}
			if (p1_y == 159)
			{
				LEFT_MOTOR = 145;
			}
			if (p1_y == 160)
			{
				LEFT_MOTOR = 145;
			}
			if (p1_y == 161)
			{
				LEFT_MOTOR = 145;
			}
			if (p1_y == 162)
			{
				LEFT_MOTOR = 145;
			}
			if (p1_y == 163)
			{
				LEFT_MOTOR = 145;
			}
			if (p1_y == 164)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 165)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 166)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 167)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 168)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 169)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 170)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 171)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 172)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 173)
			{
				LEFT_MOTOR = 150;
			}
			if (p1_y == 174)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 175)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 176)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 177)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 178)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 179)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 180)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 181)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 182)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 183)
			{
				LEFT_MOTOR = 160;
			}
			if (p1_y == 184)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 185)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 186)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 187)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 188)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 189)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 190)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 191)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 192)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 193)
			{
				LEFT_MOTOR = 170;
			}
			if (p1_y == 194)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 195)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 196)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 197)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 198)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 199)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 200)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 201)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 202)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 203)
			{
				LEFT_MOTOR = 185;
			}
			if (p1_y == 204)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 205)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 206)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 207)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 208)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 209)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 210)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 211)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 212)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 212)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 213)
			{
				LEFT_MOTOR = 195;
			}
			if (p1_y == 214)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 215)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 216)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 217)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 218)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 219)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 220)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 221)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 222)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 223)
			{
				LEFT_MOTOR = 205;
			}
			if (p1_y == 224)
			{
				LEFT_MOTOR = 215;
			}
			if (p1_y == 225)
			{
				LEFT_MOTOR = 215;
			}
			if (p1_y == 226)
			{
				LEFT_MOTOR = 215;
			}
			if (p1_y == 227)
			{
				LEFT_MOTOR = 215;
			}
			if (p1_y == 228)
			{
				LEFT_MOTOR = 215;
			}
			if (p1_y == 229)
			{
				LEFT_MOTOR = 225;
			}
			if (p1_y == 230)
			{
				LEFT_MOTOR = 225;
			}
			if (p1_y == 231)
			{
				LEFT_MOTOR = 225;
			}
			if (p1_y == 232)
			{
				LEFT_MOTOR = 225;
			}
			if (p1_y == 233)
			{
				LEFT_MOTOR = 225;
			}
			if (p1_y == 234)
			{
				LEFT_MOTOR = 235;
			}
			if (p1_y == 235)
			{
				LEFT_MOTOR = 235;
			}
			if (p1_y == 236)
			{
				LEFT_MOTOR = 235;
			}
			if (p1_y == 237)
			{
				LEFT_MOTOR = 235;
			}
			if (p1_y == 238)
			{
				LEFT_MOTOR = 235;
			}
			if (p1_y == 239)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 240)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 241)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 242)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 243)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 244)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 245)
			{
				LEFT_MOTOR = 245;
			}
			if (p1_y == 246)
			{
				LEFT_MOTOR = 250;
			}
			if (p1_y == 247)
			{
				LEFT_MOTOR = 250;
			}
			if (p1_y == 248)
			{
				LEFT_MOTOR = 250;
			}
			if (p1_y == 249)
			{
				LEFT_MOTOR = 250;
			}
			if (p1_y == 250)
			{
				LEFT_MOTOR = 250;
			}
			if (p1_y == 251)
			{
				LEFT_MOTOR = 251;
			}
			if (p1_y == 252)
			{
				LEFT_MOTOR = 252;
			}
			if (p1_y == 253)
			{
				LEFT_MOTOR = 253;
			}
			if (p1_y == 254)
			{
				LEFT_MOTOR = 254;
			}
			if (p1_y == 255)
			{
				LEFT_MOTOR = 255;
			}
So this is what I have as the code, and I also put it for the right motor as well, it sounds to me like putting it on a sheet of paper or on excel, and assigning values will give you the result above in my code. I am not sure, but that's what I am understanding
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
  #11   Spotlight this post!  
Unread 24-04-2008, 21:59
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: Joystick Input Mapping

Um, hmm, well your getting kinda the idea, but we can replace the ifs with something smaller. Here is the code:

Put this code outside of a function (it's a long story why it needs to be outside of a function):

char curve[] = {
0, 1, 2, 4, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10,
20, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
60, 60, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 110, 110, 110, 110, 110, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 120, 120, 120, 120, 120, 120, 120,
120, 120, 120, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 130, 130, 135, 135, 135, 135, 135, 135, 135,
135, 135, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 145, 145, 145,
145, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 185,
185, 185, 185, 185, 185, 185, 185, 185, 185, 195, 195, 195, 195, 195, 195, 195,
195, 195, 195, 195, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 215, 215,
215, 215, 215, 225, 225, 225, 225, 225, 235, 235, 235, 235, 235, 245, 245, 245,
245, 245, 245, 245, 250, 250, 250, 250, 250, 251, 252, 253, 254, 255, 255, 255 };

Now in your function, replace all the if statements with:

LEFT_MOTOR = curve[p1_y];

The right motor will look like this:

RIGHT_MOTOR = curve[p2_y];

This make the p1_y into the index of the table that is in ram. The value of the table at the index p1_y will be put into LEFT_MOTOR.

You may get a linker error about being out of space if you are using MC18. If you do, find your .lkr file and open it up in MPLAB.

Find the section that looks like this:
DATABANK NAME=gpr0 START=0x60 END=0xFF PROTECTED
DATABANK NAME=gpr1 START=0x100 END=0x1FF
DATABANK NAME=gpr2 START=0x200 END=0x2FF
DATABANK NAME=gpr3 START=0x300 END=0x3FF
DATABANK NAME=gpr4 START=0x400 END=0x4FF
DATABANK NAME=gpr5 START=0x500 END=0x5FF
DATABANK NAME=gpr6 START=0x600 END=0x6FF
DATABANK NAME=gpr7 START=0x700 END=0x7FF
DATABANK NAME=gpr8 START=0x800 END=0x8FF
DATABANK NAME=gpr9 START=0x900 END=0x9FF
DATABANK NAME=gpr10 START=0xA00 END=0xAFF
DATABANK NAME=gpr11 START=0xB00 END=0xBFF
DATABANK NAME=gpr12 START=0xC00 END=0xCFF

Delete one of the lines and add 100 to the end of the line above it. Here is mine where I delete grp2 and add 100 to grp1's end tag:
DATABANK NAME=gpr0 START=0x60 END=0xFF PROTECTED
DATABANK NAME=gpr1 START=0x100 END=0x2FF
DATABANK NAME=gpr3 START=0x300 END=0x3FF
DATABANK NAME=gpr4 START=0x400 END=0x4FF
DATABANK NAME=gpr5 START=0x500 END=0x5FF
DATABANK NAME=gpr6 START=0x600 END=0x6FF
DATABANK NAME=gpr7 START=0x700 END=0x7FF
DATABANK NAME=gpr8 START=0x800 END=0x8FF
DATABANK NAME=gpr9 START=0x900 END=0x9FF
DATABANK NAME=gpr10 START=0xA00 END=0xAFF
DATABANK NAME=gpr11 START=0xB00 END=0xBFF
DATABANK NAME=gpr12 START=0xC00 END=0xCFF

Then it should link.

-Jim

Last edited by JimWright949 : 24-04-2008 at 22:18.
  #12   Spotlight this post!  
Unread 24-04-2008, 22:17
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
FRC #2429 (LCEC)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Re: Joystick Input Mapping

Curious, I was never successful in putting this kind of mapping on one controller, and we had an issue where one of the people, our next best driver, had to fill in at nationals, but he was really good wit one control joystick, so how would you map the curve for one joystick, for both motors, is it the same and you just say:
RIGHT_MOTOR = p1_y;
LEFT_MOTOR = p1_y;
then use the curve above? or do you do something different??
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
  #13   Spotlight this post!  
Unread 24-04-2008, 22:30
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: Joystick Input Mapping

Hmm, at this point what I would have you do, is put the robot up on blocks and download the code to it to see what happens. However since I'm not near you, I can't have you do that.

What your code will do is just move the robot forward or backward, there will not be any turning. To turn you can copy some code.

If you are using the FrcCode_2007_8722 code base from the ifi site, find the user_routines.c file, and on line 238 you will find this code:

/*---------- 1 Joystick Drive ----------------------------------------------
*--------------------------------------------------------------------------
* This code mixes the Y and X axis on Port 1 to allow one joystick drive.
* Joystick forward = Robot forward
* Joystick backward = Robot backward
* Joystick right = Robot rotates right
* Joystick left = Robot rotates left
* Connect the right drive motors to PWM13 and/or PWM14 on the RC.
* Connect the left drive motors to PWM15 and/or PWM16 on the RC.
*/
p1_x = 255 - p1_y;
p1_y = 255 - pwm05;

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

This maps one joystick to two motors (really four but two are the same). After these lines add:

pwm13 = curve[pwm13];
pwm14 = curve[pwm14];
pwm15 = curve[pwm15];
pwm16 = curve[pwm16];

That will give you the one joystick drive and the curve that you want.

You will have to add the curve array from my post above to the code, put it somewhere like line 31 which is outside of functions.

-Jim
  #14   Spotlight this post!  
Unread 24-04-2008, 22:37
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
FRC #2429 (LCEC)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Re: Joystick Input Mapping

Okay, well as soon as our robot gets back from Atlanta, and I am aloud to go program on it, I will post up on this thread what happened using the curve way you described to me earlier, ty for all the advice, I have been having real problems with this lately.
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
  #15   Spotlight this post!  
Unread 25-04-2008, 08:41
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Joystick Input Mapping

1075 has always done the floating point operations on the fly in our controller, but our CPU isnt doing much (any, really) difficult math so its no big deal... Though this year we discovered that we had been using the wrong equation for the curve for like 3 years... oops.
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
Joystick Input for Rotation about Z-Axis manderson5192 Control System 5 19-01-2008 18:48
Joystick Input calibration in software LieAfterLie Programming 3 14-02-2007 21:44
issues limiting a joystick input Unholy Programming 7 12-02-2006 19:53
Change joystick to pwm mapping Joe Lewis Programming 3 30-03-2005 19:27
2.5 is alive !!!! (input ! .. more input ! ) Lloyd Burns Programming 2 14-01-2003 19:15


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

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