Go to Post [You know you've overdoes on FIRST when...] You're willing to take an 8 AM for the team. - ttldomination [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 17-01-2007, 23:29
brennerator brennerator is offline
Registered User
#1560
 
Join Date: Jan 2005
Location: Silicon Valley
Posts: 75
brennerator is an unknown quantity at this point
Slow down teh motors!

Hi; How would I cap the maximum value of each PWM using 1 joystick configuration?

Basically when I hit the z trigger using the one joystick defualt code I want the controls to be less sensitive.

Thanks!
  #2   Spotlight this post!  
Unread 17-01-2007, 23:37
yongkimleng yongkimleng is offline
deus ex programmeur
AKA: James Yong
FTC #0747
Team Role: Mentor
 
Join Date: Aug 2006
Rookie Year: 2004
Location: Singapore, West
Posts: 134
yongkimleng is a jewel in the roughyongkimleng is a jewel in the roughyongkimleng is a jewel in the rough
Send a message via MSN to yongkimleng
Re: Slow down teh motors!

hint:

#define max_speed 200

if(motor_speed >= max_speed) motor_speed = max_speed;

The above limits the speed of a single direction.
__________________
| jamesyong.net |
FVC2007, FTC2008
  #3   Spotlight this post!  
Unread 18-01-2007, 00:04
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: Slow down teh motors!

I would tack onto that a #define min_speed 55, just so you're backwards movement has the sam limit (notice: the limit is in terms of power given to the motor, not directly its speed. We're working with shaft encoders this year to code in speed.)

-Guy
  #4   Spotlight this post!  
Unread 18-01-2007, 01:13
sciencenerd's Avatar
sciencenerd sciencenerd is offline
ooh, what does this button do?
AKA: Kyle
FRC #1318 (the IRS (Issaquah Robotics Society))
Team Role: Coach
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Bellevue, Washington
Posts: 206
sciencenerd has much to be proud ofsciencenerd has much to be proud ofsciencenerd has much to be proud ofsciencenerd has much to be proud ofsciencenerd has much to be proud ofsciencenerd has much to be proud ofsciencenerd has much to be proud ofsciencenerd has much to be proud of
Re: Slow down teh motors!

Disclaimer: I've never done programming for a FIRST robot, although I have done it for other projects (including other robots) before.

The techniques described above would limit the maximum speed of the robot, but it sounds to me like you want a mode that would decrease the sensitivity of the controls at any range. I would take the PWM signal, subtract 127 (so the range is -127 to 127, not 0 to 255) and multiply that new number by a constant, say .5. I would then add 127 to this new value to get your new PWM signal. The robot will now be half as fast, and half as twitchy.

EDIT: I wasn't thinking/typing clearly.
__________________
Oh, maybe I shouldn't have pushed that...

Last edited by sciencenerd : 18-01-2007 at 21:53.
  #5   Spotlight this post!  
Unread 18-01-2007, 01:26
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: Slow down teh motors!

Quote:
Originally Posted by sciencenerd View Post
Disclaimer: I've never done programming for a FIRST robot, although I have done it for other projects (including other robots) before.

The techniques described above would limit the maximum speed of the robot, but it sounds to me like you want a mode that would decrease the sensitivity of the controls at any range. I would take the PWM signal, subtract 127 (so the range is -127 to 127, not 0 to 255) and multiply that new number by a constant, say .5. I would then add 255 to this new value to get your new PWM signal. The robot will now be half as fast, and half as twitchy.
Shouldn't that be a 127, to bring the scale back to 0-255?
__________________
  #6   Spotlight this post!  
Unread 18-01-2007, 02:05
brennerator brennerator is offline
Registered User
#1560
 
Join Date: Jan 2005
Location: Silicon Valley
Posts: 75
brennerator is an unknown quantity at this point
Re: Slow down teh motors!

Thats exactly what i was doing:
defualt code here

if (ztrigger pressed)
{
pwm13 = (pwm13-127)/2 + 127
pwm14 = (pwm14-127)/2 +127
and so on...

And this did not work. The robot went wild--if the joystick was shifted even slightly after ztrig was pressed robot would fly outta control.
  #7   Spotlight this post!  
Unread 18-01-2007, 07:09
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Slow down teh motors!

Quote:
Originally Posted by brennerator View Post
Thats exactly what i was doing:
defualt code here

if (ztrigger pressed)
{
pwm13 = (pwm13-127)/2 + 127
pwm14 = (pwm14-127)/2 +127
and so on...

And this did not work. The robot went wild--if the joystick was shifted even slightly after ztrig was pressed robot would fly outta control.
You're doing absolutely the right thing. However, that's obviously not the code you actually tried (it won't compile properly without semicolons). Post the exact lines of code and we can see if we can find the problem.
  #8   Spotlight this post!  
Unread 18-01-2007, 10:38
brennerator brennerator is offline
Registered User
#1560
 
Join Date: Jan 2005
Location: Silicon Valley
Posts: 75
brennerator is an unknown quantity at this point
Re: Slow down teh motors!

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

if (p1_sw_trig == 1)
{
pwm13 = (pwm13-127)/2+127;
pwm14 = (pwm14-127)/2+127;
pwm15 = (pwm15-127)/2+127;
pwm16 = (pwm16-127)/2+127;
}
  #9   Spotlight this post!  
Unread 18-01-2007, 10:54
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: Slow down teh motors!

I'd suggest a completely different method of reducing sensitivity, exponential control with a deadband. That way you don't need to have your driver remember to press a switch, as well as not amplifying the area where joystick motion is not translated into robot motion (which dividing does). I made a long post about exponential control and how to implement it here.
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #10   Spotlight this post!  
Unread 18-01-2007, 10:58
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Slow down teh motors!

Give this a try, and let me know if it works. (I don't have a robot handy to test this on.)
Code:
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

if (p1_sw_trig == 1)
{
pwm13 = ((int)pwm13-127)/2+127;
pwm14 = ((int)pwm14-127)/2+127;
pwm15 = ((int)pwm15-127)/2+127;
pwm16 = ((int)pwm16-127)/2+127;
}
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
  #11   Spotlight this post!  
Unread 18-01-2007, 11:51
CircularLogic CircularLogic is offline
Registered User
FRC #1546 (Chaos Inc)
Team Role: Leadership
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baldwin
Posts: 38
CircularLogic will become famous soon enoughCircularLogic will become famous soon enough
Re: Slow down teh motors!

If my memory serves me right, all pwm values are usigned chars (which gives them the 0 - 255) range. If you subract 127 from anything less than 127, it is going to wrap around to 255 because it cant handle negative signs.

If I am right about the pwm variables all being unsigned chars, then your problem is subtracting the 127 from the value. The fix would to be create a temporary integer variable, give it the value of the pwm, do the math, and then reassign it.

int temp13 = pwm13;
int temp14 = pwm14;
int temp15 = pwm15;
int temp16 = pwm16;
if (p1_sw_trig == 1)
{
pwm13 = (temp13-127)/2+127;
pwm14 = (temp14-127)/2+127;
pwm15 = (temp15-127)/2+127;
pwm16 = (temp16-127)/2+127;
}



Also, as posted above, you could just cast it to an int.
__________________
Team 1546 Chaos Incorporated
2005- SBPLI Rookie All Stars
2006- SBPLI Sportsmanship award.

Gotta hand it to the straight line autonomous mode, the most effective defense out there.

Proud beyond belief of the accomplishments of the second year, 20th ranked, 6 wins and 6 losses Chaos Incorporated.
  #12   Spotlight this post!  
Unread 18-01-2007, 12:08
Mr. E Mr. E is offline
Its physics or stamp collecting
FRC #1883
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Las Vegas
Posts: 38
Mr. E is an unknown quantity at this point
Re: Slow down teh motors!

I'm so excited...something I can respond to.

We had the same problem with our robot. I doesn't give you the same variability as the other methods but it let us drive the robot.
Our driver motors are pwm01 and 02. The values that you set them for are the actual speed that you end up going. You are basically partitioning different areas of joystick placement to different output voltages (speed). Be carefull how you order each statement since its an if else if statement and it checks stuff in order that you put it in. You will also notice that the minimum amount of joystick movement before the robot actually moves is 27
going backward and 18 going forward. That way there was a little bit of dead stick in the middle since the sticks were too sensitive at the start. You can add more else if statements to put in more drive speeds. You could make the extreme ends ( 0 and 254) to actually go 0 and 254 (100% forward and backward).


if (p1_y < 50) //back fast
{
pwm01 = 120; //ange these values to the actual speed you want
pwm02 = 120; //"speed" is how far forward and backward you go
}
else if (p1_y < 100) // back slow

{
pwm01 = 123;
pwm02 = 123;
}

else if (p1_y >200) //forward fast
{
pwm01 = 155;
pwm02 = 155;
}

else if (p1_y > 155)//forward slow
{
pwm01 = 145;
pwm02 = 145;
}

else //stop and idle
{
pwm01=127; //left motor
pwm02=127; //right motor
}
  #13   Spotlight this post!  
Unread 18-01-2007, 12:28
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Slow down teh motors!

Joey probably has it right. The pwm values are unsigned char, and it's likely that the compiler isn't accounting for the possibility of underflow when subtracting 127. If your joystick puts out 125, the result wraps around to 254, which gets divided down to 127 and shifted back up to 254 by the final addition. Forward control on the joystick will work okay, but the slightest backward movement will cause the robot to go full speed forward. Using 1-stick control, barely moving the joystick to either side will make it circle madly in the opposite direction.

Adding the cast to (int) will force the compiler to deal properly with the signed values, and everything should be okay.
  #14   Spotlight this post!  
Unread 18-01-2007, 13:09
brennerator brennerator is offline
Registered User
#1560
 
Join Date: Jan 2005
Location: Silicon Valley
Posts: 75
brennerator is an unknown quantity at this point
Re: Slow down teh motors!

MrE: your code will not allow me to make use of all the joystick intervals.

Thanks for the help. Alan, that was exactly what was happening with 1 joystick control. Barely moving the joystick caused the bot to circle wildly.

I shall try this when I get home.
  #15   Spotlight this post!  
Unread 18-01-2007, 13:15
Mr. E Mr. E is offline
Its physics or stamp collecting
FRC #1883
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Las Vegas
Posts: 38
Mr. E is an unknown quantity at this point
Re: Slow down teh motors!

You are right, you loose the variability that the other solutions give, but if you want to use this to drive the robot, the different speeds that the robot goes, it works well. You can always add more speeds to your robot. When we put the code in the robot, it saved our walls from too eager drivers driving too fast. I didn't notice the difference very much when I put the code.
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
Cheapest and easiest way to slow down a motor sanddrag Technical Discussion 41 21-12-2005 07:26
Slowing Down Drive Motors Arc736UV Programming 5 24-01-2005 22:35
How slow is too slow? Joe Ross Rules/Strategy 23 12-10-2004 20:23
Gearing down motors MechaJag Motors 11 17-01-2004 02:27
teh funnah Zeinin Chit-Chat 1 15-04-2002 15:02


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

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