View unanswered posts | View active topics It is currently Sun Sep 15, 2019 8:07 pm






Reply to topic  [ 5 posts ] 
Ports Not working 
Author Message
Rookie

Joined: Wed Nov 19, 2014 7:43 pm
Posts: 2
Post Ports Not working
We've had issues with Cortex ports not working. The specific ports are 3-5. We've tried two different cortexes and have experienced the same issue. Eli from VEX suggested that we use a sample code found on RobotC files. This solved our issues, but when we modified the codes to our needs, no ports worked. Could someone assist us resolve this issue? Many thanks in advance.


Wed Nov 19, 2014 7:49 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Ports Not working
Sounds like your Cortex is OK. Could be your code or the load on the port. Could you post your code and what is connected to the ports?


Wed Nov 19, 2014 8:16 pm
Profile
Rookie

Joined: Wed Nov 19, 2014 7:43 pm
Posts: 2
Post Re: Ports Not working
Here is our code.

Code:
#pragma config(Motor,  port1,           frontLeftMotor, tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           TestMotor,     tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port3,           IntakeMotor,   tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port4,           TopRightLift,  tmotorServoContinuousRotation, openLoop, driveRight)
#pragma config(Motor,  port5,           BottomRightLift, tmotorServoContinuousRotation, openLoop, reversed, driveRight)
#pragma config(Motor,  port6,           TopLeftLift,   tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port7,           BottomLeftLift, tmotorServoContinuousRotation, openLoop, reversed, driveLeft)
#pragma config(Motor,  port8,           frontRightMotor, tmotorServoContinuousRotation, openLoop, driveRight)
#pragma config(Motor,  port9,           backRightMotor, tmotorServoContinuousRotation, openLoop, driveRight)
#pragma config(Motor,  port10,          backLeftMotor, tmotorVex393_HBridge, openLoop, reversed)


Code:
task usercontrol()

{


  while (true)
  {
    //Program for Riverdale High School Robotics Team Robot 4099-C
    //Mecanum Wheels Cake
    motor[frontRightMotor] = vexRT[Ch3] - vexRT[Ch1] - vexRT[Ch4];
    motor[backRightMotor] =  vexRT[Ch3] - vexRT[Ch1] + vexRT[Ch4];
    motor[frontLeftMotor] = vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
    motor[backLeftMotor] =  vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];

    //Left Top
    {
      if(vexRT[Btn5D]==1)
      {
        motor[TopLeftLift] = 127;
      }
      else if(vexRT[Btn5U]==1)
      {
        motor[TopLeftLift] = -127;
      }
      else if(vexRT[Btn5D]==0)
      {
        motor[TopLeftLift] = 0;
      }
      else if (vexRT[Btn5U] ==0)
      {
        motor[TopLeftLift] = 0;
      }
      if(vexRT[Btn5D]==1)
      {
        motor[TopLeftLift] = 127;
      }
      else if(vexRT[Btn5U]==1)
      {
        motor[TopLeftLift] = -127;
      }
      else if(vexRT[Btn5D]==0)
      {
        motor[TopLeftLift] = 0;
      }
      else if (vexRT[Btn5U] ==0)
      {
        motor[TopLeftLift] = 0;
      }

      //Bottom Left
      {
        if(vexRT[Btn5D]==1)
        {
          motor[BottomLeftLift] = 127;
        }
        else if(vexRT[Btn5U]==1)
        {
          motor[BottomLeftLift] = -127;
        }
        else if(vexRT[Btn5D]==0)
        {
          motor[BottomLeftLift] = 0;
        }
        else if (vexRT[Btn5U] ==0)
        {
          motor[BottomLeftLift] = 0;
        }
        if(vexRT[Btn5D]==1)
        {
          motor[BottomLeftLift] = 127;
        }
        else if(vexRT[Btn5U]==1)
        {
          motor[BottomLeftLift] = -127;
        }
        else if(vexRT[Btn5D]==0)
        {
          motor[BottomLeftLift] = 0;
        }
        else if (vexRT[Btn5U] ==0)
        {
          motor[BottomLeftLift] = 0;
        }
        //Test Port

        if(vexRT[Btn7D]==1)
        {
          motor[TestMotor] = 127;
        }
        else if(vexRT[Btn7U]==1)
        {
          motor[TestMotor] = -127;
        }
        else if(vexRT[Btn7D]==0)
        {
          motor[TestMotor] = 0;
        }
        else if (vexRT[Btn7U] ==0)
        {
          motor[TestMotor] = 0;
        }
        if(vexRT[Btn7D]==1)
        {
          motor[TestMotor] = 127;
        }
        else if(vexRT[Btn7U]==1)
        {
          motor[TestMotor] = -127;
        }
        else if(vexRT[Btn7D]==0)
        {
          motor[TestMotor] = 0;
        }
        else if (vexRT[Btn7U] ==0)
        {
          motor[TestMotor] = 0;

          //IntakeMotor

          if(vexRT[Btn8D]==1)
          {
            motor[IntakeMotor] = 127;
          }
          else if(vexRT[Btn8U]==1)
          {
            motor[IntakeMotor] = -127;
          }
          else if(vexRT[Btn8D]==0)
          {
            motor[IntakeMotor] = 0;
          }
          else if (vexRT[Btn8U] ==0)
          {
            motor[IntakeMotor] = 0;
          }
          if(vexRT[Btn8D]==1)
          {
            motor[IntakeMotor] = 127;
          }
          else if(vexRT[Btn8U]==1)
          {
            motor[IntakeMotor] = -127;
          }
          else if(vexRT[Btn8D]==0)
          {
            motor[IntakeMotor] = 0;
          }
          else if (vexRT[Btn8U] ==0)
          {
            motor[IntakeMotor] = 0;
            //Right Top

            if(vexRT[Btn6D]==1)
            {
              motor[TopRightLift] = 127;
            }
            else if(vexRT[Btn6U]==1)
            {
              motor[TopRightLift] = -127;
            }
            else if(vexRT[Btn6D]==0)
            {
              motor[TopRightLift] = 0;
            }
            else if (vexRT[Btn6U] ==0)
            {
              motor[TopRightLift] = 0;
            }
            if(vexRT[Btn6D]==1)
            {
              motor[TopRightLift] = 127;
            }
            else if(vexRT[Btn6U]==1)
            {
              motor[TopRightLift] = -127;
            }
            else if(vexRT[Btn6D]==0)
            {
              motor[TopRightLift] = 0;
            }
            else if (vexRT[Btn6U] ==0)
            {
              motor[TopRightLift] = 0;
            }

            //Right Left

            if(vexRT[Btn6D]==1)
            {
              motor[BottomRightLift] = 127;
            }
            else if(vexRT[Btn6U]==1)
            {
              motor[BottomRightLift] = -127;
            }
            else if(vexRT[Btn6D]==0)
            {
              motor[BottomRightLift] = 0;
            }
            else if (vexRT[Btn6U] ==0)
            {
              motor[BottomRightLift] = 0;
            }
            if(vexRT[Btn6D]==1)
            {
              motor[BottomRightLift] = 127;
            }
            else if(vexRT[Btn6U]==1)
            {
              motor[BottomRightLift] = -127;
            }
            else if(vexRT[Btn6D]==0)
            {
              motor[BottomRightLift] = 0;
            }
            else if (vexRT[Btn6U] ==0)
            {
              motor[BottomRightLift] = 0;
            }


          }
        }

      }
    }

  }
}


Wed Nov 19, 2014 9:13 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Ports Not working
It looks like you have extra braces below //Bottom Left and //Bottom Left and just put a mating set at the bottom. These should be removed.
You have 5 subsections of code that are duplicated for some reason, the 16 lines under the first extra brace are repeated exactly twice. Consider removing the redundant code.
You may have forgotten a left brace above //IntakeMotor and another above //Right Top then added them at the bottom.


Thu Nov 20, 2014 1:28 pm
Profile
Rookie

Joined: Wed Feb 24, 2010 11:51 pm
Posts: 31
Post Re: Ports Not working
For situations like this, it's really helpful to use the "Fix Formatting" button on the toolbar. It will help you spot places where you have unexpected indenting because of mismatched braces. In your code sample, all of the if/else lines should have the same indenting.

Terry

_________________
Vex & FLL Coach and robotics instructor


Fri Nov 21, 2014 1:12 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.