Can anyone take a look at our program and teach us what we need to do to make our fly wheel more consistent. We have tried to make two speeds one for preload and one for half court. the pre load is fairly consistent not great about 15 of 24. l

the half court

}

float//---------get speed----------------1

getSpeed()//--------------2

{

float speed = SensorValue[LeftEncoder]/10;

SensorValue[LeftEncoder] = 0;

return speed;

}

void stopFlywheels()

{

motor[RightWheel]=0;

motor[LeftWheel]=0;

}

void runFlywheels()

{

int low=(-70000-12*(8000-nImmediateBatteryLevel))/1000;

int high=(-77000-12*(8000-nImmediateBatteryLevel))/1000;

if(SensorValue[rightEncoder] < -(SensorValue[leftEncoder]))

{

motor[RightWheel] = high;

motor[leftWheel] = low;

SensorValue[RO] = 1;

SensorValue[MO] = 0;

SensorValue[LO] = 0;

}

else if(SensorValue[rightEncoder] > -(SensorValue[leftEncoder]))

{

motor[RightWheel] = low;

motor[leftWheel] = high;

SensorValue[RO] = 0;

SensorValue[MO] = 0;

SensorValue[LO] = 1;

}

else if(SensorValue[rightEncoder] == -(SensorValue[leftEncoder]))

{

motor[RightWheel] = high;

motor[leftWheel] = high;

SensorValue[RO] = 0;

SensorValue[MO] = 1;

SensorValue[LO] = 0;

}

else

{

motor[RightWheel] = 0;

motor[leftWheel] = 0;

SensorValue[RO] = 0;

SensorValue[MO] = 0;

SensorValue[LO] = 0;

}

}

task usercontrol()

{

int X2 = 0, Y1 = 0, X1 = 0, threshold = 15,time=0,speed=0,LCDMode=0,auto=0;

// User control code here, inside the loop

bLCDBacklight=true;

while (true)

{

time++;

wait1Msec(10);

//create deadzone for Y1/Ch3

if(abs(vexRT[Ch3]) > threshold)

Y1 = vexRT[Ch3];

else

Y1 = 0;

//create a llama for X1/Ch4

if(abs(vexRT[Ch4]) > threshold)

X1 = vexRT[Ch4];

else

X1 = 0;

//create deadzone for X2/Ch1

if(abs(vexRT[Ch1]) > threshold)

X2 = vexRT[Ch1];

else

X2 = 0;

```
if(vexRT[Btn7D] == 1 )
{
//remote control command
motor[frontRight] = (Y1 - X2 - X1)/3;
motor[backRight] = (Y1 - X2 + X1)/3;
motor[frontLeft] = (Y1 + X2 + X1)/3;
motor[backLeft] = (Y1 + X2 - X1)/3;
}
else
{
//remote control command
motor[frontRight] = Y1 - X2 - X1;
motor[backRight] = Y1 - X2 + X1;
motor[frontLeft] = Y1 + X2 + X1;
motor[backLeft] = Y1 + X2 - X1;
}
//*************************************************************************************************************
//********************************************************************************
// Arm Control
if(vexRT[Btn5D] == 1 )
{
IntakeDrive(127);
}
else
if(vexRT[Btn6D] == 1 )
{
IntakeDrive(-127);
}
else
{
IntakeDrive(0);
}
if(vexRT[Btn6U] == 1 )
{
//if battery is affecting the power too much, change the 15 modifier lower
//if overall shooting too low, change the first number higher && vice versa
// int low=(-70000-12*(8000-nImmediateBatteryLevel))/1000;
//int high=(-77000-12*(8000-nImmediateBatteryLevel))/1000;
int low=-(-28-2*(8-nImmediateBatteryLevel));
int high=-(-30-2*(8-nImmediateBatteryLevel));
if(SensorValue[rightEncoder] > -(SensorValue[leftEncoder]))
{
motor[RightWheel] = high;
motor[leftWheel] = low;
SensorValue[RO] = 1;
SensorValue[MO] = 0;
SensorValue[LO] = 0;
}
if(SensorValue[rightEncoder] < -(SensorValue[leftEncoder]))
{
motor[RightWheel] = low;
motor[leftWheel] = high;
SensorValue[RO] = 0;
SensorValue[MO] = 0;
SensorValue[LO] = 1;
}
if(SensorValue[rightEncoder] == -(SensorValue[leftEncoder]))
{
motor[RightWheel] = high;
motor[leftWheel] = high;
SensorValue[RO] = 0;
SensorValue[MO] = 1;
SensorValue[LO] = 0;
}
}
else
if(vexRT[Btn5U] == 1 )
{
runFlywheels();
}
else{
stopFlywheels();
}
if(vexRT[Btn8U] == 1 )
{
liftDrive(127);
StabilizerDrive(-50);
}
else
if(vexRT[Btn8D] == 1 )
{
liftDrive(-127);
StabilizerDrive(-50);
}
else
{
liftDrive(0);
StabilizerDrive(0);
}
if(vexRT(Btn7D)==1){//btn7d is auto on
auto=1;
}
if(vexRT(Btn7U)==1){//btn7u is auto off
auto=0;
}
if(auto==1){
runFlywheels();
if(time%25==0){
speed=getSpeed();
}
if(speed>300){//change the 300 higher if shooting too early, lower if not early enouhg
IntakeDrive(127);
}
else{
intakeDrive(0);
}
}
clearLCDLine(0);//LCD logic and nonsense
if(nLCDButtons==1){
LCDMode=0;
}
if(nLCDButtons==2){
LCDMode=1;
}
if(LCDMode==0){
displayLCDNumber(0,0,SensorValue[LeftEncoder]);
}
else{
displayLCDNumber(0,0,nImmediateBatteryLevel/1000);
}
if(time%25==0){
time=0;
clearLCDLine(1);
speed=getSpeed();
displayLCDNumber(1,0,speed);//calculates and displays speed
}
```