When I hit a button, I want my claw to open and stay open. Likewise, when I hit another button, I want it to close and stay closed, not release tension, dropping the cone. My students have written the code to do this but it eventually becomes unresponsive or only opens a little. The motor seems to lose power (or interest) in what we are trying to do. When we wait a few seconds, it starts back up. The students wrote code to turn off the motor. We thought it might reset the motor, but this didn’t make any difference. Currently I have an if statement followed by an else if statement to make the motors go in their respective directions. I don’t want to put in a blank else statement with 0 power because that’s what I’m trying to avoid. Is it overheating and this is causing it to stall? Your help is greatly appreciated.
VEX EDR motors aren’t smart motors, meaning they don’t lock. So the claw motor might be at zero, but it can still go all over the place. If you stick a blank else statement that sets the claw motor to like 10, though, this will keep it closed but not give it enough power to move against the controller.
Would there need to be two blank else statements with 10? One for the opening and one for the closing?
I tried the 10 power with a blank else statement and it helps to hold it open really well. But to close it (which is more important) it of course slowly moves.
It sounds like the motor is overheating. What power are you sending it?
If the motor is trying to move at a high power level ( > 70) but not going anywhere, it will overheat and cut out pretty quickly. It should be able to stay at a low power level (~20) for a long time without cutting out. I recommend when you push the button, the claw initially moves at ~80, but after a short time (.5s) goes down to power ~20. This way, it will close quickly but won’t overheat
One simple way to do it is with a separate task.
Example:
task ClawControl()
{
while ( true )
{
if ( vexRT Btn5U ] == 1 )
{
motor claw ] = 80;
wait1msec( 500 );
motor claw ] = 20;
}
else if ( vexRT Btn5D ] == 1 )
{
motor claw ] = -80;
wait1msec( 500 );
motor claw ] = -20;
}
}
}
@Rod I wouldn’t use tasks just for braking power.
@Panther Tech Try this method:
int brakingPower = 0;
task usercontrol(){
while(true){
if(vexRT[Btn5U]){
motor[claw] = 127;
brakingPower = 10;
}
else if(vexRT[Btn5D]){
motor[claw] = -127;
brakingPower = -10;
}
else{
motor[claw] = brakingPower;
}
//Other usercontrol stuff.
delay(20);
}
}
@sazrocks So, that entire code is a separate task bracket than my primary?
That’s the idea. It’s not the most efficient way to do it, but it will work.
@Panther Tech @Rod No that code is not in a separate task. That was the point of my implementation, to remove the need for a separate task and allow this code to be run in the user control task. For this reason I named the task usercontrol and commented where to put the rest of your user control code.