Motor Monitor
Motor Monitor
It would be desirable to know the status of each motor on the robot after each match. The V5 smart motors have the ability to provide this information. We just need to write a monitor code to make it visible to the user.
This should be a specific code just for this purpose that we run in between matches. It will give us the temperature of each motor as well as indicate any serious problems like disconnection or port failures.
Best if it was a graphical view with very clear indications like bright colors etc.
Display of motor information
double YOFFSET = 20; //offset for the display //Writes a line for the diagnostics of a motor on the Brain void MotorDisplay(double y, double curr, double temp) { Brain.Screen.setFillColor(transparent); Brain.Screen.printAt(5, YOFFSET + y, "Current: %.1fA", curr); if (curr < 1) Brain.Screen.setFillColor(green); else if (curr >= 1 && curr <= 2.5) Brain.Screen.setFillColor(yellow); else Brain.Screen.setFillColor(red); Brain.Screen.drawRectangle(140, YOFFSET + y - 15, 15, 15); Brain.Screen.setFillColor(transparent); Brain.Screen.printAt(160, YOFFSET + y, "Temp: %.1fC", temp); if (temp < 45) Brain.Screen.setFillColor(green); else if (temp <= 50 && temp >= 45) // TRUE and TRUE --> True // TRUE and FALSE --> False // FALSE and FALSE --> False Brain.Screen.setFillColor(yellow); else Brain.Screen.setFillColor(red); Brain.Screen.drawRectangle(275, YOFFSET + y - 15, 15, 15); Brain.Screen.setFillColor(transparent); } //Displays information on the brain void Display() { double leftFrontCurr = LeftFront.current(amp); double leftFrontTemp = LeftFront.temperature(celsius); double leftBackCurr = LeftBack.current(amp); double leftBackTemp = LeftBack.temperature(celsius); double rightFrontCurr = RightFront.current(amp); double rightFrontTemp = RightFront.temperature(celsius); double rightBackCurr = RightBack.current(amp); double rightBackTemp = RightBack.temperature(celsius); if (LeftFront.installed()) { MotorDisplay(1, leftFrontCurr, leftFrontTemp); Brain.Screen.printAt(300, YOFFSET + 1, "LeftFront"); } else Brain.Screen.printAt(5, YOFFSET + 1, "LeftFront Problem"); if (LeftBack.installed()) { MotorDisplay(31, leftBackCurr, leftBackTemp); Brain.Screen.printAt(300, YOFFSET + 31, "LeftBack"); } else Brain.Screen.printAt(5, YOFFSET + 31, "LeftBack Problem"); if (RightFront.installed()) { MotorDisplay(61, rightFrontCurr, rightFrontTemp); Brain.Screen.printAt(300, YOFFSET + 61, "RightFront"); } else Brain.Screen.printAt(5, YOFFSET + 61, "RightFront Problem"); if (RightBack.installed()) { MotorDisplay(91, rightBackCurr, rightBackTemp); Brain.Screen.printAt(300, YOFFSET + 91, "RightBack"); } else Brain.Screen.printAt(5, YOFFSET + 91, "RightBack Problem"); }
Back to the course