View unanswered posts | View active topics It is currently Sun Dec 21, 2014 11:53 am






Reply to topic  [ 4 posts ] 
Servo Help 
Author Message
Rookie

Joined: Mon Dec 21, 2009 1:57 pm
Posts: 1
Post Servo Help
I was wondering if it is possible to program the servos so that if you press a button, the servo will move at one direction and when you let go of that button, the servo will stop moving and remain in its current position. If anyone has programmed this please show me a sample. Thank you in advance.
:poke:


Mon Dec 21, 2009 2:06 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: Servo Help
Paranoid486 wrote:
I was wondering if it is possible to program the servos so that if you press a button, the servo will move at one direction and when you let go of that button, the servo will stop moving and remain in its current position. If anyone has programmed this please show me a sample. Thank you in advance.
:poke:


I have seen a couple of approaches to this. Most involve setting the servo target to the servo value +/- a predefined step if a certain button is pressed. The general gotcha is that unless there is some sort of mutex and/or wait, the holding down a button for a fraction of a second can result in the target being set to a min/max value as the statement is executed rapidly inside the control loop. Remember that the servo's value is actually just the previously set target... not the actual/physical position (which it takes time to reach).

One design which just came to mind when I read your post was to create a new task whose sole responsibility is the control of the servo in question you wish to control this way. The task would check the buttons (I imagine you'd want two; one for each direction), if pressed check for min/max constraints, increment/decrement the servo, then sleep (via a wait statement) for a time long enough to allow the servo to physically move the distance the target was changed by.


Mon Dec 21, 2009 2:55 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post Re: Servo Help
It is not possible to read the current value of the servo. All that is known is the value that you've told it to move to. So, in general, you can't do your original request.

Consider the case of the servo being at position 0. And you hold the button in long enough that the servo is told to move to position 255. But it may only be partially through this move. Suppose it is only now at position 150. If you wanted to stop the servo at the current position you'd have to know that it currently is at position 150 and then tell it to move to 150. But there is no way to interrogate the servo hardware to tell how far it has progressed towards the initial target of 255.

Sorry.


Tue Dec 22, 2009 12:16 pm
Profile
Rookie

Joined: Thu Nov 06, 2008 4:35 pm
Posts: 12
Post Re: Servo Help
Cant you put a motor encoder on the servo axle and if the motor encoder reeds a steady rate at the wrong degrees you know you hit something...

_________________
Palm Harbor University High School, Robotics team Pandara #506


Sun Jan 31, 2010 7:15 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.