User Tools

Site Tools


Action unknown: copypageplugin__copy
software_notes:feeding_the_dog

Feeding the Dog

Watchdog timer

To ensure proper processing of the robot functions the main robot loop must be able to complete in 200 milliseconds (ms). This means that none of the functions in team provided code can wait or loop for a significant length of time.

To detect that the loop is taking more than 200ms, there is a check each iteration through the loop that check the clock. If the time was more than the limit, an error message is printed and table of things that were done in the loop and the length of time each took. Due to the way console IO is handled on the robot this table can sometimes be interspersed with other console output, but it is usually easy enough to puzzle out the actual output from the format. The error message includes the string “Watchdog not fed within” and the length of time the loop took or “Loop time of Xs overrun.”

In addition to the check at the end of the loop, there is a separate Java thread that occasionally examines the time since the loop started and it will print a message if the loop is taking too long. The reason a separate thread is used is to ensure that a message is printed if the loop simply stops and never completes a loop.

Motor Safety timer

There is another timer that is similar to the watchdog timer. This timer has the same timeout, but instead of being reset each time through the loop, the timer is reset each time a motor controller has it speed set. Most motor controllers will take the last speed that was set and just keep at that level indefinitely. This can present a safety hazard if the motors involved are associated with the drive train. If something goes wrong in the robot software the robot could keep moving uncontrolled and run into people.

To prevent this from happening controllers that are extend any of the drive classes in the WPILIB have the motorsafety watch dog timer check enabled. When it is enabled the motor must have its speed set once each robot loop. If it does not then an error message is printed and the motor is stopped. The error message will include the string “… Output not updated often enough.” The motor is stopped by calling its “stopMotor” method.

Unlike the loop timer, the safety timer is ignored when the robot is disabled or in test mode.

If it is desirable to enable the safety timer on a controller that is not a part of a drive class, most motor controller classes can enable it by calling the setSafetyEnabled() method on the controller object with the parameter “true”.

edu.wpi.first.wpilibj.MotorSafety

java.lang.String.concat(java.lang.String)

Discussion

Enter your comment:
E Y V A M
 
software_notes/feeding_the_dog.txt · Last modified: by Brian Utterback

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki