Jumper Pin Problem

Hello All I am having some trouble with the jumper pins on my robot. I am using RobotC and I am using the jumper pins to select from two different autonomous codes, but when I use them it only works correctly on one side for insistence when I plug in the barrier side autonomous the sensor value would equal 1 like it should but when I switch ports to the hanging side the barrier side still stays equal to one and the hanging side is equal to one.

task autonomous()
{	
	if(SensorValue[Barrier] == 1) //Tells The robot To Run The Barrier Side Autonomous
	{
		SetIntakeMotors(127); //Turns Intake Motors On To Drop The Intake Motors

		MoveArm(1090); //Moves The Arm Up To The Height Of The Big Ball

		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] < 260) //Moves The Robot Forward To Push The Ball Off The Barrier
			SetDriveMotors(127, 127);
		SetDriveMotors(0, 0);

		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] > -75) //Moves The Robot Backward Back To The Starting Square
			SetDriveMotors(-127, -127);
		SetDriveMotors(0, 0);
		
		SetIntakeMotors(0);

		wait1Msec(1250); //A Two Second Wait To Position The Robot For The Second Big Ball

		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] < 400) //Moves The Robot Forward To Push The Second Ball Off The Barrier
			SetDriveMotors(127, 127);
		SetDriveMotors(0, 0);

		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] > -250) //Moves The Robot Backward Back To The Starting Square
			SetDriveMotors(-127, -127);
		SetDriveMotors(0, 0);

		MoveArm(0); //Moves The Arm Down To Get Under The Barrier
		
		SetIntakeMotors(127); //Turns Intake Motors On

		wait1Msec(2750); //A Two Second Wait To Position The Robot For The Goal
		
		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] < 625) //Moves The Robot Forward To Goal
			SetDriveMotors(127, 127);
		SetDriveMotors(0, 0);

		SetIntakeMotors(0); //Turns Intake Motors Off

		MoveArm(1790); //Moves The Arm Up To The Height Of The Goal

		wait1Msec(375); //A Short Wait To Allow The Robot Settle From The Arm Going Up

		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] < 235) //Moves The Robot Slowly Over The Goal
			SetDriveMotors(100, 80);
		SetDriveMotors(0, 0);

		SetIntakeMotors(-127); //Turns The Intake Motors On To Drop The Ball In The Goal
		
		wait1Msec(125);

		SetDriveEncoder(0); //Clears Drive Encoder
		while(SensorValue[DriveE] > -215) //Moves The Robot Slowly Away From The Goal
			SetDriveMotors(-90, -90);
		SetDriveMotors(0, 0);

		SetIntakeMotors(0); //Turns The Intake Motors Off

		MoveArm(0); //Moves The Arm Down To The Starting Position
	}
	else if(SensorValue[Hanging] == 1) //Tells The Robot To Run The Hanging Side Autonomous
	{
		SetIntakeMotors(127); //Turns The Intake Motors On To Drop The Intake Rollers
		
		SetDriveEncoder(0); //Clears The Drive Encoder
		while(SensorValue[DriveE] < 30) //Moves The Robot Forward
			SetDriveMotors(127, 127);
		SetDriveMotors(0, 0);
		
		SetDriveEncoder(0); //Clears The Drive Encoder
		while(SensorValue[DriveE] > -25) //Moves The Robot Back
			SetDriveMotors(127, 127);
		SetDriveMotors(0, 0);

This is the code I am programming with if any one could help me I would greatly appreciate it.

Zach

What do you have the jumper pins configured as in RobotC?

What do the #pragma statements say?

#pragma config(Sensor, dgtl11, Barrier,        sensorDigitalIn)
#pragma config(Sensor, dgtl12, Hanging,        sensorDigitalIn)

They are both sensorDigitalIn that is correct right?

A digital input will read as “0” when the jumper is installed, either reverse the logic


if(SensorValue[Barrier] == 0) //Tells The robot To Run The Barrier Side Autonomous

of change the sensor type to touch sensor which will reverse polarity for you.

Why exactly do the digital inputs read as 0 or low in RobotC?

Digital inputs are traditionally pulled high (connected to positive voltage) using a resistor. When nothing is connected to the input it therefore is seen as logic 1. Plugging in the jumper shorts the input to 0 volts, the cpu sees that as logic 0.

See the input circuit for the cortex on page 13 of the user manual.

VEXnet_Cortex_UserGuide_012014

Well when I plug in the jumper pin for the barrier side the sensor port reads 1, but when I unplug the jumper pin both the barrier and hanging side read 1. The same thing happens when I plug in the hanging side. The digital ports for the barrier and hanging side read 1. Why would that be could that be a bad port or ports on the cortex?

I don’t know.

I tested this code using jumpers in port 11 and 12 (as you had defined) and it works.

#pragma config(Sensor, dgtl11, Barrier,        sensorDigitalIn)
#pragma config(Sensor, dgtl12, Hanging,        sensorDigitalIn)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!

void pre_auton()
{
  bStopTasksBetweenModes = true;
}
    
task autonomous()
{   
    if(SensorValue[Barrier] == 0) //Tells The robot To Run The Barrier Side Autonomous
        {
        writeDebugStreamLine("we are in Barrier auton");
        }
    else
    if(SensorValue[Hanging] == 0) //Tells The Robot To Run The Hanging Side Autonomous
        {
        writeDebugStreamLine("we are in Hangling auton");
        }
    else
        writeDebugStreamLine("No jumpers are installed");
}

task usercontrol()
{
    while (true)
        wait1Msec(10);
}

Okay I’ll do more testing and to see if anything changes. Thank you for your help