First time creating topic, sorry for format. This thread involves a problem my team has faced practically all season. It involves frying ports on multiple cortex’s.
First V5 brain mess up :
The problem began a couple months go when I finally completed all the code for the robot. I completed all the functions for the subsystems (Driving, expansion, intake, tray, etc) and organized into separate cpp files as well as header files. After I uploaded the code it worked flawlessly for the first couple matches, until it didn’t. At first one motor running the front left wheel stopped working completely for the first half of the match, then for the final half of that match it began to run at full speed on it’s own (even when the user wasn’t controlling it to do so). Even after the match ended it kept running until we turned off the cortex completely. After this match whenever we tried to run it again this would occur all over again. At first we thought it was a hardware issue, so we changed out the motor that was messing up. This helped for a couple matches until this would occur all over again. I then assumed there was something wrong with the code, so I began making small adjustments that I thought may effect it. We kept testing with no new results, until more motors actually began to stop working. We then decided to check the ports, which showed that many of the ports stopped working. We would decide to change V5 brain’s and use a new one.
Second V5 brain mess up:
With the first brain being fried, I had a suspicion it was the code that somehow caused this. So I made drastic changes to the code without any real direction towards the problem. With a new cortex and new code (essentially) it started to work again. But the same problem happened again, with the wheel going out and then going non-stop. This time we starting testing each port with new wires and motors. We would switch ports for the motors to be wired to, which would then make it run for a little bit until it went out, and did not work again. A couple days ago, coming back from winter break, we tried running the robot a couple times. This led to a little less than half of the ports to stop working permanently.
With all of this being said it seems as though the code is some how causing the issues, since the likelihood of getting 2, even 1 faulty brain, is very slim. We are sending one of the brain’s into vex, any suggestions are helpful!
The code :
#include "vex.h"
using namespace vex;
vex::brain Brain;
vex::controller Controller1;
vex::competition Competition;
int threshold = 17;
int distance = 0;
vex::motor LeftMotor = vex::motor(PORT10, gearSetting::ratio18_1, true);
vex::motor RightMotor = vex::motor(PORT20, gearSetting::ratio18_1, true);
vex::motor LeftMotor2 = vex::motor(PORT2, gearSetting::ratio18_1, true);
vex::motor RightMotor2 = vex::motor(PORT12, gearSetting::ratio18_1, true);
vex::motor leftIntake = vex::motor(PORT11,gearSetting::ratio18_1);
vex::motor rightIntake = vex::motor(PORT3,gearSetting::ratio18_1);
vex::motor tray = vex::motor(PORT14, gearSetting::ratio18_1);
vex::motor arms = vex::motor(PORT17);
void Tray(){
vex::task::sleep(20);
if(Controller1.ButtonR1.pressing()){
tray.spin(vex::directionType::fwd,
150, vex::velocityUnits::pct);
}
else if(Controller1.ButtonR2.pressing()){
tray.spin(vex::directionType::rev,
150, vex::velocityUnits::pct);
}
else{
tray.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
}
}
void armMove(){
vex::task::sleep(20);
if(Controller1.ButtonUp.pressing()){
arms.spin(vex::directionType::rev,
150, vex::velocityUnits::pct);
}
else if(Controller1.ButtonDown.pressing()){
arms.spin(vex::directionType::fwd,
150, vex::velocityUnits::pct);
}
else{
arms.spin(vex::directionType::fwd,
0, vex::velocityUnits::pct);
arms.setBrake(vex::brakeType::hold) ;
}
}
void intake(){
vex::task::sleep(20);
if(Controller1.ButtonL2.pressing()){
leftIntake.spin(vex::directionType::rev,
200, vex::velocityUnits::pct);
rightIntake.spin(vex::directionType::fwd,
200, vex::velocityUnits::pct);
}
else if(Controller1.ButtonL1.pressing()){
leftIntake.spin(vex::directionType::fwd,
200, vex::velocityUnits::pct);
rightIntake.spin(vex::directionType::rev,
200, vex::velocityUnits::pct);
}
else{
leftIntake.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
rightIntake.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
}
}
void driveExtend(){
vex::task::sleep(20);
if(!Controller1.ButtonA.pressing() && !Controller1.ButtonB.pressing()){
int right = ( abs(Controller1.Axis4.value()) > threshold)?Controller1.Axis4.value():0;
int forward = ( abs(Controller1.Axis3.value()) > threshold)?-Controller1.Axis3.value():0;
int turn = ( abs(Controller1.Axis1.value()) > threshold)?Controller1.Axis1.value():0;
LeftMotor.spin(vex::directionType::fwd,
forward - turn - right, vex::velocityUnits::pct);
LeftMotor2.spin(vex::directionType::fwd,
forward - turn + right, vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::rev,
forward + turn + right, vex::velocityUnits::pct);
RightMotor2.spin(vex::directionType::rev,
forward + turn - right, vex::velocityUnits::pct);
}
else if (Controller1.ButtonB.pressing()) {
LeftMotor.spin(vex::directionType::fwd,
200, vex::velocityUnits::pct);
LeftMotor2.spin(vex::directionType::rev,
200, vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::rev,
200, vex::velocityUnits::pct);
RightMotor2.spin(vex::directionType::fwd,
200, vex::velocityUnits::pct);
}
else if(Controller1.ButtonA.pressing()){
LeftMotor.spin(vex::directionType::rev,
200, vex::velocityUnits::pct);
LeftMotor2.spin(vex::directionType::fwd,
200, vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd,
200, vex::velocityUnits::pct);
RightMotor2.spin(vex::directionType::rev,
200, vex::velocityUnits::pct);
}
else{
LeftMotor.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
LeftMotor2.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
RightMotor2.spin(vex::directionType::rev,
0, vex::velocityUnits::pct);
}
}
//-----------------------------------------------------------------------------
void rotateDistance(int &distance, int newDistance){
distance = newDistance;
distance = distance/12;
}
void setVeloBaby(int veloBaby){
LeftMotor.setVelocity(veloBaby, percentUnits::pct);
LeftMotor2.setVelocity(veloBaby, percentUnits::pct);
RightMotor.setVelocity(veloBaby, percentUnits::pct);
RightMotor2.setVelocity(veloBaby, percentUnits::pct);
}
void move(directionType lm, directionType lm2, directionType rm, directionType rm2){
while(LeftMotor.rotation(vex::rotationUnits::deg) < 1800){
LeftMotor.spin(lm);
LeftMotor2.spin(lm2);
RightMotor.spin(rm);
RightMotor2.spin(rm2);
}
}
//--------------------------------------
void pre_auton(void){}
void autorun(){
//rotateDistance(distance,12);
//setVeloBaby(100);
//move(fwd, directionType::rev, fwd, directionType::rev);
}
//-------------------------------------------
int main() {
Competition.autonomous( autorun );
pre_auton();
autorun();
while(1) {
driveExtend();
intake();
Tray();
armMove();
}
}