ROBOTC.net forums
http://robotc.net/forums/

Ports Not working
http://robotc.net/forums/viewtopic.php?f=11&t=9854
Page 1 of 1

Author:  captainespinoza [ Wed Nov 19, 2014 7:49 pm ]
Post subject:  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.

Author:  CARBOT [ Wed Nov 19, 2014 8:16 pm ]
Post subject:  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?

Author:  captainespinoza [ Wed Nov 19, 2014 9:13 pm ]
Post subject:  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;
            }


          }
        }

      }
    }

  }
}

Author:  CARBOT [ Thu Nov 20, 2014 1:28 pm ]
Post subject:  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.

Author:  terbos [ Fri Nov 21, 2014 1:12 pm ]
Post subject:  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

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/