Go to Post They were designed that way so they would be compatible with the water-based ga.... oops, sorry, we aren't supposed to say anything about that. Never mind. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
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 16-01-2002, 19:54
team222badbrad's Avatar
team222badbrad team222badbrad is offline
3D Printing Specialist
AKA: Bradley Rigdon
FRC #0222 (The Tigertrons)
Team Role: Mentor
 
Join Date: Sep 2001
Rookie Year: 2000
Location: Tunkhannock, PA
Posts: 1,091
team222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond repute
Send a message via AIM to team222badbrad
Question switching joystick axis?????

Please tell me if this is possible:

ok lets say my robot is 4 wheel drive and uses on joystick to drive the two motors. Ok now when you push the joystick forward both motors will go forward, and when you turn each motor turns in the opposite direction and so on and so forth. ok so now we have a joystick that operates the drivetrain. Lets say I want to reverse the joystick so that when you push it forward it will accually drive in the other direction. Is it possible to do this with a switch????? In other words I want the robot to have 2 ends. This is because it is sometime difficult to drive the robot backwards with the joystick pulled backwards if yah know what I mean!

Please respond if yah can tell me any information about this!!!!!!! or if you dont understand what i mean!
__________________
Tigertrons are on Facebook!

http://www.printo3d.com

16th FIRST season for me.
  #2   Spotlight this post!  
Unread 16-01-2002, 20:26
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
This is easily done...

Suppose you have a switch called p1_trig.

Suppose that you have 2 variables called Left_wheels and Right_wheels that are bytes that you output to the appropriate PWM channel to make the wheels go round.

Then the following code turns your joysticks around (in a sense) in that what used to make your robot go forward will now make it go backward.

Just Prior to the output statement put:
.
.
.
If p1_trig = 0 then DoNothing
Left_wheels = 254 - (Left_wheels MAX 254)
Right_wheels = 254 - (Right_wheels MAX 254)
DoNothing:
.
.
.

Joe J.

P.S. The MAX 254 takes care of the case when you may have (foolishly) set a PWM value to 255. This may cause trouble for the master CPU if you actual DO set a value of a PWM to 255, but that is only a possibility. It is a certainty that a value of 255 will cause the transformation above to make an error if you don't have the MAX 254 bit. Why? Well, thing about it. 255 probably was intended to make the machine go as fast as possible FORWARD. So, in the transformed case you want the robot to go as fast as possible REARWARD. Now, if you stuff in 255 without the MAX 254 stuff, the value of 255 will yield -1 which using the magic of 16 bit unsigned math will transform to 255 -- so... the robot will go Full FORWARD -- not the drive intended because they intended the machine to be going Full REVERSE. I am not sure I made that very clear but it will have to do for now. JJ.

P.P.S Don't try using this
Left_wheel = 254 - Left_wheel MIN 0
Trust me, this will not yield the desired result. JJ
  #3   Spotlight this post!  
Unread 16-01-2002, 20:30
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
Or you could say "The opposite side of the robot goes the same direction as the joystick",

and fore and aft (joystick) are still the same relative to the robot's fore and aft.
  #4   Spotlight this post!  
Unread 16-01-2002, 20:37
Matt Reiland's Avatar
Matt Reiland Matt Reiland is offline
'The' drive behind the drive
None #0226 (TEC CReW Hammerheads)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1999
Location: Troy Michigan
Posts: 712
Matt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond repute
Great Idea!

We have incorporated that same thing into our robot for this year. The drivers from last year found a few times last year that they rotated around and now stick up caused the robot to be coming to them and the steering was reversed. We put a button on the custom box that says orientation reverse and now the front is the back and it is easier for them to control (so they say). Not much programming but if it helps them drive, well worth it.

Now we have to highlight both ends of the robot to give them an idea of which side is which in relation to the switch. Hmmm

Matt
  #5   Spotlight this post!  
Unread 16-01-2002, 20:41
Joseph F Joseph F is offline
Registered User
#0506 (Steel Friars)
 
Join Date: Jan 2002
Location: New York
Posts: 59
Joseph F is an unknown quantity at this point
Send a message via AIM to Joseph F
i think this works

I just tossed together this program now so it may not work.. one of the veteran teams please check me... From what I understand your looking to push the joystick and have the robot go one way, then flip a switch, push the joystick in the same direction and have the robot reverse course. If this is what you meant then this code should work.. Any questions just leme know, but remember this is untested...

'===============Reversed Drive Program =====================
if backdrive = 0 then frontdrive 'backdrive is switch name
if p1_y < 127 then yback
p1_y = 127 - ((p1_y - 127) Min 0 Max 127) 'p1_y > 127. takes # above 127 and makes it same distance below
goto xtest 'if previous line used ignore next 2
yback
p1_y = 127 + ((127 - p1_y) Min 0 Max 127) 'p1_y < 127. takes # below 127 it makes variable same distance above
xtest
if p1_x < 127 then xback 'now works on x-axis
p1_x = 127 - ((p1_x - 127) Min 0 Max 127) 'same as p1_y above 127, only with x-axis
goto xydone
xback
p1_x = 127 + ((127 - p1_x) Min 0 Max 127) 'same as p1_y below 127, only with x-axis
xydone:
frontdrive
'===========end of reversable drive==continue with tank drive program===========

This assumes the tank drive program is immediately after it. You need to add a variable in the declaring variable sections, it only needs to be 1 bit and i named it backdrive.
When backdrive is not pressed the robot will drive normal. When it is pressed it will first see if p1_y is above or below 127. It will then find the difference between p1_y and 127 and add or subtract it as appropriate. It then does the same using p1_x.
__________________
One Team, One Bot, One Fleet of Ambulances!
  #6   Spotlight this post!  
Unread 16-01-2002, 21:17
team222badbrad's Avatar
team222badbrad team222badbrad is offline
3D Printing Specialist
AKA: Bradley Rigdon
FRC #0222 (The Tigertrons)
Team Role: Mentor
 
Join Date: Sep 2001
Rookie Year: 2000
Location: Tunkhannock, PA
Posts: 1,091
team222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond reputeteam222badbrad has a reputation beyond repute
Send a message via AIM to team222badbrad
Thanks

I will try to talk my programer into testing it! I just wish I had the time to learn how to use STAMP!!! I just came up with this idea because I know how hard it is to drive with the joystick backwards. Will this work so that you can still go backwards on the joystick if you want too?

Bad Brad

P.S thanks for helping me explain what i wanted lol because I just didnt know how to word it right!
__________________
Tigertrons are on Facebook!

http://www.printo3d.com

16th FIRST season for me.
  #7   Spotlight this post!  
Unread 16-01-2002, 22:45
Jnadke Jnadke is offline
Go Badgers!
#0093
Team Role: Alumni
 
Join Date: Jan 2002
Location: Appleton, WI
Posts: 775
Jnadke is on a distinguished road
Send a message via ICQ to Jnadke Send a message via AIM to Jnadke Send a message via Yahoo to Jnadke
Re: This is easily done...

Quote:
Originally posted by Joe Johnson
Suppose you have a switch called p1_trig.

.....
If p1_trig = 0 then DoNothing
Left_wheels = 254 - (Left_wheels MAX 254)
Right_wheels = 254 - (Right_wheels MAX 254)
DoNothing:
....

K.I.S.S.

Left_wheels = ~Left_wheels
Right_wheels = ~Right_wheels


Just a simple inverse of the bits. As long as you do that min and max stuff where it is supposed to be done (in the drive calculations), you should be fine.
  #8   Spotlight this post!  
Unread 16-01-2002, 22:51
Tom Fairchild's Avatar
Tom Fairchild Tom Fairchild is offline
Nice Guy
no team
 
Join Date: Jul 2001
Location: Atlanta, GA
Posts: 308
Tom Fairchild will become famous soon enoughTom Fairchild will become famous soon enough
Send a message via AIM to Tom Fairchild
We used that on our drive system last year. When our team went under the bar, it would actually do it backwards. A simple three position toggle switch is all we needed. Forward is forward, back is backwards, and the center was neutral, which meant that the arm etc. still worked but that drive wheels wouldn't move. That was useful in troubleshooting in case someone bumped into the joystick.

~Tom Faircihld~
  #9   Spotlight this post!  
Unread 16-01-2002, 23:01
Joseph F Joseph F is offline
Registered User
#0506 (Steel Friars)
 
Join Date: Jan 2002
Location: New York
Posts: 59
Joseph F is an unknown quantity at this point
Send a message via AIM to Joseph F
Quote:
If p1_trig = 0 then DoNothing
Left_wheels = 254 - (Left_wheels MAX 254)
Right_wheels = 254 - (Right_wheels MAX 254)
DoNothing:
The above is probably the simplest way to do it. I tend to drag it out more in my program simply because I like to see the thinking process. However you have to then tell it what right_wheel and left_wheel are. I presume there pwm1 and pwm2 as listed in tankdrive. Make sure to put this just after the tankdrive section.

Quote:
Left_wheels = ~Left_wheels
Right_wheels = ~Right_wheels
This may work. I'm not exactly sure about negations in pbasic. It could end up attempting to put in a negative... Use it at your own risk.


The code I put in is untested but shows exactly what it does step by step. Its probably not the best but it should work. Just try them 1 at a time and see which one you like. A standard 2 position switch, a button on the joystick, or even the wheel on the joystick can be used to control which way it drives.

If you have specific questions on the pbasic editor you can post them here or feel free to e-mail me. I taught myself how to use it and the basic program commands in under a week so it shouldn't be that hard to help you if you need.
__________________
One Team, One Bot, One Fleet of Ambulances!
  #10   Spotlight this post!  
Unread 16-01-2002, 23:07
Jnadke Jnadke is offline
Go Badgers!
#0093
Team Role: Alumni
 
Join Date: Jan 2002
Location: Appleton, WI
Posts: 775
Jnadke is on a distinguished road
Send a message via ICQ to Jnadke Send a message via AIM to Jnadke Send a message via Yahoo to Jnadke
Quote:
Originally posted by Joseph F

...
This may work. I'm not exactly sure about negations in pbasic. It could end up attempting to put in a negative... Use it at your own risk.
...
Uhhh.... that's not a negative sign (unary operator). That's a tilde (inverse operator).

Say you have a value of 0 (binary 00000000). The inverse sign inverses all the bits to 255 (11111111). Simplest way of doing it.

Example: 00010100 = ~11101011


Same concept for toggling relays....
Example:
relay_solenoid var bit
relay_solenoid = 0 'solenoid should be deactivated
relay_solenoid = ~relay_solenoid ' toggle the solenoid state

This code is simpler than using if-then statements to check the current state of the bit. All you're doing is altering it.


Suggestion is to read the stamp manual. I did and I learned more than I ever wanted to know about the PBASIC programming language. Just head over to The PBASIC programming manual and check it out. Be careful, it's 2 mb.

Last edited by Jnadke : 16-01-2002 at 23:16.
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
how do i control a piston with a joystick Ryan Foley Programming 2 27-05-2003 17:13
Fried program slots? Jeff Waegelin Programming 18 19-03-2003 18:08
question about one joystick drive programing james700 Programming 13 29-01-2003 14:49
robot goes haywire with the one joystick default code Miles Programming 7 24-01-2003 14:58
joystick problem archiver 2000 12 23-06-2002 23:08


All times are GMT -5. The time now is 05:34.

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