|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
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 ![]() |
|
#2
|
||||
|
||||
|
Re: Programming a Potentiometer
Quote:
![]() 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. |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
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! |
|
#5
|
||||
|
||||
|
Re: Programming a Potentiometer
Quote:
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 |
|
#6
|
||||
|
||||
|
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). Last edited by mmaunu : 05-02-2014 at 23:45. Reason: Fixed hyperlink. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|