Go to Post The Bus includes Free Wifi and 120v Power (the bare essentials for any robotics team member) - Clinton Bolinger [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 Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 07-02-2007, 13:59
WGRAY WGRAY is offline
Registered User
FRC #2027
 
Join Date: Jan 2007
Location: westbury
Posts: 22
WGRAY is an unknown quantity at this point
Controlling motor speed

I would like to control the speed of motors so that my arm motors spin slowly, ie when I use my joystick to control my arm and push it full throttle, it would return a quarter throttle response. If you could step by step instruct in easycpro, I am a newbie rookie.
  #2   Spotlight this post!  
Unread 07-02-2007, 14:09
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: Controlling motor speed

Quote:
Originally Posted by WGRAY View Post
I would like to control the speed of motors so that my arm motors spin slowly, ie when I use my joystick to control my arm and push it full throttle, it would return a quarter throttle response. If you could step by step instruct in easycpro, I am a newbie rookie.
I can't help you with easyC but can explain the basics...

A PWM is defined to be:

255 - Full Forward
127 - Stop
0 - Full Reverse

Let's assume that your PWM is #1 and you are using the Y axis of the Joystick installed into Port 1 to control it. Your C code would look like this:

pwm01 = (unsigned char) ((((int) p1_y - 127) / 4) + 127);

(int) and (unsigned char) are compiler directives called a cast. (int) tells the compiler to transform the unsigned char, p1_y, to a signed integer. (unsigned char) transforms it back.

Note that there are many ways to skin a cat, all of which are intensely undesirable to the cat...

Regards,

Mike
__________________
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...
  #3   Spotlight this post!  
Unread 07-02-2007, 22:25
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Controlling motor speed

You should use the online window to determine the speed you want your arm to move at and then using a formula like Mike posted make that your maximum.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #4   Spotlight this post!  
Unread 07-02-2007, 23:01
WGRAY WGRAY is offline
Registered User
FRC #2027
 
Join Date: Jan 2007
Location: westbury
Posts: 22
WGRAY is an unknown quantity at this point
Re: Controlling motor speed

I understand the formula however I do not have anything in my c window that resembles his format "pwm01 = (unsigned char) ((((int) p1_y - 127) / 4) + 127); otherwise I would replace my code with his. What steps in easycpro would I use to generate code in that format?http://www.chiefdelphi.com/forums/im...es/redface.gif
  #5   Spotlight this post!  
Unread 08-02-2007, 07:04
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Controlling motor speed

Here is the easiest way to do this in easyC.

Code:
      int Arm_Joystick; 
      unsigned char Arm_Output; 

      while ( 1 )
      {
            Arm_Joystick = GetOIAInput ( 2 , 2 ) ; // Analog OI Input Block
            Arm_Output = ((( Arm_Joystick - 127 ) / 4) + 127 ) ; // User Code Block
            SetPWM ( 4 , Arm_Output ) ; // PWM Control Block
      }
Here is a more advanced way to do this in easyC Pro

Code:
while (1)
  {
         SetPWM ( 5 , ((( GetOIAInput(2,2) - 127) / 4) +127 ) ) ;
  }
Oh, and when you put a smiley in your post all you have to do is click on the smile you want once and the forum software
automagicly loads the image.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 08-02-2007 at 07:08.
  #6   Spotlight this post!  
Unread 08-02-2007, 11:01
WGRAY WGRAY is offline
Registered User
FRC #2027
 
Join Date: Jan 2007
Location: westbury
Posts: 22
WGRAY is an unknown quantity at this point
Re: Controlling motor speed

Thanks
With a little tweaking your more advanced code worked perfectly!
  #7   Spotlight this post!  
Unread 08-02-2007, 13:54
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Controlling motor speed

Variables are overrated
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #8   Spotlight this post!  
Unread 11-02-2009, 18:23
Drake Hunter's Avatar
Drake Hunter Drake Hunter is offline
Fighting Rednecks
FRC #2883 (F.R.E.D)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Warroad, MN
Posts: 15
Drake Hunter is an unknown quantity at this point
Re: Controlling motor speed

Can anyone help me in labview?
  #9   Spotlight this post!  
Unread 12-02-2009, 21:29
dboisvert dboisvert is offline
Registered User
AKA: Dan Boisvert
FRC #2405 (Divided by Zero)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Michigan
Posts: 57
dboisvert is an unknown quantity at this point
Re: Controlling motor speed

This isnt the proper area to ask a labview question. I would suggest going under Programming > Labview
  #10   Spotlight this post!  
Unread 16-02-2009, 22:50
Drake Hunter's Avatar
Drake Hunter Drake Hunter is offline
Fighting Rednecks
FRC #2883 (F.R.E.D)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Warroad, MN
Posts: 15
Drake Hunter is an unknown quantity at this point
Re: Controlling motor speed

Quote:
Originally Posted by dboisvert View Post
This isnt the proper area to ask a labview question. I would suggest going under Programming > Labview
no kidding....but i needed help so i figured i would ask
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
Motor speed HellBoy Programming 2 05-02-2007 10:41
Multi-Speed motor Questions Burg Robotics Education and Curriculum 2 23-12-2004 15:54
Multi Speed Dual Motor Gearbox tenfour General Forum 14 08-09-2003 13:09
Drill Motor Speed Difference Mark Jones Motors 2 14-02-2003 15:23
Drill motor true speed? archiver 2001 0 23-06-2002 23:58


All times are GMT -5. The time now is 08:38.

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