|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Potentiometer arm control
Hello again. I've finally got pots mounted on my arm but I need a little help adapting them to my code. The arm has two pivot points, with a potentiometer mounted at each. The goal of my program is to make the motors move to keep the arm level until it's above the overpass at which point I'll press a button and have the ball get "flipped" over. I'm sort of stuck, and if someone could give me a hint on how to achieve this then that would be great.
Here's a picture of what's happening: |
|
#2
|
||||
|
||||
|
Re: Potentiometer arm control
You understand how to make a joint seek to a certain position, yes? The next step would be to find a list of pairs of joint values between (350,900) and (600,350), maybe 20 or 30 clicks apart, all of which keep the ball level. Then instead of going directly to the target, you instead target each intermediate point until you reach your goal. I'm having a little bit of trouble putting this into words... does it make sense?
|
|
#3
|
||||
|
||||
|
Re: Potentiometer arm control
Yes, I understand what you're saying, but is there a way to put these numbers into a function to tell me what the wrist position should be at any given arm position? I would rather not program 30 different positions if I didn't have to...
|
|
#4
|
||||
|
||||
|
Re: Potentiometer arm control
Remember Algebra I? Use that to make an equation that will work. It's just like x and y components. Hopefully that helps. (Find the slope using (y2-y1)/(x2-x1), then use y1 = m(x1) + b) That should get you setup. At least, I think that should work.
EDIT: Since I really love math, I had to figure it out myself to be content . Wrist Position = (-11/5)Arm Position + 1670 Last edited by RyanN : 16-02-2008 at 00:13. |
|
#5
|
||||
|
||||
|
Re: Potentiometer arm control
I'm pretty confident that a linear approximation should do nicely... in terms of real angles (not pot values), you're trying to make it so that theta1+theta2 is always constant. How does this look?
Code:
int wristPos(int elbow)
{
return elbow*(350-900)/(600-350)+1670;
}
Last edited by jgannon : 16-02-2008 at 00:13. |
|
#6
|
||||
|
||||
|
Re: Potentiometer arm control
And now y is the number I'm seeking, correct?
|
|
#7
|
||||
|
||||
|
Re: Potentiometer arm control
Pretty much
Code:
wrist_pos = (-11/5)*arm_pos + 1670; |
|
#8
|
||||
|
||||
|
Re: Potentiometer arm control
Quote:
Code:
wrist_pos = -11*arm_pos/5 + 1670; |
|
#9
|
||||
|
||||
|
Re: Potentiometer arm control
It will not try to use floating point or just use that fraction and multiply it? I thought that would work.
|
|
#10
|
||||
|
||||
|
Re: Potentiometer arm control
-11 and 5 are both integers, so it will do integer division. It might work if you explicitly made one of them a float (i.e. -11.0), but floating point is a mess on these controllers, so my integer solution is a pretty reasonable approach.
|
|
#11
|
||||
|
||||
|
Re: Potentiometer arm control
All right, I'll also keep that in mind in the future.
|
|
#12
|
||||
|
||||
|
Re: Potentiometer arm control
Quote:
What was shown will work, but you might even get a little better precision by doing... wrist_pos = (-11*arm_pos + 1670*5) / 5; This maximizes the numerator before dividing by the denominator. |
|
#13
|
||||
|
||||
|
Re: Potentiometer arm control
Can you explain how that would work? I'm reasonably confident that you would get exactly the same result for any given value of arm_pos (discounting any overflow issues).
|
|
#14
|
||||
|
||||
|
Re: Potentiometer arm control
Quote:
Using ArmPosition = 501, here's what you'd get with all 3 methods: First Method: wrist_pos = -11/5*arm_pos + 1670 = (-2)*501+1670 = 668 2nd method: wrist_pos = -11*arm_pos/5 + 1670 = (-5511)/5 + 1670 = -1102+1670=568 3rd method: wrist_pos = (-11*arm_pos + 1670*5 )/ 5 = 2850/5 = 567.8 = 567 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mounting an arm potentiometer | Hazmatt | Technical Discussion | 18 | 12-02-2008 21:53 |
| P.I.D. Control for the arm | skibum2490 | Programming | 8 | 27-02-2007 11:21 |
| Slave Control Arm | aaronD341 | Control System | 1 | 26-04-2005 17:13 |
| 2-Segment Arm Control | Orborde | Programming | 1 | 20-01-2005 01:40 |
| Neural Control of Robot Arm | Leo M | Math and Science | 2 | 29-03-2004 13:46 |