Go to Post I am a human wiring diagram, how can i help you? - Jeffy [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2011, 21:58
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Can you use a potentiometer to control motor position?

We are driving a Banebot motor with a JAG to move an arm and coding in JAVA. Is it possible to command position of the motor using a potentiometer? We’ve connected the POT to an analog channel, but we’re not sure how to feedback that value to the JAG to control position.
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2011, 22:33
mjbrauck mjbrauck is offline
Registered User
FRC #0768 (Techno Warriors )
 
Join Date: Jan 2006
Rookie Year: 2005
Location: maryland
Posts: 23
mjbrauck has a spectacular aura aboutmjbrauck has a spectacular aura about
Re: Can you use a potentiometer to control motor position?

Sure. but you will need some way of measuring the arm's position ie an encoder or if its rotation is limited another potentiometer on the robots arm wired to a analog input on the CRIO. Then in code you can compare the value of the potentiometer with the position of the arm and figuer out what direction to move. a simple way to do this is to subtract the two potentiometers (desired position - actual position) the result is how far off you are and the sign represtent the direction you need to go.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2011, 22:44
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Re: Can you use a potentiometer to control motor position?

We only planned on having one POT coupled to the gear shaft. I understand the idea of using a pot to identify the position by poling the value returned from the analog channel, but I don't know how to feed that data back to the JAG to control position.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-02-2011, 23:16
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: Can you use a potentiometer to control motor position?

this is psuedocode
this is assuming that the pot gives a value from 0-360 (sorry, but I've nvr used a potentiometer befor, so bear with me)
Code:
if(desiredAngle==pot.getAngle)
//stops motor from moving arm if you're at the angle you need to be at
jag.set(0);
else
/*moves jag forward or backward to get you at the desired angle
does it so fast if far away and slow if close
it will ultimately slow to a stop after it start moving*/
jag.set((desiredAngle-180)/360);
__________________

Last edited by kinganu123 : 06-02-2011 at 23:41.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-02-2011, 23:48
mjbrauck mjbrauck is offline
Registered User
FRC #0768 (Techno Warriors )
 
Join Date: Jan 2006
Rookie Year: 2005
Location: maryland
Posts: 23
mjbrauck has a spectacular aura aboutmjbrauck has a spectacular aura about
Re: Can you use a potentiometer to control motor position?

Ok so it is still the same principle the value of the potentiometer represents the position of the arm and I assume you have some way of inputting the position you want the arm to be at so a simplified proportional control could be

MotorSpeed = (PotentiometerReading - DesiredPosition) *K;
Jag.Set(MotorSpeed);

K is a constant that scales the value you can just play with it till the arm stop at the appropriate position with out much oscillation.

You will also want to
A. constrain the value of MotorSpeed to max and min values of the motor
B. create some margin for error so it does not have to get to the exact value or else it will keep bouncing up and down till something breaks

Last edited by mjbrauck : 06-02-2011 at 23:56.
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2011, 09:01
chadbarbe1 chadbarbe1 is offline
Registered User
AKA: Chad Barbe
FRC #1450 (XQ Robitx)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2006
Location: Rochester, NY
Posts: 8
chadbarbe1 is an unknown quantity at this point
Re: Can you use a potentiometer to control motor position?

In Java you can look into using the PIDController class and start out with the I and D values equal to 0.

NOTE - to do this you'll have to implement a version of PIDInput (i think that's the correct name of the class) that reads from the potentiometer.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2011, 09:39
Alexander Meyer Alexander Meyer is offline
Registered User
FRC #2358 (Bearbotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Lake Zurich, Illinois
Posts: 36
Alexander Meyer is on a distinguished road
Re: Can you use a potentiometer to control motor position?

Quote:
Originally Posted by chadbarbe1 View Post
In Java you can look into using the PIDController class and start out with the I and D values equal to 0.

NOTE - to do this you'll have to implement a version of PIDInput (i think that's the correct name of the class) that reads from the potentiometer.
If I'm not mistaken, AnalogChannel already implements PIDSource.
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2011, 09:44
chadbarbe1 chadbarbe1 is offline
Registered User
AKA: Chad Barbe
FRC #1450 (XQ Robitx)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2006
Location: Rochester, NY
Posts: 8
chadbarbe1 is an unknown quantity at this point
Re: Can you use a potentiometer to control motor position?

Very likely. I didn't have my laptop on me to check :-)
Reply With Quote
Reply


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


All times are GMT -5. The time now is 11:19.

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