Go to Post It's far easier to find ambiguity in the rules than to write them. - MikeE [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-2007, 15:20
Xenosthebest Xenosthebest is offline
Registered User
FRC #0701
 
Join Date: Feb 2007
Location: Travis AFB
Posts: 14
Xenosthebest is an unknown quantity at this point
Constants

I keep trying to write this code to help tune my joystick driving, but it keeps telling me to make a constant. I know what they are, but how would i write a constant when i want something to be more than or less than 127? for example: is it this <= or this =<? this >= or this =>?

please help me...
  #2   Spotlight this post!  
Unread 04-02-2007, 15:30
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Constants

Quote:
Originally Posted by Xenosthebest View Post
I keep trying to write this code to help tune my joystick driving, but it keeps telling me to make a constant. I know what they are, but how would i write a constant when i want something to be more than or less than 127? for example: is it this <= or this =<? this >= or this =>?

please help me...
Post a snippet of your actual code generating the error, or
what your desired algorithm is in pseudo code, and we will
have a chance of helping you out.
  #3   Spotlight this post!  
Unread 04-02-2007, 15:49
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Constants

Quote:
Originally Posted by Xenosthebest View Post
...i want something to be more than or less than 127? for example: is it this <= or this =<? this >= or this =>?...
The answer you seek can be found on slide #5 of module C, part 2 located on this page.
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #4   Spotlight this post!  
Unread 04-02-2007, 16:20
Xenosthebest Xenosthebest is offline
Registered User
FRC #0701
 
Join Date: Feb 2007
Location: Travis AFB
Posts: 14
Xenosthebest is an unknown quantity at this point
Re: Constants

my bad, this is the code to drive forward or backward with sensitivity in the joystick.

#if 1

if (joystick_y < 127)
{
drive_left and drive_right < 127;
drive_left = drive_right;
}
else if (joystick_y > 127)
{
drive_left and drive_right > 127;
drive_left = drive_right;
}
else joystick_y == 127;

Before this, the joystick would only read something if it went ONLY full forward or full backward. I want to make it so we could move it slighty when we want it to move only a little and not alot.
  #5   Spotlight this post!  
Unread 04-02-2007, 17:35
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 357
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Wink Re: Constants

To move the motors "a little" (proportionally) to a joystick. Just assign the joystick value to the motor drive value. 0 is full reverse, 127 is neutral and 255 is full forward.
There are some lines in the default code:
pwm01 = p1_y;
pwm02 = p2_y;

This uses two joysticks to control two motors.

Now, you may want to widen the "neutral some so that the joysticks don't have to be perfectly centered for the motor to be off. Something like:
if (p1_y < 120 || p1_y > 134)
pwm01 = p1_y;
else
pwm01 = 127; // neutral

The statement:
drive_left and drive_right < 127
doesn't DO anything. Its just a comparison.
__________________
Brian K
Team 1225 Robotics Mentor
  #6   Spotlight this post!  
Unread 04-02-2007, 21:08
Tureyhall Tureyhall is offline
Registered User
AKA: Thomas Hall
FRC #0668 (Apes Of Wrath)
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2004
Location: San Jose
Posts: 40
Tureyhall will become famous soon enoughTureyhall will become famous soon enough
Re: Constants

Quote:
Originally Posted by Xenosthebest View Post
else joystick_y == 127;
I don't know what you're trying to do with this line, but it won't work.

Quote:
Originally Posted by Xenosthebest View Post
Before this, the joystick would only read something if it went ONLY full forward or full backward. I want to make it so we could move it slighty when we want it to move only a little and not alot.
You sure you're using a speed controller and not a spike?
__________________
/*Nerd Camouflage*/

2005 SVR - 668+1072+840 - Semifinalists.
2006 SVR - 668+1280+1693 - Finalists.
2007 SVR - 668+604+624 - Quarter-finalists, Xerox Creativity Award, two highest scores (290-2, 128-0) at SVR.
2007 Nat's - TBA.
  #7   Spotlight this post!  
Unread 05-02-2007, 18:30
Xenosthebest Xenosthebest is offline
Registered User
FRC #0701
 
Join Date: Feb 2007
Location: Travis AFB
Posts: 14
Xenosthebest is an unknown quantity at this point
Re: Constants

im trying to make the code work so that if the joystick goes, say, forward a little bit, the code will move closer to 255 only a little bit, say up to 145 or something like that. Same way backward, and if neither of those then the robot will be neutral and not move at all. The purpose is because we don't want to break the transmissions because it stops too hard when it goes full forward, so we would change the sensitivity of the joystick to slow down to neutral rather than go straight from 255 to 127. You get what im saying?
  #8   Spotlight this post!  
Unread 05-02-2007, 19:45
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: Constants

Sounds like you are trying to do THIS
  #9   Spotlight this post!  
Unread 06-02-2007, 13:50
purduephotog purduephotog is offline
Active Defense Design Engineer
AKA: Jason
FRC #3015
Team Role: Leadership
 
Join Date: Jan 2007
Rookie Year: 2004
Location: Rochester, NY
Posts: 162
purduephotog is a jewel in the roughpurduephotog is a jewel in the roughpurduephotog is a jewel in the roughpurduephotog is a jewel in the rough
Send a message via AIM to purduephotog
Re: Constants

Quote:
Originally Posted by Xenosthebest View Post
im trying to make the code work so that if the joystick goes, say, forward a little bit, the code will move closer to 255 only a little bit, say up to 145 or something like that. Same way backward, and if neither of those then the robot will be neutral and not move at all. The purpose is because we don't want to break the transmissions because it stops too hard when it goes full forward, so we would change the sensitivity of the joystick to slow down to neutral rather than go straight from 255 to 127. You get what im saying?
Ahhh, the beauty of a PID controller. I wish I had a way to demonstrate it without the UI, because that's about what you're wishing to do, minus the driving aspect.

The problem is your drivers. They are thinking like a race car game and not a real-car game. You don't slow your vehicle down by slamming the car into reverse, you slow it down by applying the brakes. Of course, I don't know what the wear/tear is on the gearbox by hitting it to neutral and whether or not that is a 'locked' neutral or a free neutral, but...

If you have encoders on the wheels you could 'refuse' to allow the robot's PWM to be reduced to below 127 so long as there has been an increase in the count of the encoder in the last 26.2 ms loop.

Regardless as to what you decide to do I would suggest having an 'override' for the system- one that allows your driver to go full power for any task, just in case (Say) time is running out and you've just GOT to get there.

Just an idea.
  #10   Spotlight this post!  
Unread 07-02-2007, 17:31
Xenosthebest Xenosthebest is offline
Registered User
FRC #0701
 
Join Date: Feb 2007
Location: Travis AFB
Posts: 14
Xenosthebest is an unknown quantity at this point
Re: Constants

Thank you for the helping codes, it is greatly appreciated! Robot moves nice n smooth.
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
What constants are u using for high velocity PID Salik Syed Programming 3 18-02-2006 23:22
realistic friction constants. Rickertsen2 Motors 11 18-10-2005 00:25
Tweaking constants: any good way? wun Programming 5 08-04-2004 10:44
Global Constants Ryan Cumings Programming 17 08-02-2004 19:05


All times are GMT -5. The time now is 10:43.

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