Go Down

Topic: joystick using servo motor (Read 2028 times) previous topic - next topic


M using an arduino diecimila to control two servo motors m currently writing a code for the PID to control the motors, but i ran into a problem as the motor is supplied will power m unable to move the motor manually. i need for one motor to be running freely as the other one sits in the centre with a PID applied for the joystick to move forward. is a way of having a servo motor move freely in code but being able to track its position


Unfortunately, with a regular servo, the position sensor is built-in and not accessible from the outside. You might be able to get that information with special digital servos that offer other interfaces (such as I2C) than the normal pulse duration control interface, but not with a regular servo, and not with most digital servos.



Here's a cool example of what you can do if you DO go thru the trouble of accessing that pot's signal, tho:



Oct 26, 2008, 01:58 pm Last Edit: Oct 26, 2008, 01:58 pm by pkm360 Reason: 1
do you know how to control the servo motor position using a PID. can you send a sample code please


I can show you how to read a POT to determine a servo position, or at least know it's position. But, you would only have two options for using it:

1: get rid of the servo's controller.  use it as a standard DC motor, and run the POT leads from the case off to your arduino.  You can use the pot to determine it's position (you'll now have 1024 positions instead of 180).  My code shows how to prevent damaging the pot by stopping well before its rotational end.  This is what my code covers.

2: use a gear-train.  Use a pot as the shaft of a driven gear.  You can now use your servo as it is w/ the normal servo libraries.  Drawbacks = depending on your gearing, you'll get reduced resolution.  For example, your servo is driving a gear, such that the driven gear is 2x larger (2:1 ratio).  This reduces your resolution by half (it takes 2 turns of the servo to make one turn of the driven gear) - you could do 1:2 (half size of servo gear), and increase resolution, but you'll lose torque.

Here's the how-to on it: http://roamingdrone.wordpress.com/2008/07/24/diy-servo-with-arduino-dc-motor-and-potentiometer/

For the proportional, integrative, derivative function - you'll have to come up w/ that yourself.  But, if you know what you intend to achieve, it's not hard at all. Well, assuming you can get your head around the integral part - time to brush up on the ol' calculus =) Start here: http://en.wikipedia.org/wiki/PID_controller


Go Up