So to be able to pick up a skyrise section, our team put the basic claw from the ClawBot Kit onto our robot (Yes we plan to use something different in the future). The problem is that after the claw picks up a skyrise section, the motor will sometimes stop working for a short while. It doesn’t do it every time, just sometimes. We believe it is flipping the internal circuit breaker or something. We have never had this problem with the claw before. Is possible to stop this from happening without changing the way the claw is?
Thanks!
Set the motor at a low power (about 10) after the claw has closed. Something high enough to keep it closed tightly around the skyrise section, but low enough so that you won’t trip the PTC.
So use like a limit switch to know when it is closed on something or not?
Yeah, or an encoder.
Options
-
Encode the motor, use intelligent programming (or my smart motor library)
-
Track the duration of applied power, ie. you press the close button, send high power to the motor for 1 second before dropping power to a low value. Don’t send high power to the motor again (for closing it) until you have detected that the claw has been opened. You can implement this as a finite state machine using the operator button presses and time to move between the different states. I will see of I can throw some code together for you later.
What forum members have already described is sometimes known as "“stall detection”. When a motor is forced to stop moving even when it is still being supplied with electrical power, it is in a stall condition.
When a motor stalls, it sucks up a large amount of current. When it sucks up a large amount of current, it starts to heat up. To protect the motor from burning up, there is a device inside called a PTC. This warms up when there is a lot of current, too, and will effectively cut off the electrical power when it gets too hot. There is something like this in the Cortex, too.
Stall detection uses a sensor (usually an encoder) to watch when the motor is stalled. Your code can then decide what to do once stall has been detected. Jpearman’s smart motor library has code that will do that for you somewhat automatically. It is not only a smart library, it is brilliant. But you can write your own versions of such a code, too.
Alright thanks people! I’ll see what I can do with some encoders and sensors!
Here’s some code that demonstrates state machine based control. Claw can be opened or closed for 1 second after which power is reduced.
#pragma config(Motor, port1, clawMotor, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*-----------------------------------------------------------------------------*/
/* Claw control demo */
/* Copyright James Pearman 2014 */
/*-----------------------------------------------------------------------------*/
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/*-----------------------------------------------------------------------------*/
// Motor powers for claw
#define CLAW_OPEN_FAST -127
#define CLAW_OPEN_SLOW -20
#define CLAW_STOP 0
#define CLAW_CLOSE_FAST 127
#define CLAW_CLOSE_SLOW 20
// mS in a second
#define MS_TO_SECONDS 1000 // there are 1000 mS in a second
// Time before we cut power
#define CLAW_MOVE_TIME (1*MS_TO_SECONDS)
// Claw states
typedef enum {
kClawInitialize1 = 0,
kClawInitialize2,
kClawOpen,
kClawClosed,
kClawMoving
} clawStates;
// Function to send speed to the claw motor
void
setClawSpeed( int speed )
{
motor clawMotor ] = speed;
}
// Task to control the claw
task claw()
{
clawStates clawState = kClawInitialize1;
long clawTimer;
long clawTimerRemaining;
long systemTime;
while(1)
{
// get system up time
systemTime = nSysTime;
// run state machine
switch(clawState)
{
case kClawInitialize1:
// We start off not knowing where the claw is so we open slowly
// for 2 seconds
setClawSpeed( CLAW_OPEN_SLOW );
clawTimer = systemTime + (2 * MS_TO_SECONDS);
clawState = kClawInitialize2;
break;
case kClawInitialize2:
// wait for claw to open
if( systemTime >= clawTimer )
{
setClawSpeed( CLAW_STOP );
clawState = kClawOpen;
}
break;
case kClawOpen:
// Claw is open here
if( vexRT Btn8R ] == 1 )
{
setClawSpeed( CLAW_CLOSE_FAST );
clawTimer = systemTime + CLAW_MOVE_TIME;
clawState = kClawMoving;
}
else
if( vexRT Btn8L ] == 1 )
setClawSpeed( CLAW_OPEN_SLOW );
else
setClawSpeed( CLAW_STOP );
break;
case kClawClosed:
// Claw is closed here
if( vexRT Btn8L ] == 1 )
{
setClawSpeed( CLAW_OPEN_FAST );
clawTimer = systemTime + CLAW_MOVE_TIME;
clawState = kClawMoving;
}
else
if( vexRT Btn8R ] == 1 )
setClawSpeed( CLAW_CLOSE_SLOW );
else
setClawSpeed( CLAW_STOP );
break;
case kClawMoving:
// Claw is partially open here
if( vexRT Btn8R ] == 1 && systemTime >= clawTimer )
{
setClawSpeed( CLAW_CLOSE_SLOW );
clawState = kClawClosed;
}
else
if( vexRT Btn8L ] == 1 && systemTime >= clawTimer )
{
setClawSpeed( CLAW_OPEN_SLOW );
clawState = kClawOpen;
}
else
if( vexRT Btn8R ] == 1 )
{
setClawSpeed( CLAW_CLOSE_FAST );
clawTimerRemaining = clawTimer - systemTime;
}
else
if( vexRT Btn8L ] == 1 )
{
setClawSpeed( CLAW_OPEN_FAST );
clawTimerRemaining = clawTimer - systemTime;
}
else
{
setClawSpeed( CLAW_STOP );
clawTimer = systemTime + clawTimerRemaining;
}
break;
default:
// error condition
clawState = kClawInitialize1;
break;
}
wait1Msec(25);
}
}
// Main entry
task main()
{
startTask( claw );
while(1)
wait1Msec(25);
}
my solution was simple(ish) and doesnt use any encoders, i made the claw slow down gradually when you hold down the button
this solves the issue where you hold down the button on accident and the motor overheats
and it solved the issue where the sudden lack of power when you stop pressing the button causes the claw to release slightly (vs adding rubber bands which makes it harder to release)
this is pretty much how it works:
#define getBtns(a,b) ((vexRT[a]*-127)+(vexRT***127))
float clawSpeed=1;
task userControl() {
while (true) {
clawSpeed*=0.93
clawSpeed=getBtns(Btn6D,Btn6U)==0?1:clawSpeed*0.93 // sets clawSpeed to 1 if you dont press anything
motor[claw_motor]=getBtns(Btn6D,Btn6U)*clawSpeed
wait1Msec(50); // so it releases at a predictable rate
}
}
**