View unanswered posts | View active topics It is currently Sun Nov 23, 2014 12:41 am






Reply to topic  [ 9 posts ] 
Need Help Righting A Program Part, potentiometer ultra sonic 
Author Message
Rookie

Joined: Sun Jul 21, 2013 7:17 pm
Posts: 3
Post Need Help Righting A Program Part, potentiometer ultra sonic
my question is I am trying to right a part in my program were the robot "Vex Claw Bot" will raise and lower its arm depending on how far away my own hand is from the ultra sonic sensor.
so basically if my hand is 2 inches away the arm will raise up so high till a potentiometer would tell it to stop but then i could move my hand back and the arm would move to another spot say lower down.


Sun Jul 21, 2013 7:27 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Need Help Righting A Program Part, potentiometer ultra s
Where are you having trouble exactly? Is it the lowering part? If so, you can use essentially the same code as the first part (raising the arm); just change the value of the potentiometer and the trigger for the ultrasonic sensor.

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Sun Jul 21, 2013 9:50 pm
Profile
Rookie

Joined: Sun Jul 21, 2013 7:17 pm
Posts: 3
Post Re: Need Help Righting A Program Part, potentiometer ultra s
no the problem i'm having is to get the arm a smooth motion like as i get closer the arm moves down and as i get far away the arm moves up. ill i can do right now is say i set it to 5 inches then i can have the moter go till the potetiometer hits a certain point then when my hand hits 4 inches it goes to another i want it all smooth so when i move my hand i don't have to hit a certain number to change it.
please help


Mon Jul 22, 2013 7:31 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Need Help Righting A Program Part, potentiometer ultra s
Ok. So what you need is a while loop, which constantly monitors the ultrasonic sensor, and continually sets the arm. This means you will have to constantly monitor the potentiometer as well. Have some pseudocode:

Code:
const float kDistanceToPower=1;
float distance=0, potentiometer=0, motor_power=0;
while (true)
{
    motor_power = (distance-potentiometer)*kDistanceToPower;
    motor[armMotor] = motor_power;
}


Note that the above is essentially a "P" controller (is that even a thing?) which directly acts upon the measured value.

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Tue Jul 23, 2013 12:07 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Need Help Righting A Program Part, potentiometer ultra s
Ernest3.14 wrote:
Note that the above is essentially a "P" controller (is that even a thing?) which directly acts upon the measured value.

Traditional position PID control doesn't work well for an arm because of gravity. If you really want to do PID control, you need at least two sets of PID constants, one for up and one for down. Even so, it won't be smooth because the arm travels non-linearly (the load is heaviest when parallel to the ground) whereas Proportional (the P in PID) is by definition linear. If you want smooth, you may want to look into velocity PID control instead of position PID control. However, velocity PID control is only good to keep the arm moving smoothly (at constant speed) but it doesn't help when you want to reach a certain position and want to stop gracefully. We experimented with a combination of position PID and velocity PID control. Unfortunately, we didn't have enough time to complete the experiment because the team decided to abandon the arm design and chose the elevator design instead so the problem was no longer relevant. At some point, I would like to get back to investigating the arm design just for the fun of it.


Tue Jul 23, 2013 12:32 am
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Need Help Righting A Program Part, potentiometer ultra s
That's very interesting! Now I'm interested, and might build an arm just to test this. I blame you in advance for hours of frustration and sleep deprivation ;)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Tue Jul 23, 2013 12:41 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Need Help Righting A Program Part, potentiometer ultra s
Ernest3.14 wrote:
That's very interesting! Now I'm interested, and might build an arm just to test this. I blame you in advance for hours of frustration and sleep deprivation ;)

Good luck, would love to learn what progress you make :)


Tue Jul 23, 2013 1:02 am
Profile
Rookie

Joined: Sun Jul 21, 2013 7:17 pm
Posts: 3
Post Re: Need Help Righting A Program Part, potentiometer ultra s
glade i could get you interested if you do diside to make the program please post it on this fourms so i can take a look at it.


Tue Jul 23, 2013 9:36 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Need Help Righting A Program Part, potentiometer ultra s
Sure will! FTC season coming up though... :)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Tue Jul 23, 2013 9:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.