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...
Message search is now enhanced, find messages faster. Take it for a spin.

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 #559 of 1070 |
Re: Brain Programming, code change servo speed?

--- In bestinc@yahoogroups.com, "tagrimley" <tgrimley@...> wrote:
>
> 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 the define to a lower
number will result in a smaller time per tick increment, however, you'll have to
check to see if it causes other problems with the additional interrupt service
time.
>
> 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). I'll look back through the code (since
I don't remember off the top of my head) but I think you are likely trying to
achieve resolution that is beyond what will actually be set and output to the
servo via the control proc.
>
> 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.

BTW, I use the method getInputs() in my code to gather all the brain inputs
(including stick position) and write their values to global variables. This is
overkill but it makes it so much easier for high school students to work with
the code without the BRAIN wizard.





Fri May 22, 2009 2:38 pm

nicholas.seward
Offline Offline
Send Email Send Email

Forward
Message #559 of 1070 |
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