Go to Post Because you know what they say, the new year doesn't begin until Dean, Dave, and Woodie drop the big one. - Jay Trzaskos [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 04-02-2003, 00:51
CyberWolf_22's Avatar
CyberWolf_22 CyberWolf_22 is offline
Programming and Electrical Mentor
AKA: Allen Gregory
FRC #2587 (Afrobots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Houston, Texas
Posts: 227
CyberWolf_22 is just really niceCyberWolf_22 is just really niceCyberWolf_22 is just really niceCyberWolf_22 is just really nice
Orientation Switch

I am trying to write a program that when p4_sw_aux1 = 1 the robots orientation changes so that when joy1_y is 254 full reverse and when joy1_y is 0 then full foward same will go for the X axis.
I wish to do this in the single joystick drive code and can not get it to work write. Plz can anyone give me an example of how this might work.
Thanks in advance

CyberWolf_22,
  #2   Spotlight this post!  
Unread 04-02-2003, 01:24
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
My suggestion

Right after these lines:
Code:

drive_R = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000)
drive_L = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)
Insert:
Code:

if p4_sw_aux1 = 1 then
    drive_R = 254 - drive_R
    drive_L = 254 - drive_L
endif
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #3   Spotlight this post!  
Unread 04-02-2003, 01:33
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
If you're really planning on changing the orientation of the robot, forwards to backwards, you also have to swap the values of the PWM outputs, switching left for right, and vice versa, or else you'll be sending signals meant for the left side of the robot to the right, and signals meant for the right to the left.

I did this operation last year, for our roller/claw robot, first by doing what gwross already pointed out, which is inverting the PWM value around 127, then by XORing the values with eachother to swap them, without going through a third temp variable.

Code:
PWM1 = PWM1 ^ PWM2
PWM2 = PWM1 ^ PWM2
PWM1 = PWM1 ^ PWM2
or

Code:
drive_L = drive_L ^ drive_R
drive_R = drive_L ^ drive_R
drive_L = drive_L ^ drive_R
It worked like a dream, and was fun to implement.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #4   Spotlight this post!  
Unread 04-02-2003, 02:12
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
they easy way:

Code:
drive_L              var      byte
drive_R              var      byte
tempjoystick      var      byte


drive_R = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000)
drive_L = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)
'single joystick drive code


if p4_sw_aux1 = 1 then
      tempdrive = drive_R
      drive_R = 254-drive_L
      drive_L = 254-tempjoystick
endif

Works like a charm. I used it last year on our robot.

Basically, you want to do the reverse code AFTER you figure out how fast you want each motor to go (assuming you're doing a 2 motor drivetrain, tank-style). It may not be pretty, or efficient, but it's guaranteed to work.

Not only do you have to reverse the drive speeds, but also you must remember to flip the left and right motor values, or you will find that the x-axis will be backwards.
__________________
The best moments of our lives fall in two categories: those that did happen and those that did not.

Last edited by Jnadke : 04-02-2003 at 02:14.
  #5   Spotlight this post!  
Unread 04-02-2003, 07:47
rust710's Avatar
rust710 rust710 is offline
Registered User
#0862 (Lightning Robotics)
 
Join Date: Dec 2002
Location: Canton, MI
Posts: 103
rust710 is an unknown quantity at this point
Send a message via AIM to rust710
Quote:
Originally posted by Jnadke
they easy way:

Code:
drive_L              var      byte
drive_R              var      byte
tempjoystick      var      byte


drive_R = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000)
drive_L = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)
'single joystick drive code


if p4_sw_aux1 = 1 then
      tempdrive = drive_R
      drive_R = 254-drive_L
      drive_L = 254-tempjoystick
endif
Your code is correct except for what is bolded. You are using two different Variables. Probably just an error when you typed it. Your code is similar to what I use on our robot.
__________________
Andrew Radamis
Programmer on 862
info@lightingrobotics.com
  #6   Spotlight this post!  
Unread 04-02-2003, 09:38
Jferrante Jferrante is offline
Registered User
#0506
 
Join Date: Aug 2002
Location: New York
Posts: 67
Jferrante is an unknown quantity at this point
Send a message via AIM to Jferrante Send a message via Yahoo to Jferrante
another way

drive_L = ((((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000) * (1 - p1_sw_trig)) + (~(((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000) * p1_sw_trig)
drive_R = ((((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000) * (1 - p1_sw_trig)) + (~(((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000) * p1_sw_trig)

If you want to avoid extra lines and extra variables you can do it this way. Its a bit long but we used it last year and it worked great.
__________________
GodBless America
September 11, 2001... NEVER FORGET!
All Gave Some. Some Gave All. How much are you willing to give?
FDNYPD
  #7   Spotlight this post!  
Unread 04-02-2003, 10:42
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Quote:
Originally posted by FotoPlasma
you also have to swap the values of the PWM outputs, switching left for right, and vice versa
Thanks. I just remembered about that this morning. You saved me having to post it.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
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
spike for pressure switch? Rob Colatutto Rules/Strategy 4 23-02-2003 15:42
Using a switch before autonomous operation KZos550 Programming 11 04-02-2003 19:12
NEED HELP with Delay loop for compressor relay switch archiver 2001 10 24-06-2002 02:11
1 or 2 phase switch archiver 2001 0 24-06-2002 00:48
Error found in programming for the pump and pressure switch sjharobotics Programming 4 06-02-2002 17:46


All times are GMT -5. The time now is 13:29.

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