Go to Post Well, air conditioners when pointed inside the house make it cooler. So I figure if EVERYONE turns their air conditioners on full blast and just point them out the window, we should more or less get rid of this "warming" nonsense. - Mike [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 15-10-2004, 22:17
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Create a low speed drive in programming

Our robots are a little too fast for anyone other than the driver to control. Since we take our robots out for demos and stuff, I being the programmer would want it to be safe. So I have been trying to come up with a program to drive this thing at half speed when the joystick are at full forward. We can't just divide all the values by 2 because that moves the center from 127 to 63.5. Anybody done such a thing, or can come up with a working program for this? I would appreciate any help
Thanks,
-Bharat
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #2   Spotlight this post!  
Unread 15-10-2004, 22:26
George1902's Avatar
George1902 George1902 is offline
It's a SPAM thing...
AKA: George1083; George180
FRC #0180 (SPAM)
Team Role: Mentor
 
Join Date: Dec 2001
Rookie Year: 1998
Location: Stuart, FL
Posts: 784
George1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond reputeGeorge1902 has a reputation beyond repute
Re: Create a low speed drive in programming

Quote:
Originally Posted by Bharat Nain
We can't just divide all the values by 2 because that moves the center from 127 to 63.5.
You can divide by 2 then add 63.5.

[edit]

You might want to tweak that reduction ratio a little, though. For example, you might want to multiply by 2/3 or 3/4 instead of 1/2. Whatever you decide to do, you can recenter your range by adding whatever it takes to get your center back to 127.

So a formula would be:

x1*reduction_ratio + (127-127*reduction_ratio)

And the same for y1
__________________
George

"Darkness cannot drive out darkness; only light can do that. Hate cannot drive out hate; only love can do that."
-- Martin Luther King, Jr.

Last edited by George1902 : 15-10-2004 at 22:34.
  #3   Spotlight this post!  
Unread 15-10-2004, 22:31
Max Lobovsky's Avatar
Max Lobovsky Max Lobovsky is offline
Fold em oval!
FRC #1257 (Parallel Universe)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Scotch Plains, NJ
Posts: 1,026
Max Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant future
Send a message via AIM to Max Lobovsky
Re: Create a low speed drive in programming

Two simple ways that I can think of off the top of my head:

1. convert the speeds to signed values then divide by two:
Code:
int signValue(int value)				
   {
   	return value - 127;
   }
divide by two then:

Code:
int unsignValue(int value)
   {
   	return value + 127;
   }
2. This one allows for some interesting possibilities. An open-filter system.
Code:
char filter[255] = [64,64,65,65,etc,etc];
   motorOutput = filter[joystickInput];
You can simply fill the filter array with [64,196] (middle 50% of speed range) in with a constant slope, or you can experiment with having a curve to, for example, put values near the center closer together to give even greater very low speed control. In fact, you may decided to leave the full range of possible speeds, just make it so the joystick has to be at the far extremes to reach full speed.
__________________
Learn, edit, inspire: The FIRSTwiki.
Team 1257


2005 NYC Regional - 2nd seed, Xerox Creativity Award, Autodesk Visualization Award
2005 Chesapeake Regional - Engineering Inspiration Award
2004 Chesapeake Regional - Rookie Inspiration award
2004 NJ Regional - Team Spirit Award

Last edited by Max Lobovsky : 15-10-2004 at 22:34.
  #4   Spotlight this post!  
Unread 15-10-2004, 23:56
wun's Avatar
wun wun is offline
Registered User
AKA: David Wolever
#0865 (Warp7)
Team Role: Programmer
 
Join Date: Dec 2003
Rookie Year: 2001
Location: Toronto
Posts: 84
wun will become famous soon enough
Send a message via AIM to wun Send a message via MSN to wun
Re: Create a low speed drive in programming

Quote:
Originally Posted by Bharat Nain
Our robots are a little too fast for anyone other than the driver to control. Since we take our robots out for demos and stuff, I being the programmer would want it to be safe. So I have been trying to come up with a program to drive this thing at half speed when the joystick are at full forward. We can't just divide all the values by 2 because that moves the center from 127 to 63.5. Anybody done such a thing, or can come up with a working program for this? I would appreciate any help
Thanks,
-Bharat
Another good way is look up tables. Then you can also set it up so it "ramps" (eg: if you move the joystick 1/2 of the way, it will only bring it up to 1/4 the possible speed, then when you push the joystick all the way, the robot will go up to 1/2 speed (or what have you). The code would look something like this:
Code:
const rom unsigned char mytable[256] = {
     56,56,55,55....
};
I wrote a little python script (which I promptly lost) that would generate them for me. There is also an auto-generator here (but your gonna need M$ excel to open it =\)
__________________
Help Microsoft stop piracy. Use Linux!

I have three gmail invitations, message me if you want one
  #5   Spotlight this post!  
Unread 16-10-2004, 14:52
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Create a low speed drive in programming

Or perhaps have it divide the difference from 127 in half, add/subtract them and send that to PWMs

Like if your joystick is at 250

250 - 127 = 123 / 2 = 61.5 + 127 = 188.5

Code:
int DriveLimiter(int joyvalue)
{
	if(joyvalue > 127)
	{
		return ((joyvalue - 127) / 2) + 127;
	}
	if(joyvalue < 127)
	{
		return 127 - ((127 - joyvalue) / 2);
	}
}
I just did that off top of my head, don't shoot me if it's wrong, but that's the general idea. I think.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #6   Spotlight this post!  
Unread 16-10-2004, 15:06
Max Lobovsky's Avatar
Max Lobovsky Max Lobovsky is offline
Fold em oval!
FRC #1257 (Parallel Universe)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Scotch Plains, NJ
Posts: 1,026
Max Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant future
Send a message via AIM to Max Lobovsky
Re: Create a low speed drive in programming

Just to clarify, my second method is the same as Wun's and my first method is (essentially) the same as Matt's.
__________________
Learn, edit, inspire: The FIRSTwiki.
Team 1257


2005 NYC Regional - 2nd seed, Xerox Creativity Award, Autodesk Visualization Award
2005 Chesapeake Regional - Engineering Inspiration Award
2004 Chesapeake Regional - Rookie Inspiration award
2004 NJ Regional - Team Spirit Award
  #7   Spotlight this post!  
Unread 16-10-2004, 15:30
Unsung FIRST Hero
JVN JVN is offline
@JohnVNeun
AKA: John Vielkind-Neun
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 2000
Location: Greenville, Tx
Posts: 3,159
JVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond reputeJVN has a reputation beyond repute
Re: Create a low speed drive in programming

Quote:
Originally Posted by George1083
You might want to tweak that reduction ratio a little, though. For example, you might want to multiply by 2/3 or 3/4 instead of 1/2.
One year, we had our programmer's make it so the dial on the joystick controlled this scaling factor. This allowed the robot max speed to be dynamically adjusted.

I just do the gearboxes. Any programmers wanna explain how this is possible?

John
__________________
In the interest of full disclosure: I work for VEX Robotics a subsidiary of Innovation First International (IFI) Crown Supplier & Proud Supporter of FIRST
  #8   Spotlight this post!  
Unread 16-10-2004, 17:54
Max Lobovsky's Avatar
Max Lobovsky Max Lobovsky is offline
Fold em oval!
FRC #1257 (Parallel Universe)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Scotch Plains, NJ
Posts: 1,026
Max Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant future
Send a message via AIM to Max Lobovsky
Re: Create a low speed drive in programming

Well I'm not sure what dial you are referring to, but I assume it is a one axis analog input. You could simply multiply the joystick input by a scaling factor (of course after first centering the joystick input around zero by subtracting 127) based on the value of this dial. It would probably be something like this (using the functions from my first example):
Code:
motorOutput = unsignValue(signValue(joystickInput) * (dialInput/255));
That is a pretty cool feature, but I think an open loop filter on the inputs should probably give you enough control without doing that.
__________________
Learn, edit, inspire: The FIRSTwiki.
Team 1257


2005 NYC Regional - 2nd seed, Xerox Creativity Award, Autodesk Visualization Award
2005 Chesapeake Regional - Engineering Inspiration Award
2004 Chesapeake Regional - Rookie Inspiration award
2004 NJ Regional - Team Spirit Award
  #9   Spotlight this post!  
Unread 17-10-2004, 01:09
scitobor 617's Avatar
scitobor 617 scitobor 617 is offline
More nerd than you can handle!
AKA: Alan Meekins
FRC #0617 (HSHS 617 "DUKE")
Team Role: Programmer
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Richmond, VA
Posts: 153
scitobor 617 will become famous soon enoughscitobor 617 will become famous soon enough
Send a message via AIM to scitobor 617
Re: Create a low speed drive in programming

Here's another possible solution.

Code:
motor=y-((y-center)/factor)

So for example:
y=168 center=127 and factor=2

148=168 - (( 168 - 127 ) / 2 )
'y' is the joysticj y-axis, center would be you center value for that joystick(normaly 127) and factor could be changed to scale up or down the output speed.
__________________
Beta testers needed!
http://www.nullagent.no-ip.com

Your kidding, there are other operating systems besides Linux?!
  #10   Spotlight this post!  
Unread 17-10-2004, 12:54
MikeDubreuil's Avatar
MikeDubreuil MikeDubreuil is offline
Carpe diem
FRC #0125 (Nu-Trons)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Boston, MA
Posts: 967
MikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond repute
Send a message via AIM to MikeDubreuil
Re: Create a low speed drive in programming

Quote:
Originally Posted by scitobor 617
Code:
motor=y-((y-center)/factor)

So for example:
y=168 center=127 and factor=2

148=168 - (( 168 - 127 ) / 2 )
This code will not work for joystick values less than 127.
__________________
"FIRST is like bling bling for the brain." - Woodie Flowers
  #11   Spotlight this post!  
Unread 17-10-2004, 12:56
MikeDubreuil's Avatar
MikeDubreuil MikeDubreuil is offline
Carpe diem
FRC #0125 (Nu-Trons)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Boston, MA
Posts: 967
MikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond repute
Send a message via AIM to MikeDubreuil
Re: Create a low speed drive in programming

The wheel that John is talking about was on the old joysticks. It was a thumb wheel located opposite the y axis trim adjustment wheel. The input was analog and reffered to in the code with a variable name similar to "thumb_wheel."

Here's the code to have the thumb wheel control the scaling on a joystick input.

Code:
if (joystick < 127) {
     motor = 127 - ((127 - joystick) * (thumb_wheel/254));
} else if (joystick > 127) {
     motor = 127 + ((joystick - 127) * (thumb_wheel/254));
}
__________________
"FIRST is like bling bling for the brain." - Woodie Flowers
  #12   Spotlight this post!  
Unread 17-10-2004, 20:38
wun's Avatar
wun wun is offline
Registered User
AKA: David Wolever
#0865 (Warp7)
Team Role: Programmer
 
Join Date: Dec 2003
Rookie Year: 2001
Location: Toronto
Posts: 84
wun will become famous soon enough
Send a message via AIM to wun Send a message via MSN to wun
Re: Create a low speed drive in programming

Now, I'm not sure about this, but I know the PIC processor is not very good with things like division. This makes me wonder if it would be faster to generate a lookup table before hand, or if the overhead of the division is so minuscule it will not make any real difference.
__________________
Help Microsoft stop piracy. Use Linux!

I have three gmail invitations, message me if you want one
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's your most important drive train advice? Ken Leung Technical Discussion 42 07-01-2003 09:58
Power, speed, and torque... AGH Gui Cavalcanti Technical Discussion 5 10-11-2002 19:02
Quad- 1/2 track drive system Ben Mitchell Technical Discussion 24 30-01-2002 11:55
"Motors and Drive train edition" of Fresh From the Forum Ken Leung CD Forum Support 6 29-01-2002 12:32
Drivetrain Help Jordan Technical Discussion 16 02-12-2001 12:14


All times are GMT -5. The time now is 06: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