OpenServo.com Forum Index OpenServo.com
Discussion of the OpenServo project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Continuous Rotation soft-mod

 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
robotjay
co-admin


Joined: 01 Aug 2006
Posts: 225
Location: Nebraska, USA

PostPosted: Tue Nov 10, 2009 8:36 am    Post subject: Continuous Rotation soft-mod Reply with quote

Friends,

I have a toy R/C truck that I wanted to convert to a cheap base for a mobile robot. The truck is driven and steered by two DC motors, neither with any form of feedback. I happen to have a small personal stash of OpenServos, and although using an OpenServo for this application is overkill, I still wanted to prove it could be done effectively.

For my first tests, I simply soldered two equal value resistors to the potentiometer connections on the OpenServo, and commanded the OpenServo to an arbitrary position. This had exactly the effect I wanted, and the motor spins happily, with it's speed proportional to the distance from "center." Unfortunately, these resistors are easily broken off, and I knew I would have to modify the actual firmware to make this happen without such a hardware hack.

Turns out, the source code needs very little modification to make this happen. In the config.h file I add the lines:
Code:
// Enable (1) or disable (0) continuous rotation of the servo.  We
// ignore the position feedback value, and force a value into the
// position register.  This seems like a clunky hack, and should be
// cleaned up.  Nonetheless, it's still cleaner than the current
// work-around: soldering matching resistors to the pot-holes.  In
// the future, I'd like to retain the position feedback for those
// applications where the servo is still closed-loop (via encoder) and also
// continuously rotating (such as servos connected to conveyor belts.)
#define CONTINUOUS_ROTATION_ENABLED       1


and in main.c I replace:
Code:
            // Get the new position value.
            position = (int16_t) adc_get_position_value();

with:
Code:
#if CONTINUOUS_ROTATION_ENABLED
         // Force the position reading to the center of its range. 
         // This tricks the pid_position_to_pwm() function into setting
         // a PWM speed proportional to the seek value's distance from
         // the center, effectively giving the servo continuous rotation.
            position = 512;
#else
            // Get the new position value.
            position = (int16_t) adc_get_position_value();
#endif


I'd like to see this merged with the dev branch (after some editing, of course,) but there's a whole lot of undocumented features in the dev branch that may already address this, or may be broken by this. I'd appreciate any of your thoughts. Thanks much. Talk to you soon.

-Jay

EDIT 11/11/2009: This method is deprecated, and replaced by Stefan Engelke's velocity control.
_________________
"Nothing is fool-proof; For we fools are ingenious and will find a way."


Last edited by robotjay on Wed Nov 11, 2009 10:04 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Wed Nov 11, 2009 11:25 am    Post subject: Reply with quote

Hi Jay,

A Nice and simple hack. I'm not sure if this is the right way to fix this issue (see below) but deserved to be documented in the wiki somewhere.

Check out the CVS for the VElocity Controller algorithms.
http://openservo.org/VelocityControl?highlight=%28velocity%29

It works really well and even uses the EMF for good velocity control.

I suppose there could be a compromise and we could recommend the Jay method for the v2 and the velocity controller for the v3.
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
robotjay
co-admin


Joined: 01 Aug 2006
Posts: 225
Location: Nebraska, USA

PostPosted: Wed Nov 11, 2009 9:52 pm    Post subject: Reply with quote

Barry,

Thanks for the links. Stefan's velocity control is exactly what I'm looking for, and is much more elegant than duct-taping resistors to the pot connections. PI+FF? New to me. I need to do some reading, but I'm excited all over again. The excitement of discovery and learning something new is what makes this whole project awesome...

Thanks again. Talk to you soon.

-Jay
_________________
"Nothing is fool-proof; For we fools are ingenious and will find a way."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group