--- 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.