jcferguson
04-14-2007, 01:01 AM
Hi All,
I have three joysticks controlling three servos. The center values for the joystick RC circuits drift a tiny bit with changes in temperature. I would like to set up a subroutine in my code to adjust for this.
My thinking:
1 - monitor the joysticks - when they haven't changed for a while, assume they are not being touched and run an "idletime" subroutine
2 - in the "idletime" subroutine check the rctime value and set a constant with the difference between this actual reading and what the centered joystick "should be"
3 - then use this constant when "back in play" as an adjustment to the code that scales the joystick rctime value for the servos
1 - done, I just check the value each time through the loop and when they haven't changed for about 30 times I send to the subroutine
2 - not sure. my problem is the math - say I want a value of 750 for the end output. I could do something like:
driveservodriftconstant = idletimedrivejoystickreading - 750. But then I don't know how to deal with the negative numbers (or lack of...). the ideltimedrivejoystickreading is likely 754 - 746 or so... so I get a funny value is the end result should be negative.
how do I deal with the negative numbers?
3 - think I can figure this out if I get a way to deal with the negative values.
Is there a different/better way?
Thanks for any thoughts! let me know if I need to clarify!
Carlos
I have three joysticks controlling three servos. The center values for the joystick RC circuits drift a tiny bit with changes in temperature. I would like to set up a subroutine in my code to adjust for this.
My thinking:
1 - monitor the joysticks - when they haven't changed for a while, assume they are not being touched and run an "idletime" subroutine
2 - in the "idletime" subroutine check the rctime value and set a constant with the difference between this actual reading and what the centered joystick "should be"
3 - then use this constant when "back in play" as an adjustment to the code that scales the joystick rctime value for the servos
1 - done, I just check the value each time through the loop and when they haven't changed for about 30 times I send to the subroutine
2 - not sure. my problem is the math - say I want a value of 750 for the end output. I could do something like:
driveservodriftconstant = idletimedrivejoystickreading - 750. But then I don't know how to deal with the negative numbers (or lack of...). the ideltimedrivejoystickreading is likely 754 - 746 or so... so I get a funny value is the end result should be negative.
how do I deal with the negative numbers?
3 - think I can figure this out if I get a way to deal with the negative values.
Is there a different/better way?
Thanks for any thoughts! let me know if I need to clarify!
Carlos