Search the web
Sign In
New User? Sign Up
bestinc · Best Inc.
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Brain Programming, code change servo speed?   Message List  
Reply | Forward Message #560 of 1073 |
Re: Brain Programming, code change servo speed?

--- In bestinc@yahoogroups.com, "nicholas.seward" <nicholas.seward@...> wrote:
>
> --- In bestinc@yahoogroups.com, "tagrimley" <tgrimley@> wrote:
> >
> > A couple comments ...
> > I've not looked at your code but I want to comment about the use of floating
point numbers; you may have noticed that everything in the BEST library was
written using integers - that was not a random/evil choice :) First, the
floating point numbers are going to slow down the update process significantly.
Second, there are inherent resolution issues both in reading the stick position
(which I realize you're not doing) and in setting the servo position (which you
actually set by setting a pulse width).
> > As Joel pointed out with his example of the oscillating piano wire problem,
sometimes the fix to the control issue sits outside the controller (even though
it'd be better to eliminate the problem at the source).
> >
> > Terry
> >
> >
>
> Terry,
> I agree I shouldn't have used floating point numbers. The optimal solution
would probably be to use the full range of int to specify servo positions and
then convert it back to the 0-1023 range at the last minute. Although, you have
to agree my proof of concept would have been obfuscated if I had done a
processor friendly version. Since I didn't have means to debug and I was too
worried about accidental overflow I went with floating point numbers but even so
a better choice would have been to go with a long if I was afraid.
>
> I also agree with you that this is a little overkill. The main problem as I
see it is if you want to have the servo swing from one extreme to another over 2
seconds you would have to increment the servo_positon by 9 each tick. This
would not be nearly as smooth as incrementing by 1 each time but the tick
doesn't change often enough. I am liking the inner loop method without use of a
real time clock more and more.

I (Joel) wrote this typo a couple posts ago:
> "A ~90 degree servo swing for an input of 0-1000 is ~0.9 degree each"

Make that 0.09 degrees each, so moving a servo_position by 9 would be 1 degree
= 1/90th of full swing. These servos probably don't support more accuracy that
1 degree anyway. (Notice I'm now advocating the opposite position as I took
before.)

Regarding obfuscated code: IMHO, The redundancies in both the BEST lib and
Nicholas' code make it harder to read. One of the refactorings that makes my
code short is to move the in>out comparison to the inside.

Regarding teaching emphasis:
- Float emphasizes the concept, and allows for loop time variation.
- Otherwise we can assume, ie take as a constraint that limits other
methodologies, that loop time is short and mostly repeatable.

My next steps:
- The key in -this- programming exercise was to keep a new variable of current
output setting, independent of desired (input) setting.
- Next step is to control the desired settings other than directly from input.
I'm assuming this is what split-stick has to do. I'll want to look at it this
week, or my proto-bot won't have good control of its 7-9 outputs based on just 4
inputs.
- Once we can track time, and current/this/next states, we have the basis for
statemachines.

--Joel








Tue May 26, 2009 6:32 pm

joel.graber1
Offline Offline
Send Email Send Email

Forward
Message #560 of 1073 |
Expand Messages Author Sort by Date

I'd like to have a servo slowly and gracefully change from one position to another, rather than use the existing default "as fast as possible PID". Does anyone...
joel.graber1
Offline Send Email
Apr 28, 2009
8:32 pm

... I placed an example in the files. I haven't been able to test it since we don't have a brain right now. I programmed the servo to have a constant speed...
nicholas.seward
Offline Send Email
Apr 29, 2009
3:12 pm

... Thanks, that was helpful to get me started. I don't anticipate having a long variable loop time, so I think the use of the RealTime clock is overkill for...
joel.graber1
Offline Send Email
May 18, 2009
3:54 am

... This is much simpler. I probably should go through mine and condense it but I thought I would throw you something quick that would work. Just out of...
nicholas.seward
Offline Send Email
May 18, 2009
2:45 pm

... // cc3 is just a counter from 0 .. speed3 short in_3, out_3, cc3, speed3; A ~90 degree servo swing for an input of 0-1000 is ~0.9 degree each. Changing the...
joel.graber1
Offline Send Email
May 20, 2009
2:57 pm

// provide clock ticks at increment: 9/450=> 0.02 sec #define RESET_CLK (9) This is line 41 and 42 of bestusrutil.c. I don't think BEST allows this code to be...
nicholas.seward
Offline Send Email
May 21, 2009
6:17 pm

A couple comments ... You are welcome to change the user libraries at your own risk. Hub personnel and/or BEST cannot support customized libraries. Changing...
tagrimley
Offline Send Email
May 22, 2009
11:34 am

... Terry, I agree I shouldn't have used floating point numbers. The optimal solution would probably be to use the full range of int to specify servo positions...
nicholas.seward
Offline Send Email
May 22, 2009
2:39 pm

... Make that 0.09 degrees each, so moving a servo_position by 9 would be 1 degree = 1/90th of full swing. These servos probably don't support more accuracy...
joel.graber1
Offline Send Email
May 26, 2009
6:32 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help