ROBOTC.net forums
http://robotc.net/forums/

Need Help Righting A Program Part, potentiometer ultra sonic
http://robotc.net/forums/viewtopic.php?f=15&t=6335
Page 1 of 1

Author:  TheBradyBox [ Sun Jul 21, 2013 7:27 pm ]
Post subject:  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.

Author:  Ernest3.14 [ Sun Jul 21, 2013 9:50 pm ]
Post subject:  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.

Author:  TheBradyBox [ Mon Jul 22, 2013 7:31 pm ]
Post subject:  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

Author:  Ernest3.14 [ Tue Jul 23, 2013 12:07 am ]
Post subject:  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.

Author:  MHTS [ Tue Jul 23, 2013 12:32 am ]
Post subject:  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.

Author:  Ernest3.14 [ Tue Jul 23, 2013 12:41 am ]
Post subject:  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 ;)

Author:  MHTS [ Tue Jul 23, 2013 1:02 am ]
Post subject:  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 :)

Author:  TheBradyBox [ Tue Jul 23, 2013 9:36 pm ]
Post subject:  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.

Author:  Ernest3.14 [ Tue Jul 23, 2013 9:49 pm ]
Post subject:  Re: Need Help Righting A Program Part, potentiometer ultra s

Sure will! FTC season coming up though... :)

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/