Go to Post FIRST like life is what you make of it, if you would rather go through FIRST worrying about what other teams do to make their robots, then your destined for disappointment. if you go through FIRST making the most of it doing the best you and your team can then it doesn't matter what other teams do. - Mike Schroeder [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 24-03-2005, 21:14
Joe Lewis Joe Lewis is offline
Registered User
#0992
 
Join Date: Mar 2005
Location: Sherman Oaks, CA
Posts: 2
Joe Lewis is an unknown quantity at this point
Change joystick to pwm mapping

We are trying to program the following scenario and are having a difficult time:

Joystick one - push forward - makes pwm11 go forward
Joystick one - pull back - makes pwm09 go forward
Joystick one - move left - make pwm05 go forward
Joystick one - move right - make pwm07 go foward

Each of the outputs needs to be variable, so the further the joystick is moved, the higher the output to the motors.

Lastly, if the joystick is moved forward, back, left or right off the x/y axis, then a combination of the motors needs to be triggered.

Can we do this, and if so, how? Below is a sample of my code that is not working. The code that I have is just triggering PWM01 to go forward or backward as the joystick is moved on the Y axis.

Thanks much,
Joe

pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;

/* Check if Port 1 Joystick is being pulled back or pushed forward */

if (p1_y <= 125) /* Joystick is being pulled back */
{
Pwm09 = 255 - p1_y; /* turn on motor 5 to go up */
Pwm11 = 127; /* turn off motor 6 */
}
else if (p1_y >= 135) /* Joystick is being pushed down */
{
Pwm11 = p1_y; /* turn on motor 6 to go down*/
Pwm09 = 127; /* turn off motor 5 */
}
else
{ /* In neither forward or reverse position */
Pwm11 = pwm09 = 127; /* Turn off motors 5 and 6 */
}
  #2   Spotlight this post!  
Unread 26-03-2005, 19:47
dm0ney's Avatar
dm0ney dm0ney is offline
Will Code For Food (Food Optional)
AKA: Deepak Mishra
None #0217 (The ThunderChickens)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Shelby Twp., MI
Posts: 48
dm0ney will become famous soon enough
Send a message via AIM to dm0ney
Re: Change joystick to pwm mapping

Default code has p1_y mapped straight to pwm01.
Check Default_Routine, where the pwms are all mapped.
I would tell you that since you are going through and editing the code, comment out or #if 0 the mapping.

Insert the code you have into Default_Routine as well. I'm not sure where you have it currently.

One last thing: the pwms are all lowercase, NOT Pwm

PM me or post more of the code here if you need more help.

Good Luck
__________________

Alumni
Team #217, The ThunderChickens



Student, Class of 2009
California Institute of Technology



Last edited by dm0ney : 27-03-2005 at 11:17.
  #3   Spotlight this post!  
Unread 27-03-2005, 02:49
RbtGal1351's Avatar
RbtGal1351 RbtGal1351 is offline
~La Reina de los Robots~
AKA: Stephanie
FRC #1351 (TKO)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 166
RbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to behold
Send a message via AIM to RbtGal1351 Send a message via MSN to RbtGal1351
Re: Change joystick to pwm mapping

Quote:
Originally Posted by Joe Lewis
We are trying to program the following scenario and are having a difficult time:

Joystick one - push forward - makes pwm11 go forward
Joystick one - pull back - makes pwm09 go forward
Joystick one - move left - make pwm05 go forward
Joystick one - move right - make pwm07 go foward

Each of the outputs needs to be variable, so the further the joystick is moved, the higher the output to the motors.

Lastly, if the joystick is moved forward, back, left or right off the x/y axis, then a combination of the motors needs to be triggered.

Can we do this, and if so, how? Below is a sample of my code that is not working. The code that I have is just triggering PWM01 to go forward or backward as the joystick is moved on the Y axis.

Thanks much,
Joe

pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;

/* Check if Port 1 Joystick is being pulled back or pushed forward */

if (p1_y <= 125) /* Joystick is being pulled back */
{
Pwm09 = 255 - p1_y; /* turn on motor 5 to go up */
Pwm11 = 127; /* turn off motor 6 */
}
else if (p1_y >= 135) /* Joystick is being pushed down */
{
Pwm11 = p1_y; /* turn on motor 6 to go down*/
Pwm09 = 127; /* turn off motor 5 */
}
else
{ /* In neither forward or reverse position */
Pwm11 = pwm09 = 127; /* Turn off motors 5 and 6 */
}
well its probably too late, but its always good to solve the problem anyway

1. if you directly copy/pasted that, its a lowercase "p" for pwm01, etc.
2. you might want a bigger deadzone than that, i normally use 140 and 115
(depending on the joysticks tho, we use the KoP ones and i admit, they suck)
3. you can test the logic in visual c - i do this a LOT and can thus prove it is not directly a SW problem
4. i did that, and the logic works, so its not the obvious problem unfortunately... so sorry, must be something else

Plz tell me what the problem is when you find it, you have me curious
feel free to IM me or something, i can try to help

~Stephanie Schmit
Team 1351
__________________
2004 Founding member and Arm leader, 2005 Lead programmer, 2006 Controls leader, 2007 Project Manager/President
Thanks for making FIRST such a great experience for me. I'm no longer on 1351, and I'm not currently planning to mentor team 97, but FIRST has meant so much in getting me to where I am now, in life and at MIT, class of 2011.
I met Billfred! He recognized me!
SVR 04: 11th seed - Highest Rookie Seed - Semifinalists w/ 1120 and 568 - GM Industrial Design Award
SVR 05: Semifinalists w/ 8 and 766
SVR 06: 6th seed - Quarterfinalists w/ 368 and 1072
Davis 06: 1st seed - Quarterfinalists w/ 649 and 100 - KPCB Entrepreneurship Award
SVR 07: 36th seed
David 07: 4th seed - Semifinalists w/ 1280 and 692 - Johnson and Johnson Sportsmanship Award
  #4   Spotlight this post!  
Unread 30-03-2005, 19:27
Joe Lewis Joe Lewis is offline
Registered User
#0992
 
Join Date: Mar 2005
Location: Sherman Oaks, CA
Posts: 2
Joe Lewis is an unknown quantity at this point
Thumbs up Re: Change joystick to pwm mapping

Stephanie,

My big DUHHHH was the case sensitive "P" - I am sure that is the problem and I knew it was something simple that I forgot. I will be testing the revised program next week (this is not for a competition).

Thanks much,
Joe
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
Compiling Failed Teh Mike Programming 7 09-02-2005 13:27
FYI about using PWM 13-16 with interrupts cabbagekid2 Programming 6 22-01-2005 00:54
pwm outputs vs. joystick y-axis stephenthe1 Programming 4 01-12-2004 17:29
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Changing 1 joystick code to 2 (rookie team) Brawler006 Programming 5 20-02-2004 17:00


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

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