I used the programming mode for joystick and downloaded to the brain. After using it for about 30-40 seconds it stopped working and I had to reset the brain and set to, Tele op and then select the program. It is always the same thing. Works for 30-40 seconds and then again stopped.
How can I fix it, to perform in 100% without resetting it??
Hmm that stinks. Can you post your code? I would like to try to see if I experience the same thing.
I used the sample program Advance Joystick with mods.
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, reversed, encoder)
#pragma config(Motor, motor4, tankiz, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor5, tankder, tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor10, armMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor11, armMotorder, tmotorVexIQ, openLoop, reversed, encoder)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
/*------------------------------------------------------------------------------------------------
This program will use the VEX IQ Wirless Controller to drive your Clawbot. This program uses
If/Else statements to provide a “threshold” for the transmitter - this allows your robot to
come to a stop even if the joysticks on the Wireless Controller haven’t perfectly returned to
their zero position.
Note: You will have to set ROBOTC to enable “Wireless Control” to use the VEX IQ joystick.
ROBOT CONFIGURATION: VEX IQ Clawbot
MOTORS & SENSORS:
* [Name] [Type] [Location]
Port 1 leftMotor VEX IQ Motor Left side motor
Port 6 rightMotor VEX IQ Motor Right side motor (reversed)
Port 10 armMotor VEX IQ Motor Arm Up/Down motor
Port 11 clawMotor VEX IQ Motor Claw Open/Close motor
------------------------------------------------------------------------------------------------*/
task main()
{
int threshold = 10;
while(true)
{
//If the ChannelA (left Y-Axis) is greater than the threshold value,
//then we’ll set the speed of the motor to vlaue from the joystick.
if(getJoystickValue(ChA) > threshold || getJoystickValue(ChA) < -threshold)
{
setMotorSpeed(leftMotor, getJoystickValue(ChA));
}
else //If less than the threshold, we’ll set the motor to zero.
{
setMotorSpeed(leftMotor, 0);
}
//If the ChannelD (right Y-Axis) is greater than the threshold value,
//then we'll set the speed of the motor to vlaue from the joystick.
if(getJoystickValue(ChD) > threshold || getJoystickValue(ChD) < -threshold)
{
setMotorSpeed(rightMotor, getJoystickValue(ChD));
}
else //If less than the threshold, we'll set the motor to zero.
{
setMotorSpeed(rightMotor, 0);
}
//If Button "L-Up" is pressed in, we'll set the arm motor to run in reverse.
if(getJoystickValue(BtnLUp) == 1)
{
setMotorSpeed(armMotor, 127);
setMotorSpeed (armMotorder, 127);
}
//If the "L-Up" isn't pressed, but "L-Down" is, we'll set the motor to run forward.
else if(getJoystickValue(BtnLDown) == 1)
{
setMotorSpeed(armMotor, -127);
setMotorSpeed (armMotorder, -127);
}
else //If neither button is pressed, we'll set the motor off.
{
setMotorSpeed(armMotor, 0);
setMotorSpeed (armMotorder, 0);
}
//If Button "R-Up" is pressed in, we'll set the arm motor to run in reverse.
if(getJoystickValue(BtnRUp) == 1)
{
setMotorSpeed(motor4, 127);
setMotorSpeed(motor5, 127);
}
//If the "L-Up" isn't pressed, but "L-Down" is, we'll set the motor to run forward.
else if(getJoystickValue(BtnRDown) == 1)
{
setMotorSpeed(motor4, -127);
setMotorSpeed(motor5, -127);
}
else //If neither button is pressed, we'll set the motor off.
{
setMotorSpeed(motor4, 0);
setMotorSpeed(motor5, 0);
}
}
}
This was it!*
Please tell what is wrong with it!
Hello,
So yeah, it did the same thing for me. Stopped after a little bit.
I would add a “Sleep(50);” inside the while loop. Basically, your code is running as fast as possible. I am wondering if you are overflowing a buffer that controls I/O on the IQ brain. The sleep would allow the brain to flush some of its memory. 50 ms is way faster than you will notice, about 200 Hz. For comparison, video is typically 24 Hz.
That is the only possible thing I can think of. I know there is tight timing and memory requirements for the FW, so this seems like a reasonable solution. It seems to be working for me now, but I havent tested it extensively
Hey Guys,
We’re actively working/looking into this issue. We should have more information within the next day or so.
Thanks!
The sleep(50) I should add in any part of the progamming??
Add it at the very end of the while loop. Outside of the if statements.
frankfort, did that solve the issue? tfriez, any thoughts?
I have tested this program several times, and have been unable to replicate the issue. There are a couple of things to check and some more information I will need in order to continue the debugging process:
-
Is the IQ and all of the motors/sensors running the latest version of the firmware? I would recommend first running the IQ Firmware Update Utility, updating the motors and sensors as needed, and then update the ROBOTC firmware to the latest version (close the IQ Firmware Update Utility, open ROBOTC, navigate to the ‘Robot -> Download Firmware -> Standard File’). The latest version should be ‘VEX_IQ_1006.bin’
-
Double check to make sure that you are using the latest version of ROBOTC (currently 4.06). This can be checked by navigating to the ‘Help -> About ROBOTC’ menu option (the version number will be in the bottom left corner of the popup window that appears). If required, you can update to the latest version by navigating to the the ‘Help -> Check for Updates’ menu option.
-
Is Natural Language enabled? You can check for this by navigating to the ‘Robot -> Platform Type’ menu option.
-
What error codes, if any, are appearing when the program crashes? Specifically, what does the IQ LCD screen show, how does the control of the robot change, and what does ROBOTC show when the program crashes?
Thank you in advance!
John,
I’ve seen this problem also. Our VEX team is running a program just like this, but the main difference is that one set of buttons move two motors (the arm) using the “setServoTarget” command. The kids ran the robot maybe 30 times this weekend, for about 1 minute each, and we had it freeze about 5 times. A couple times, they had to remove the battery to reset it.
I don’t recall the exact message, but I think it was something like I2C communication failed.
Several of the times it happened, one of the two “claw” motors would be running, and the other was not. Suggesting it happened on the second of consecutive “setMotorSpeed” commands.
It also seemed to happen more often to one specific kid, who would always put one finger on the “L-Up” button, and another on the “L-Down”, suggesting the motors could switch from speed -127 to +127 and back at any time.
Not sure if any of that helps.
I also ran into another issue with my Connect Four robot, where a large array overwrites the call-stack. I finally found out how to get around that, but it should be looked into.
If I can get you more information, please tell me.
Steve
Thank you for this information. I was able to successfully replicate the issue using the basic code below:
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, reversed, encoder)
#pragma config(Motor, motor4, tankiz, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor5, tankder, tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor10, armMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor11, armMotorder, tmotorVexIQ, openLoop, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//Code generates an 'I2C error detected on Motor Port 4-6. Reconnect Motor' error message
task main()
{
while(true)
{
if(getJoystickValue(BtnLUp))
{
setMotorSpeed(motor1, 00);
}
else if(getJoystickValue(BtnLDown))
{
setMotorSpeed(motor1, -100);
}
else
{
setMotorSpeed(motor1, 0);
}
}
}
Adding in the 50ms wait command after the if/else if/ else statements seemed to resolve the issue:
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, reversed, encoder)
#pragma config(Motor, motor4, tankiz, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor5, tankder, tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor10, armMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor11, armMotorder, tmotorVexIQ, openLoop, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//Code does not generate an 'I2C error detected on Motor Port 4-6. Reconnect Motor' message
task main()
{
while(true)
{
if(getJoystickValue(BtnLUp))
{
setMotorSpeed(motor1, 00);
}
else if(getJoystickValue(BtnLDown))
{
setMotorSpeed(motor1, -100);
}
else
{
setMotorSpeed(motor1, 0);
}
wait1Msec(50);
}
}
The error generated is an I2C issue on ports 4-6. We are currently working with VEX to resolve this issue and will post any updated information as soon as it becomes available. In the meantime, make sure to put a short, 50ms wait in any tight loops (such as the ones posted in the code above) and this should resolve the issue for you.
Thank you, everyone, for your patience as we work towards a permanent solution for this problem.
Will have the kids try that, tonight. Thanks
Steve