Go to Post don't be grumpy. No one is allowed to be grumpy during build. - JaneYoung [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 Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 04-02-2014, 18:03
RamZ's Avatar
RamZ RamZ is offline
Project Manager & Driver
AKA: Ram Zallan
FRC #0004 (Team 4 ELEMENT)
Team Role: Leadership
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Los Angeles
Posts: 127
RamZ will become famous soon enoughRamZ will become famous soon enough
Programming a Potentiometer

My team wants to program a potentiometer to limit how far a mini-CIM is to spin. I can't seem to find any WPILib javadocs on them, or any other resources online.

I need to know how to get the reading from the potentiometer, and know how much to limit the mini-CIM.

Any help, including commands or links would be awesome.

Thanks,
Ram
__________________
Team 4 ELEMENT
Project Manager & Driver
team4element.com facebook twitter instagram


Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2014, 20:07
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Programming a Potentiometer

A potentiometer is just a voltage divider, so at one end of the dial its output is your input voltage (5V probably), and at the other end your output is 0V. Wire this output into your analog module, and use an AnalogChannel and its getAverageVoltage() method to read the output. You should experiment to see what the voltage should be for the limits.
__________________
I code stuff.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2014, 23:22
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Programming a Potentiometer

As Ginto said, you can use an AnalogChannel object to represent your potentiometer but the Java API also has an AnalogPotentiometer class that you can use as well (wpi api link).

When our team uses potentiometers, we tend to correlate the different positions that we are interested in to readings from the potentiometer (e.g. when the arm is in the "up" position, the potentiometer has a reading of x) and then we use a PIDController to get a motor/speed controller to move the mechanism into position. This sounds like what you are talking about but I am not sure.

If you have some more questions, can you give us some specific details on how you are trying to use the potentiometer and what type of potentiometer it is (single-turn-270-degrees or 10-turn or a string potentiometer)? I am assuming that you will be monitoring something other than the output shaft of the mini-cim, like an arm that rotates or an output shaft on a gearbox...but I am sure that more help will come if you can provide a few more details.
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2014, 00:23
RamZ's Avatar
RamZ RamZ is offline
Project Manager & Driver
AKA: Ram Zallan
FRC #0004 (Team 4 ELEMENT)
Team Role: Leadership
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Los Angeles
Posts: 127
RamZ will become famous soon enoughRamZ will become famous soon enough
Re: Programming a Potentiometer

Thanks for the responses!

So, what we'e doing is using the mini-CIM to wind a winch, using a ratchet to make sure it only goes one way. We want to be able to wind the winch to a certain amount, to ready our spring-shooter. So we'll most likely use a PID related code in the end, to have a setpoint that on button push, will wind up to a certain amount (via readings from the pot), then stop.

I'll fill you in on more precise details when I'm at robotics tomorrow afternoon.

Would the only way to get readings to actually test with the pot, or is there some way to show that, x degrees of turning = y voltage?
__________________
Team 4 ELEMENT
Project Manager & Driver
team4element.com facebook twitter instagram


Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2014, 12:00
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Programming a Potentiometer

You can map the values from the potentiometer without testing them, but I would only feel really good about it after verifying the numbers on the pot itself. You can map the values by taking the range of the pot's motion (for a 270 degree pot, this would be 270) and dividing it by the max output power (probably 5 Volts).

270/5 gives you 54 degrees per volt. One end of the pot will read 0 volts and a rotation of 54 degrees should give you a reading of 1 volt. This assumes that it is a linear pot (as opposed to a logarithmic pot).

With the AnalogChannel class, you can get the voltage or the scaled analog value (which is in the range 0 to 1023). The AnalogPotentiometer class gives the voltage by default and has a constructor that allows you to scale the values to more meaningful units.

Sorry if this is scattered...I am doing it between bits of teaching
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2014, 12:17
RamZ's Avatar
RamZ RamZ is offline
Project Manager & Driver
AKA: Ram Zallan
FRC #0004 (Team 4 ELEMENT)
Team Role: Leadership
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Los Angeles
Posts: 127
RamZ will become famous soon enoughRamZ will become famous soon enough
Re: Programming a Potentiometer

Quote:
Originally Posted by mmaunu View Post
You can map the values from the potentiometer without testing them, but I would only feel really good about it after verifying the numbers on the pot itself. You can map the values by taking the range of the pot's motion (for a 270 degree pot, this would be 270) and dividing it by the max output power (probably 5 Volts).

270/5 gives you 54 degrees per volt. One end of the pot will read 0 volts and a rotation of 54 degrees should give you a reading of 1 volt. This assumes that it is a linear pot (as opposed to a logarithmic pot).

With the AnalogChannel class, you can get the voltage or the scaled analog value (which is in the range 0 to 1023). The AnalogPotentiometer class gives the voltage by default and has a constructor that allows you to scale the values to more meaningful units.

Sorry if this is scattered...I am doing it between bits of teaching
Thanks a ton! This actually makes sense to me now

It's my first year programming our robot hands on, so I was a bit confused, but this helped clear it up. I'll be in robotics around 4, so I'll check which type of pot we have then.
__________________
Team 4 ELEMENT
Project Manager & Driver
team4element.com facebook twitter instagram


Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2014, 19:16
RamZ's Avatar
RamZ RamZ is offline
Project Manager & Driver
AKA: Ram Zallan
FRC #0004 (Team 4 ELEMENT)
Team Role: Leadership
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Los Angeles
Posts: 127
RamZ will become famous soon enoughRamZ will become famous soon enough
Re: Programming a Potentiometer

So, ours are 10-turn potentiometers.

Any help on that? Does it work by turn. So x angle = y turns?

Thanks again.
__________________
Team 4 ELEMENT
Project Manager & Driver
team4element.com facebook twitter instagram


Reply With Quote
  #8   Spotlight this post!  
Unread 05-02-2014, 20:22
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Programming a Potentiometer

A 10 turn potentiometer means that it can fully rotate 10 times before hitting its hard stops. If you slowly turn the knob on the potentiometer, it should turn smoothly and easily until you rotate it to the hard stop (either direction). If you then rotate it in the other directions, you should be able to get 10 full rotations before hitting the other hard stop. One of the hard stops corresponds to a signal of 5 volts and the other stop is a signal of 0 volts (don't worry too much about which is which).

10 turns * 360 degrees per turn gives 3600 total degrees of rotation. Divide that by 5 volts and you will get 720 degrees per volt. If you use the AnalogChannel class, the get() method will return a number in the range of 0 to 1023. Dividing 3600 degrees by 1024 values gives you something like 3.6 degrees per value.

When you mount the potentiometer, try to "center" the 10 turns in the center of your range of motion...you don't want to drive the potentiometer against its hard stops (that will break it). This also means that the shaft/arm/thingamajig that you are monitoring should need to rotate more than 10 times in its normal operating mode.

Good luck! I hope to see how it turns out in Las Vegas!
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2014, 21:01
RamZ's Avatar
RamZ RamZ is offline
Project Manager & Driver
AKA: Ram Zallan
FRC #0004 (Team 4 ELEMENT)
Team Role: Leadership
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Los Angeles
Posts: 127
RamZ will become famous soon enoughRamZ will become famous soon enough
Re: Programming a Potentiometer

Quote:
Originally Posted by mmaunu View Post
A 10 turn potentiometer means that it can fully rotate 10 times before hitting its hard stops. If you slowly turn the knob on the potentiometer, it should turn smoothly and easily until you rotate it to the hard stop (either direction). If you then rotate it in the other directions, you should be able to get 10 full rotations before hitting the other hard stop. One of the hard stops corresponds to a signal of 5 volts and the other stop is a signal of 0 volts (don't worry too much about which is which).

10 turns * 360 degrees per turn gives 3600 total degrees of rotation. Divide that by 5 volts and you will get 720 degrees per volt. If you use the AnalogChannel class, the get() method will return a number in the range of 0 to 1023. Dividing 3600 degrees by 1024 values gives you something like 3.6 degrees per value.

When you mount the potentiometer, try to "center" the 10 turns in the center of your range of motion...you don't want to drive the potentiometer against its hard stops (that will break it). This also means that the shaft/arm/thingamajig that you are monitoring should need to rotate more than 10 times in its normal operating mode.

Good luck! I hope to see how it turns out in Las Vegas!
Thanks!
That makes it much easier for our thingamajig to work.
What exactly is the AnalogChannel class?
I clicked that link, and I couldn't figure out what it was used for.

Thanks
__________________
Team 4 ELEMENT
Project Manager & Driver
team4element.com facebook twitter instagram


Reply With Quote
  #10   Spotlight this post!  
Unread 05-02-2014, 21:55
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Programming a Potentiometer

The link from the post above is to the java api (application programming interface). It lists the various ways to construct an object and the methods supported by the class. If you google "java FRC api", you can find many sites with the full api (here).

The AnalogChannel class in particular is, I believe, a class that allows you to gather values from any generic sensor that provides analog input (e.g. a gyro or a potentiometer).
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)

Last edited by mmaunu : 05-02-2014 at 23:45. Reason: Fixed hyperlink.
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 12: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