Académique Documents
Professionnel Documents
Culture Documents
Thanks
Jerry
/////////////////////////////////////////////////////////////////////////////////////////////
Hola tfriez,
gracias
Jerry
#pragmaconfig(Motor,motor4,rightLiftMotor,tmotorVexIQ,
PIDControl,reversed,encoder)
#pragmaconfig(Motor,motor10,leftLiftMotor,tmotorVexIQ,
PIDControl,encoder)
#pragmaconfig(Motor,motor11,clawMotor,tmotorVexIQ,
PIDControl,encoder)
//*!!Codeautomaticallygeneratedby'ROBOTC'configurationwizard
!!*//
floatfSetClawPos=0;
floatfSetArmPos=0;
taskmain()
while(1)
if(getJoystickValue(BtnRDown))
fSetClawPos=0;//CloseClaw
if(getJoystickValue(BtnRUp))
fSetClawPos=450;//Open
if(getJoystickValue(BtnLDown))
fSetArmPos=0;//LowerClaw
if(getJoystickValue(BtnLUp))
fSetArmPos=250;//RaiseClaw
setServoTarget(clawMotor,fSetClawPos);
setServoTarget(leftLiftMotor,fSetArmPos);
setServoTarget(rightLiftMotor,fSetArmPos);
//displayTextLine(0,"Drvs=%dl=%dr=%d",0,
getServoEncoder(leftDriveMotor),getServoEncoder(rightDriveMotor));
displayTextLine(1,"Clws=%da=%d",fSetClawPos,
getServoEncoder(clawMotor));
displayTextLine(2,"RLfts=%dr=%d",fSetArmPos,
getServoEncoder(rightLiftMotor));
displayTextLine(3,"LLfts=%dl=%d",fSetArmPos,
getServoEncoder(leftLiftMotor));
//Waitthetiminginterval
wait1Msec(25);
}
Hey Jerry,
Yeah - I'm pretty stumped to why the motors would be cutting out. Luckily,
there's some status variables we can monitor with the motors using
ROBOTC. I've thrown together a test program that runs as a separate task
(so it won't interfere with your main code) and will output data to the global
variables debugger window.
Just add your program to "task main" and keep the "startTask" command at
the top. Then, while your program is running - keep an eye on the Global
Debugger window and see if any of the variables (Specifically current limit /
motor temp) switch to reporting as "true".
Code:
Hey Jerry,
Cdigo:
boolbMotorCurrentLimit[12];
boolbMotorTemp[12];
boolbMotorZeroPosition[12];
boolbMotorZeroVelocity[12];
taskmonitorMotors()
TVexIQDeviceTypesnDeviceType;
TDeviceStatusnDeviceStatus;
shortnDeviceVersion=0;
while(true)
for(tMotortheMotor=motor1;theMotor<=motor12;theMotor++)
getVexIqDeviceInfo(theMotor,nDeviceType,nDeviceStatus,
nDeviceVersion);
if(nDeviceType!=vexIQ_SensorMOTOR)
continue;
bMotorCurrentLimit[theMotor]=getMotorCurrentLimitFlag(theMotor);
bMotorTemp[theMotor]=getMotorOverTemp(theMotor);
bMotorZeroPosition[theMotor]=getMotorZeroPosition(theMotor);
bMotorZeroVelocity[theMotor]=getMotorZeroVelocity(theMotor);
sleep(5);
}
taskmain()
startTask(monitorMotors);
//Addyourcodehere.