Go to Post "I don't need an anniversary party. Use the money for the kids on the robotics team."- Walter Suchowiecki, BMS technician - Wayne C. [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, 19:09
JoJo5 JoJo5 is offline
Registered User
no team
 
Join Date: Feb 2007
Location: Long Island
Posts: 4
JoJo5 is an unknown quantity at this point
Code to have speed of motors dependent on how hard you push the joystick

Right now, I just have tank drive-2 motors, 2wheel drive setup, with two joysticks. No matter how far the joystick is pushed forward or backward, the motors turn the same speed. How can I set it up so that when pushed a little, the motor goes a slower speed, than pushing the joystick full throttle?
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2007, 19:25
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: Code to have speed of motors dependent on how hard you push the joystick

The default code turns on the motors at a certain voltage depending on how hard you press the joystick. Maybe your motors have such a high RPM you can't see a difference. Try setting the PWM to a certain value and check the voltage on the Victors and see if they're working right.
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/
  #3   Spotlight this post!  
Unread 04-02-2007, 19:35
JoJo5 JoJo5 is offline
Registered User
no team
 
Join Date: Feb 2007
Location: Long Island
Posts: 4
JoJo5 is an unknown quantity at this point
Re: Code to have speed of motors dependent on how hard you push the joystick

I edited the default code though
  #4   Spotlight this post!  
Unread 04-02-2007, 19:41
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Code to have speed of motors dependent on how hard you push the joystick

I take it from your terminology that you are using easyC. If so, wouldn't this code work--see the attached screenshot...sorry, easyC won't let me copy code out of it...

I don't know much about easyC, so this might not be the right answer.

If you are using MPLAB:

Code:
pwm01 = p1_y;
pwm02 = p2_y
would map joystick 1's y axis to pwm output 1, and joystick 2's y axis to pwm output 2.

Ask if you need more help.

Good luck,
JBot
Attached Thumbnails
Click image for larger version

Name:	easyC tank drive.JPG
Views:	85
Size:	26.8 KB
ID:	5009  
__________________
Aren't signatures a bit outdated?
  #5   Spotlight this post!  
Unread 04-02-2007, 19:43
Salik Syed Salik Syed is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Stanford CA.
Posts: 514
Salik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud of
Send a message via AIM to Salik Syed
Re: Code to have speed of motors dependent on how hard you push the joystick

The joysticks output a value between 0 and 255 based on how far the joystick is pulled back. 0 is full back, 255 is full forward, 127 is neutral.
The speed of the motor is controlled using PWM, all you really need to know is that 0 is full back, 255 full forward, and 127 neutral.
Assuming your motor has fairly linear Power vs. RPM curve you should see a fairly linear response if you just do something like this:
PWM = joystick.
__________________
Team 701
  #6   Spotlight this post!  
Unread 04-02-2007, 19:44
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Code to have speed of motors dependent on how hard you push the joystick

YOu can guarantee it by checking the values of the pwm outputs right before the PutData call at the end of Process_Data_From_Master_uP.

Since the PutData call is (essentially) when the data actually goes out to the robot, if the PWMs are the right value then, then you know that it isn't a code problem.

Are you testing the motors with a load on them? They might spin fast even at low power settings if there is no load.
  #7   Spotlight this post!  
Unread 04-02-2007, 19:44
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: Code to have speed of motors dependent on how hard you push the joystick

What did you edit it to? It should be easy for you to take what you changed and adapt it to match the joystick mapping in the default code.

You can directly map the joystick value to a PWM, as they are both in the 0-255 range with 127 being "neutral" or "off." If you need to reverse the direction of a joystick to match your CIM configuration, you can just subtract the joystick axis from 255, like so:

Code:
pwm01 = p1_y; /* Left drive train maps directly from port 1 y axis to pwm01. */
pwm02 = 255 - p2_y; /* Right drive train does the same, but in reverse. */
To make things smoother (eliminate noise etc) you could use a lookup table to map joystick values.
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
  #8   Spotlight this post!  
Unread 04-02-2007, 20:34
AndrewN's Avatar
AndrewN AndrewN is offline
it's alive!
AKA: Andrew Nicholson
FRC #1778 (Chill Out)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Edmonds, WA
Posts: 48
AndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really nice
Re: Code to have speed of motors dependent on how hard you push the joystick

You are using a victor controller for the motors and not a spike relay, right?
  #9   Spotlight this post!  
Unread 04-02-2007, 21:16
JoJo5 JoJo5 is offline
Registered User
no team
 
Join Date: Feb 2007
Location: Long Island
Posts: 4
JoJo5 is an unknown quantity at this point
Re: Code to have speed of motors dependent on how hard you push the joystick

using a victor
  #10   Spotlight this post!  
Unread 04-02-2007, 22:05
AndrewN's Avatar
AndrewN AndrewN is offline
it's alive!
AKA: Andrew Nicholson
FRC #1778 (Chill Out)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Edmonds, WA
Posts: 48
AndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really nice
Re: Code to have speed of motors dependent on how hard you push the joystick

Good. Doesn't hurt to check for simple problems.

Do the motors immediately start turning when the robot is reset?
Have you tried moving the centering dials beside the stick to center the joystick?
Are the PWM1 LEDS lit when the joystick is centered?
There is no change when you move either joystick? The motors don't reverse at all?
Both joysticks do the same thing?

Can you copy the lines of code where you read one joystick value and then
assign it to the PWM output and post it here (or send it in a private message)?
  #11   Spotlight this post!  
Unread 04-02-2007, 22:16
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Code to have speed of motors dependent on how hard you push the joystick

Fire up the dashboard, connect your PC to the "dashboard" port on the OI, and check the PWM values there. They are changing, correct?

To check center on your joysticks, you can move the jumper just below the dashboard port and check the new screen. Center is 127.

The dashboard viewer is at http://www.ifirobotics.com/dashboard_viewer.shtml. Yes, 2005 is the latest and yes, it will work fine.
  #12   Spotlight this post!  
Unread 05-02-2007, 16:39
AndrewN's Avatar
AndrewN AndrewN is offline
it's alive!
AKA: Andrew Nicholson
FRC #1778 (Chill Out)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Edmonds, WA
Posts: 48
AndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really nice
Re: Code to have speed of motors dependent on how hard you push the joystick

Another simple check: the victor controllers pwm's are connected to the RC pwm 13,14,15 or 16. You can't connect them to PWM 1 thru 12 ... that's from memory ... if you do the victors will pick some speed and never change like you described.
  #13   Spotlight this post!  
Unread 05-02-2007, 16:56
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: Code to have speed of motors dependent on how hard you push the joystick

Quote:
Originally Posted by AndrewN View Post
Another simple check: the victor controllers pwm's are connected to the RC pwm 13,14,15 or 16. You can't connect them to PWM 1 thru 12 ... that's from memory ... if you do the victors will pick some speed and never change like you described.
Umm, I'm pretty sure Victors don't care one way or another what PWM they're on, in fact I don't believe any of our robots use PWMs except 1-12 and they all work fine.
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #14   Spotlight this post!  
Unread 05-02-2007, 17:16
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Code to have speed of motors dependent on how hard you push the joystick

Quote:
Originally Posted by lukevanoort View Post
Umm, I'm pretty sure Victors don't care one way or another what PWM they're on, in fact I don't believe any of our robots use PWMs except 1-12 and they all work fine.
13-16 are different--the user processor must generate the signal, and because of this unless you have a special piece of code in place to generate the signal, these outputs will either be very quirky or not work at all.

JBot
__________________
Aren't signatures a bit outdated?
  #15   Spotlight this post!  
Unread 06-02-2007, 02:26
AndrewN's Avatar
AndrewN AndrewN is offline
it's alive!
AKA: Andrew Nicholson
FRC #1778 (Chill Out)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Edmonds, WA
Posts: 48
AndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really niceAndrewN is just really nice
Re: Code to have speed of motors dependent on how hard you push the joystick

Quite right the victors don't really care what PWM you use. I was working from memory (don't do that .. read the manuals first before posting :-)

However the original FRC code only drives 13-16 without you doing extra coding.

You might also want to look over here: http://www.chiefdelphi.com/forums/sh...ad.php?t=53527
another possible problem.
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
Code to increase speed when joystick is pushed further JoJo5 Programming 3 06-02-2007 07:29
How Many Motors Have You Dropped This Year? littleelectron Motors 5 05-02-2004 16:03
How do you connect the speed controller fans? Iain Electrical 7 31-01-2003 07:05
How do you set a speed limit on the servo Fares Programming 6 01-01-2003 15:04
How fast are you planning to push/pull a goal? Anton Abaya Rules/Strategy 7 12-01-2002 23:33


All times are GMT -5. The time now is 14:21.

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