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
--- In bestinc@yahoogroups.com, "nicholas.seward" <nicholas.seward@...> wrote:
>
> // 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 edited but if you are not constrained by BEST rules then you can set you
tick length to what ever you want up to limit of 1/450 sec. I don't know if it
would be against the rules to place the following lines of code immediately
before the InitBrain() call. I am 99% sure that it would work but have not
tested it. I think the #undef line can be omitted but that might cause some
compilers to throw a warning.
>
> //DON'T USE SEMIS AT THE END OF THE FOLLOWING LINES
> #undef RESET_CLK
> #define RESET_CLK (1)
>
> I have also posted an example called "FineGrainClock.zip" in the file section.
I don't have a brain or even a C compiler on my computer so I am quite sure it
has many bugs. However, it should show you a way to increase the clock
resolution without modifying "bestusrutil.c." I am not a C programmer so
beware. I changed the servo_output variables to doubles. That was because if
the resolution of the clock is really fine you might get in a situation where
you are trying to change the servo position by less than one. In that situation
nothing would ever happen. You need to be able to keep track of fraction
position changes.
>