Go to Post That's one of the saddest stories I've ever heard. When your green isn't neon enough, you are in big trouble in FIRST. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 05-03-2013, 18:51
jvriezen jvriezen is offline
Registered User
FRC #3184 (Burnsville Blaze)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Burnsville, MN
Posts: 636
jvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond repute
Stall detection

We've been having some issues with discs getting jammed in our shooter and the motors stalling.. So far, its only been in scenarios where someone is standing next to the shooter so we e-stop or whatever to avoid damage.

Does anyone have some code they can point me to that will detect a stall condition in software and shutdown the motor? Right now we don't have encoders installed (hope to soon) so I'm thinking of something that relates requested voltage detects amp draw and shutdown if amp draw stays too high for the given voltage for too long. Using CAN & Labview.

What would the code look like if we have encoders ? (Although I'd like to have both 'safety nets' in case the encoder fails and we have to go back to running without)

Thanks !
__________________
John Vriezen
FRC, Mentor, Inspector #3184 2016- #4859 2015, #2530 2010-2014 FTC Mentor, Inspector #7152 2013-14
  #2   Spotlight this post!  
Unread 05-03-2013, 19:04
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
FRC #0868
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Noblesville, IN
Posts: 1,406
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
Re: Stall detection

Under a stall condition, current will be relatively high after the motor has been free spinning for a while (if the motor is starting from stop, it will have a similar current as a stall, briefly). With CAN, you should be able to get the current output on the motors. Someone with more experience with CAN might be able to help you there.


If you're using an encoder, you should get a reading of # ticks / timeframe with a certain motor output. If you get near zero ticks / timeframe, the wheel isn't spinning and you could be in a stall condition.
__________________
Be Healthy. Never Stop Learning. Say It Like It Is. Own It.

Like our values? Flexware Innovation is looking for Automation Engineers. Check us out!
  #3   Spotlight this post!  
Unread 05-03-2013, 19:36
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Stall detection

Specifically, with encoders, you'd want to implement something like an integrated error check. Integrate your error, and if the integrated error exceeds a certain amount, you've stalled. You'll want to tune it so you don't trip the limit while you're spinning up, obviously. Probably a good idea to have something in there that reduces the integrated error over time so you don't have a whole lot of error built up from spinning up.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #4   Spotlight this post!  
Unread 07-03-2013, 11:24
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Stall detection

Implement a software circuit breaker. Circuit Breakers operate on an I^2T curve. Basically, average the I^2 value over some number of samples and if it exceeds a certain value, stop the motor. Don't set this value too low or it will trip whenever you start the motor or fire a disc.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
  #5   Spotlight this post!  
Unread 07-03-2013, 15:22
Jefferson Jefferson is offline
Registered User
AKA: Jeff Clements
FRC #0016 (Bomb Squad)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Mountain Home, AR
Posts: 258
Jefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond repute
Re: Stall detection

I don't know a thing about Labview, but I am familiar with CAN. The non-hardware solution is to monitor the output current to your shooter motors. In c++, the function is GetOutputCurrent. Our method: if the current exceeds a defined limit (say 20A) for a defined time (1.5 s) then you know the motor is stalled. Then you can take action to either shut it down to save the motor, or run it backwards if you think you can clear the jam.

To determine the current limit and time above, you'll need to know what a baseline current is for your shooter and how it reacts under normal conditions. Easiest way to do that is to chart the current on the dashboard while you are doing normal tasks like startup and shooting. These will create spikes in current. You don't want these normal activities to get confused with a stall condition.
  #6   Spotlight this post!  
Unread 07-03-2013, 16:22
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Stall detection

Assuming I already had an encoder for speed control or monitoring, I would use a low speed threshold and acceleration threshold to declare stall. A rapid deceleration of the wheel combined with a low wheel speed when wheel power is on will correlate to a stalled wheel.

Code:
wheel_speed = rpm_from_sensor();
d_wheel_speed = wheel_speed - wheel_speed_last;
wheel_speed_last = wheel_speed;
wheel_des_on_time++;


if(wheel_speed  < wss_stall_cal_lt && d_wheel_speed < wss_stall_accel_cal && wheel_desired > 0 && wheel_des_on_time > wss_stall_on_cal)
{
wheel_stall = 1;
}
if(0 == wheel_desired)
{
wheel_stall = 0;
wheel_des_on_time = 0;
}
wss_stall_cal_lt is low, probably about 50% normal running speed
wss_stall_accel_cal is a negative number. I would play with it but I would guess something like -12 for a 10ms loop time. This number should be calibrated based on data traces of stalling the wheel and normal free running.
wss_stall_on_cal is probably around 1/2 the time it takes to spin up to full speed measured in loop iterations (this is determined by fixed iteration time).

No normal conditions except firing a frisbee should create significant negative acceleration. The low speed cal prevents the normal firing from tripping it, and the on time cal prevents battery voltage spikes/dips or other startup oddities from tripping it even if you don't think they would produce a large negative acceleration.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #7   Spotlight this post!  
Unread 25-03-2013, 11:18
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
Re: Stall detection

My team wrote a library of common FRC tasks to extend off of WPILib.

We wrote code for Stall Detection in the form of an abstract base class, and implemented it with the CANJaguar interface and Analog Channel (PWMs)

Basically we just measure the voltage diffs of what we want to check for stalling, if it hardly varies than you have a stall.

Our Stallable Class:
https://github.com/FRCTeam1073-TheFo.../Stallable.cpp

CANJaguar Implementation (look at line 14):
https://github.com/FRCTeam1073-TheFo...tCANJaguar.cpp

You're fully welcome to use our code, and I'm more than happy to help adapting it for your purposes if you'd like that.
  #8   Spotlight this post!  
Unread 25-03-2013, 11:45
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Stall detection

Quote:
Originally Posted by evinugur View Post
This class is seriously inefficient. Suggestions:

-You are literally copying each value back an entry in the table with a For loop which is really really inefficient. A more efficient solution while still retaining the table of history would be to use a circular buffer where you set an arbitrary array index as the start and work back from there, looping around at one end to the other. Then, you can move the 'front' of the buffer forward and overwrite the oldest history element each time you sample the value. Then the process of inserting a sample requires only a memory write to a known array index, an increment of the circular buffer index, and a case to wrap it back to 0 at the end.

-It would be significantly more efficient to use a racheting error counter than a large RAM array which you For through each iteration. A racheting error counter woud use a single threshold on the current sample each time you sampled, and a counter of failures. A failure would increment the counter, a success would decrement the counter (limited to 0 and a number above your threshold). A certain counter value would be thresholded to declare stall. The comparison on the sample is only done once per sample (ever), instead of multiple times on the same sample, and the function call to read the stall state only has to perform a comparison on the counter. The reset is also simple, as you just set the counter to 0.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #9   Spotlight this post!  
Unread 26-03-2013, 23:21
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
Re: Stall detection

We have a 700MHz processor. That particular class was written by a freshman who has never programmed prior to her first year of FIRST.

Well it isn't that efficient, I never proclaimed it to be (just easy to integrate into a pre-existing project). We've never actually run into any performance issues with it, and honestly, it works, right? (reason why we used a for loop was actually to teach her a for loop)

It definitely can be improved, but during build season my team has more important things to worry about. And let's be honest here, I don't think any practical application of a cRio for FRC really pushes the processor to its bounds...
  #10   Spotlight this post!  
Unread 27-03-2013, 10:03
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Stall detection

I have seen the 400mhz PowerPC pushed to its bounds by many teams. Lots of bad things happen when nearing CPU bandwidth limits, the first things is the LV bootloader stops working (many LV teams know of the 'no-app' switch for this reason). Then, tasks will start jittering and low priority tasks will start missing or be very late, and eventually all of the timing gets so bad that nothing is usable.

I agree that we shouldn't be running up near the limits of a 400mhz PowerPC but many teams are.

A lot of this has to do with horribly inefficient code in the WPIlib, massively inefficient algorithm design, and too many layers of execution. The nature of the LV execution system for LV teams is also a huge contributor to CPU loading, as it optimizes and builds code in a way that might seem strange to OO or procedural programmers. It makes a lot of sense for LV, but the WPIlib and framework is written in a way that seriously hurts LV optimization and fast execution.

I am also generally an opponent of the For loop in embedded software. Unlike the Goto they do occasionally have a use, but they are almost always the wrong answer.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #11   Spotlight this post!  
Unread 02-04-2013, 09:53
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 577
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: Stall detection

I wouldn't get too worried about the perf of that particular for loop, since the array only has three elements. It's very possible the compiler unrolls that loop anyways.

In an FRC robot, big picture choices like your vision processing strategy will have a much, much bigger impact on CPU utilization than tuning a small loop.
  #12   Spotlight this post!  
Unread 02-04-2013, 11:19
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Stall detection

Quote:
Originally Posted by apalrd View Post
Unlike the Goto they do occasionally have a use.
Reminded me of this...
Attached Thumbnails
Click image for larger version

Name:	cover.jpg
Views:	38
Size:	70.5 KB
ID:	14506  Click image for larger version

Name:	p65.jpg
Views:	49
Size:	116.3 KB
ID:	14507  Click image for larger version

Name:	p66.jpg
Views:	52
Size:	94.6 KB
ID:	14508  
  #13   Spotlight this post!  
Unread 25-03-2013, 11:45
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Stall detection

Quote:
Originally Posted by apalrd View Post
Assuming I already had an encoder for speed control or monitoring, I would use a low speed threshold and acceleration threshold to declare stall. A rapid deceleration of the wheel combined with a low wheel speed when wheel power is on will correlate to a stalled wheel.
That's what we're doing. Although we did not have it implemented in Orlando when we smoked our shooter with a jam, in an early qualifier match

Those accel/decel calcs from encoders will likely need a bit of filtering.

Thanks,
Eric
__________________

Don't PANIC!
S. P. A. M.
  #14   Spotlight this post!  
Unread 26-03-2013, 22:55
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Stall detection

Easiest way I can think of fixing that is to use a current sensor. As per the rules it has to be low impedance. The one we used this year was: https://www.sparkfun.com/products/9028. There is also a 45amp version.

As for implementation: in Java we simply set it up as an AnalogButton that called a StopMotor command when it hit a current higher than a set amount. (We are also planning to re-implement that for if it jumps a certain amount, aka current spike, even if its low current to start with).
__________________
Programmer - A creature known for converting Caffeine into Code.
Studying Computer Science @ Louisiana Tech University
Associate Consultant @ Fenway Group

2012-13: 3946 - Head of Programming, Electrical and Web
2014 - 3468 - Programming Mentor
2015 - Present - Lurker
  #15   Spotlight this post!  
Unread 26-03-2013, 23:09
tr6scott's Avatar
tr6scott tr6scott is offline
Um, I smell Motor!
AKA: Scott McBride
FRC #2137 (TORC)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2005
Location: Oxford, MI
Posts: 515
tr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond repute
Re: Stall detection

Seeing we jam after we shoot, and we shoot when the rpm of the wheel is 5% of the target speed, we condition the jam detection that we have shot, and the wheel encoder is less than 150 rpm. Only allowing to detect when you shoot, masks all of the startup issues.

After the jam is detected, we reverse our flipper motor and shooter wheel. The flipper motor will retrip the home photoeye, and stop the shoot routine. The shooter wheel is run reverse at full power for 1.5 seconds, then allowed go back to normal shoot mode.

Code works, we will test at Livonia in a couple of days if it actually can correct a jam condition.
__________________
The sooner we get behind schedule, the more time we have to catch up.

Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi