by cp » Thu Nov 09, 2006 4:21 pm
by cp
Thu Nov 09, 2006 4:21 pm
Thanks i-Bot, I have a couple of questions to clarify my understanding.
i-Bot wrote:If you now uncomment the motor command and run again you will see the period is now about 40 ms. This is beacause the time taken in the 4ms interrupt has increased to about 3ms, due to fact that servos are updated in this routine if enabled. Any motor enabled will make the change to longer delay.
If you still need better then turn off the motors when you don't need them. Your 5955 servos are digital, so will hold their position.
Does this mean that if I use
MOTOR G6A - instead of
MOTOR 0
MOTOR 5
that the interrupt delay would be 3 times longer? (having enabled six motors instead of two)
Too bad the MOTOR and MOTOROFF command can only be invoked for one motor at a time, presumably this increases the time required to execute the commands.
Secondly, when digital motors are "turned off" do they hold their position because of the gearing, or simply because they are actively controlling their position while awaiting their next command? I need all of my motors to hold a load at their target positions at all times.
Also, can the MOTOROFF command be invoked while the motors are moving to their new targets? (I presume the answer to this question will be tied to my question above)
Assuming the motors would remain energized after MOTOROFF, to get the best response times I would think my code could be structured as follows:
---------- BEFORE ------------
'Read sensors here
i = AD(0)
IF i > AD_ON AND FRONT_LS_FLAG = LF_STATE THEN
SPEED RETRACT_SPEED
MOVE G6A,RUN_ANG_LEFT_AFT,,,,,RUN_ANG_RIGHT_AFT
FRONT_LS_FLAG = LS_STATE
ELSEIF i < AD_OFF AND FRONT_LS_FLAG = LS_STATE THEN
SPEED RETURN_SPEED
MOVE G6A,RUN_ANG_LEFT_FORE,,,,,RUN_ANG_RIGHT_FORE
FRONT_LS_FLAG = LF_STATE
ENDIF
------- AFTER -------- (note motor numbers are intentionally changed from above)
'Read sensors here
k = AD(3)
IF k > AD_ON AND REAR_LS_FLAG = LF_STATE THEN
MOTOR 2
MOTOR 3
SPEED RETRACT_SPEED
MOVE ,,RUN_ANG_LEFT_AFT,RUN_ANG_RIGHT_AFT
REAR_LS_FLAG = LS_STATE
MOTOROFF 2
MOTOROFF 3
ELSEIF k < AD_OFF AND REAR_LS_FLAG = LS_STATE THEN
MOTOR 2
MOTOR 3
SPEED RETURN_SPEED
MOVE ,,RUN_ANG_LEFT_AFT,RUN_ANG_RIGHT_AFT
REAR_LS_FLAG = LF_STATE
MOTOROFF 2
MOTOROFF 3
ENDIF
--------------
i-Bot wrote:I also have the timer interrupt running, and this is a hog of processing. This means I also have large chunks of time lost especially if motors are enabled. So far I have got around this by turning off interrupts for short time critical code ( the normal C3024 code also does this). I also put code in the timer interrupt at 4 or 16 ms if I need to perform it regularily.
One drawback I found from using the FOR NEXT loop to reduce the REMOCON reads is that I find I have to accept reduced responsiveness to the remote in order to get fast timing. Hopefully by disabling the motors, I can get the additional responsiveness I need from both the controller and the remote. If I can't get acceptable results, is there anything else I can do from within RoboBasic?
Thanks!
Thanks i-Bot, I have a couple of questions to clarify my understanding.
i-Bot wrote:If you now uncomment the motor command and run again you will see the period is now about 40 ms. This is beacause the time taken in the 4ms interrupt has increased to about 3ms, due to fact that servos are updated in this routine if enabled. Any motor enabled will make the change to longer delay.
If you still need better then turn off the motors when you don't need them. Your 5955 servos are digital, so will hold their position.
Does this mean that if I use
MOTOR G6A - instead of
MOTOR 0
MOTOR 5
that the interrupt delay would be 3 times longer? (having enabled six motors instead of two)
Too bad the MOTOR and MOTOROFF command can only be invoked for one motor at a time, presumably this increases the time required to execute the commands.
Secondly, when digital motors are "turned off" do they hold their position because of the gearing, or simply because they are actively controlling their position while awaiting their next command? I need all of my motors to hold a load at their target positions at all times.
Also, can the MOTOROFF command be invoked while the motors are moving to their new targets? (I presume the answer to this question will be tied to my question above)
Assuming the motors would remain energized after MOTOROFF, to get the best response times I would think my code could be structured as follows:
---------- BEFORE ------------
'Read sensors here
i = AD(0)
IF i > AD_ON AND FRONT_LS_FLAG = LF_STATE THEN
SPEED RETRACT_SPEED
MOVE G6A,RUN_ANG_LEFT_AFT,,,,,RUN_ANG_RIGHT_AFT
FRONT_LS_FLAG = LS_STATE
ELSEIF i < AD_OFF AND FRONT_LS_FLAG = LS_STATE THEN
SPEED RETURN_SPEED
MOVE G6A,RUN_ANG_LEFT_FORE,,,,,RUN_ANG_RIGHT_FORE
FRONT_LS_FLAG = LF_STATE
ENDIF
------- AFTER -------- (note motor numbers are intentionally changed from above)
'Read sensors here
k = AD(3)
IF k > AD_ON AND REAR_LS_FLAG = LF_STATE THEN
MOTOR 2
MOTOR 3
SPEED RETRACT_SPEED
MOVE ,,RUN_ANG_LEFT_AFT,RUN_ANG_RIGHT_AFT
REAR_LS_FLAG = LS_STATE
MOTOROFF 2
MOTOROFF 3
ELSEIF k < AD_OFF AND REAR_LS_FLAG = LS_STATE THEN
MOTOR 2
MOTOR 3
SPEED RETURN_SPEED
MOVE ,,RUN_ANG_LEFT_AFT,RUN_ANG_RIGHT_AFT
REAR_LS_FLAG = LF_STATE
MOTOROFF 2
MOTOROFF 3
ENDIF
--------------
i-Bot wrote:I also have the timer interrupt running, and this is a hog of processing. This means I also have large chunks of time lost especially if motors are enabled. So far I have got around this by turning off interrupts for short time critical code ( the normal C3024 code also does this). I also put code in the timer interrupt at 4 or 16 ms if I need to perform it regularily.
One drawback I found from using the FOR NEXT loop to reduce the REMOCON reads is that I find I have to accept reduced responsiveness to the remote in order to get fast timing. Hopefully by disabling the motors, I can get the additional responsiveness I need from both the controller and the remote. If I can't get acceptable results, is there anything else I can do from within RoboBasic?
Thanks!