Go to Post OMG this topic again. Those who stir the pot should lick the spoon. - nuggetsyl [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-04-2013, 22:35
Vikingtech2054's Avatar
Vikingtech2054 Vikingtech2054 is offline
Registered User
FRC #5162 (The Big Red Theory)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Big Rapids, MI
Posts: 86
Vikingtech2054 is an unknown quantity at this point
Question about encoders to control motor

Our team is competing this weekend at the Michigan State Championship, i have been the programmer for about the last two years and i look to improve our shooter. The way we control the speed of the shooter is working well but we look to improve it by adding an encoder. I have played around with encoders on an old robot i had played with them and understand how they work. Although i need help using the rpm from the encoder to control the shooter speed
I currently use Labview as a programming language
What i am looking for is an example or VI that will automatically adjust the speed of the shooter to the desired rpm by using the information from the encoder. (if its going fast enough or to fast). I have looked at some of the PID Vi's but i cant seem to find one that will work for the application im looking for. If you can help me or give me an example how to use the encoder to control the shooter that would be great. Thanks
__________________
Ferris State University-Manufacturing Engineering (BS)

FRC 2054: Student 2010-2013
FTC 6283: Mentor 2012-????
FTC 5980: Mentor 2012-????
FTC 7837: Mentor 2013-????
FRC 2054: Mentor 2013-????
FRC 5162: Mentor 2014-????
FRC 5448: Mentor 2016-????
FRC 5576: Mentor 2015
  #2   Spotlight this post!  
Unread 09-04-2013, 22:43
nicholsjj's Avatar
nicholsjj nicholsjj is offline
Registered User
AKA: John Nichols
no team (Devil Bots)
Team Role: Coach
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Murpyhsboro, IL.
Posts: 261
nicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant futurenicholsjj has a brilliant future
Re: Question about encoders to control motor

I admire your passion for continuing to work on your code, but a word of caution is sometimes don't over-complicate things. I am directing you to this thread http://www.chiefdelphi.com/forums/sh...ight=Bang-bang to get started. It should get your feet off the ground. Know that your team has won two Michigan District Events so be careful when revamping code.
__________________
2011-FRC Team 3862, Team Captain
2012-FRC Team 3862, Strategy Mentor
2013-FRC Team 3885, Programming Mentor, Razorback Regional, Curie Inspector
2014- FRC Team 3885, Programming Mentor, Arkansas Regional, Newton inspector
2015-??? Teacher Murphysboro High School


“They call it coaching but it is teaching. You do not just tell them…you show them the reasons.”- V. Lombardi

  #3   Spotlight this post!  
Unread 09-04-2013, 22:47
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Question about encoders to control motor

We use a bang-bang controller very successfully. It is very simple:

1) decide on the RPM you want for your shooter. Let's call it DesiredRPM.

2) You have the RPM from your encoder. Call it ActualRPM.

3) Implement your LabVIEW code as follows:

if (ActualRPM < DesiredRPM)
MotorOutput = 1.0;
else
MotorOutput = 0;

The keys to this working well are:

1) Do NOT filter or use averaging of your RPM reading from your encoder.

2) Run it in the fast loop. We do it in a 30 ms loop and we get good results.

If you have any questions or want any help with setting it up or testing, come find me in our pit on Wednesday evening. I won't be at the competition during the day on Thursday and Friday (I'll be at work).
__________________
-
An ounce of perception is worth a pound of obscure.
  #4   Spotlight this post!  
Unread 09-04-2013, 22:58
gluxon's Avatar
gluxon gluxon is offline
\n
AKA: Brandon Cheng
FRC #0178 (The 2nd Law Enforcers)
Team Role: Leadership
 
Join Date: Apr 2012
Rookie Year: 2011
Location: Connecticut
Posts: 65
gluxon has a spectacular aura aboutgluxon has a spectacular aura aboutgluxon has a spectacular aura about
Re: Question about encoders to control motor

Quote:
Originally Posted by Chris Hibner View Post
We use a bang-bang controller very successfully. It is very simple:

1) decide on the RPM you want for your shooter. Let's call it DesiredRPM.

2) You have the RPM from your encoder. Call it ActualRPM.

3) Implement your LabVIEW code as follows:

if (ActualRPM < DesiredRPM)
MotorOutput = 1.0;
else
MotorOutput = 0;

The keys to this working well are:

1) Do NOT filter or use averaging of your RPM reading from your encoder.

2) Run it in the fast loop. We do it in a 30 ms loop and we get good results.

If you have any questions or want any help with setting it up or testing, come find me in our pit on Wednesday evening. I won't be at the competition during the day on Thursday and Friday (I'll be at work).
This particular algorithm scares me a bit. Did your robot shooter motors have issues handling the stress of constantly reversing its rotation?
  #5   Spotlight this post!  
Unread 09-04-2013, 23:09
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Question about encoders to control motor

Quote:
Originally Posted by Vikingtech2054 View Post
...I have played around with encoders on an old robot i had played with them and understand how they work. Although i need help using the rpm from the encoder to control the shooter speed
I currently use Labview as a programming language
What i am looking for is an example or VI that will automatically adjust the speed of the shooter to the desired rpm by using the information from the encoder. (if its going fast enough or to fast)... If you can help me or give me an example how to use the encoder to control the shooter that would be great. Thanks
First things first:

- What model encoder are you using?

- What motor(s) are you using?

- What motor controller(s) are you using?

- What is the gear ratio from your motor output shaft to the shooter wheel?

- Where is you encoder mounted? (i.e. is it measuring the motor output shaft speed, or the wheel speed, or something in-between)

- How are you decoding the raw signal from the encoder? (i.e. do you have it set up as a counter or an encoder, and are you reading counts or period)

- What is your desired shooter wheel speed (aka "setpoint")

Answering those questions will improve your chances of getting correct advice.


  #6   Spotlight this post!  
Unread 09-04-2013, 23:10
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Question about encoders to control motor

Quote:
Originally Posted by gluxon View Post
Did your robot shooter motors have issues handling the stress of constantly reversing its rotation?
What do you mean by "constantly reversing its rotation" ?


  #7   Spotlight this post!  
Unread 09-04-2013, 23:16
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,384
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Question about encoders to control motor

Quote:
Originally Posted by gluxon View Post
This particular algorithm scares me a bit. Did your robot shooter motors have issues handling the stress of constantly reversing its rotation?
This is classic Bang-Bang. Full power forward or coast. That's it. No reversing in that code at all.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #8   Spotlight this post!  
Unread 09-04-2013, 23:16
friskywombat's Avatar
friskywombat friskywombat is offline
Registered User
AKA: Ben Berry
FRC #2468 (Team Appreciate)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Austin, Texas
Posts: 8
friskywombat is an unknown quantity at this point
Re: Question about encoders to control motor

We use bang-bang on our shooter wheel, and it's working pretty amazingly. But instead of an encoder, we have an optical sensor that is rigged as a digital signal, and set up as a Counter object in LabVIEW. We have the code running every 5 milliseconds in one of LabVIEW's timed loops. The motor speeds back up to our desired RPM very quickly after a dropoff, and there is only a little oscillation when it reaches the RPM (not enough to affect the shot, even at full court). And Gluxon, we haven't had any problems with our CIM or Jaguar, even running the algorithm at 200 Hz.
__________________

2013 Alamo Regional Champions (with 4063 & 2789)
-Engineering Excellence Award
2013 Hub City Regional Semifinalists (with 4694 & 1750)
-Chairman's Award
2012 Dallas West Regional Finalists (with 1429 & 4045)
-Entrepreneurship Award
2012 Alamo Regional Quarterfinalists (with 245 & 2969)
-Judge's Award
  #9   Spotlight this post!  
Unread 09-04-2013, 23:24
gluxon's Avatar
gluxon gluxon is offline
\n
AKA: Brandon Cheng
FRC #0178 (The 2nd Law Enforcers)
Team Role: Leadership
 
Join Date: Apr 2012
Rookie Year: 2011
Location: Connecticut
Posts: 65
gluxon has a spectacular aura aboutgluxon has a spectacular aura aboutgluxon has a spectacular aura about
Re: Question about encoders to control motor

Quote:
Originally Posted by billbo911 View Post
This is classic Bang-Bang. Full power forward or coast. That's it. No reversing in that code at all.
I had a brain hiccup while reading that code. Last time I worked on robot code, it was with a servo motor where 0 was backwards, 1 was full forward, and 0.5 was stop (weird, yes). Either way, that code is stopping and starting the motor at what I would guess to be a very high rate. I'd imagine some mechanical stress depending on the motor used, no?
  #10   Spotlight this post!  
Unread 09-04-2013, 23:33
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Question about encoders to control motor

Quote:
Originally Posted by gluxon View Post
This particular algorithm scares me a bit. Did your robot shooter motors have issues handling the stress of constantly reversing its rotation?
If you have your speed controller jumpered into coast mode (there's a jumper labeled "BC" for brake/coast), you shouldn't be stressing anything. I implemented a Bang-Bang controller on last year's shooter wheel for testing, and made some very scary-sounding repeated thunks from the wheel, but I think that was a chain re-engaging more than anything. We didn't go for a Bang-Bang this season, instead opting for a PID controller. It has worked quite well, but it required some significant tuning. At our last competition, we retuned the controller a little, and shortened our initial spin-up time by about a second. We might be retuning it a bit this weekend as well. We'll see.
__________________
I code stuff.
  #11   Spotlight this post!  
Unread 09-04-2013, 23:34
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Question about encoders to control motor

Quote:
Originally Posted by gluxon View Post
that code is stopping and starting the motor at what I would guess to be a very high rate.
The higher the rate, the better. The inertia of the wheel keeps the wheel speed steady in between command updates.

It's not starting and stopping. It's starting and coasting. One of the requirements of using bang-bang is that the motor controller jumper must be in the "coast" position.


Quote:
I'd imagine some mechanical stress depending on the motor used, no?
It might, if there is excessive mechanical free play between the motor shaft and the wheel. That's why I asked all those questions. Bang-bang works remarkably well, if you have the right mechanical design for it.


  #12   Spotlight this post!  
Unread 09-04-2013, 23:37
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Question about encoders to control motor

Quote:
Originally Posted by friskywombat View Post
We use bang-bang on our shooter wheel, and it's working pretty amazingly. But instead of an encoder, we have an optical sensor that is rigged as a digital signal, and set up as a Counter object in LabVIEW. We have the code running every 5 milliseconds in one of LabVIEW's timed loops. The motor speeds back up to our desired RPM very quickly after a dropoff, and there is only a little oscillation when it reaches the RPM.
Check to make sure your Jags are not jumpered for voltage ramping.


  #13   Spotlight this post!  
Unread 09-04-2013, 23:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Question about encoders to control motor

Quote:
Originally Posted by Ginto8 View Post
I implemented a Bang-Bang controller on last year's shooter wheel for testing, and made some very scary-sounding repeated thunks from the wheel, but I think that was a chain re-engaging more than anything.
Mechanical free play and bang-bang sometimes don't go together very well. Direct coupling of motor shaft to shooter wheel is more amenable to bang-bang control.


  #14   Spotlight this post!  
Unread 09-04-2013, 23:44
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Question about encoders to control motor

I'm not much help with Labview code specifically, but I can help you setup the control and explain the bang-bang controller to you a bit at MSC if you want some help. Just swing by our pit and ask for Joe.
  #15   Spotlight this post!  
Unread 09-04-2013, 23:48
Woolly's Avatar
Woolly Woolly is offline
Programming Mentor
AKA: Dillon Woollums
FRC #1806 (S.W.A.T.)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Springfield, MO
Posts: 512
Woolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond repute
Re: Question about encoders to control motor

Quote:
Originally Posted by Ether View Post
Mechanical free play and bang-bang sometimes don't go together very well. Direct coupling of motor shaft to shooter wheel is more amenable to bang-bang control.


Yeah, the belt on our robot's shooter doesn't exactly like slamming between coast and full power. However the feed-forward we're doing is giving us rpm control that stays within ~10 RPM of the set-point, without being hard on the belt.
__________________


Team 1806 Student: 2012-2013 | Mentor: 2013-Present
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:34.

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