Go to Post Don’t choose your hero because they will just teach you with their abilities, but also because they will also teach you with their mistakes. - Ken Leung [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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 22-02-2012, 18:04
Mr. Rogers's Avatar
Mr. Rogers Mr. Rogers is offline
That? That was in the CAD.
FRC #3539 (Byting Bulldogs)
Team Role: College Student
 
Join Date: Apr 2011
Rookie Year: 2011
Location: Romeo, MI
Posts: 67
Mr. Rogers will become famous soon enoughMr. Rogers will become famous soon enough
High Speed Encoder Problem

Hey, we have a 128 click encoder for our shooter speed. Our java programmers managed to get an encoder velocity, but it updates constantly and is all over the place, it ranges +/- 1000 clicks per second when we run a constant speed on the shooter motors, any way to clean up the "noise," if that's the problem. Thanks.
__________________
Grow the roses of success!
2011 Archimedes 2nd seed,
2011 Waterford Champion, 2011 Troy Simi-Finalist,
2011 Waterford Rookie all star, 2011 Troy Rookie all star
http://www.bytingbulldogs.com/
  #2   Spotlight this post!  
Unread 22-02-2012, 18:05
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 847
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
Re: High Speed Encoder Problem

How are you calculating the rate? Are you using WPILib?
__________________
  #3   Spotlight this post!  
Unread 22-02-2012, 18:10
Mr. Rogers's Avatar
Mr. Rogers Mr. Rogers is offline
That? That was in the CAD.
FRC #3539 (Byting Bulldogs)
Team Role: College Student
 
Join Date: Apr 2011
Rookie Year: 2011
Location: Romeo, MI
Posts: 67
Mr. Rogers will become famous soon enoughMr. Rogers will become famous soon enough
Re: High Speed Encoder Problem

It that a lab view feature? We're using a pre-made java class from the 2012 API. It has a " .getRate() " that returns the angular velocity.
__________________
Grow the roses of success!
2011 Archimedes 2nd seed,
2011 Waterford Champion, 2011 Troy Simi-Finalist,
2011 Waterford Rookie all star, 2011 Troy Rookie all star
http://www.bytingbulldogs.com/
  #4   Spotlight this post!  
Unread 22-02-2012, 18:14
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 847
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
Re: High Speed Encoder Problem

WPILib is basically the whole thing. I think encoder.getRate() works by reading the number of encoder counts from the FPGA and then dividing by the time elapsed between readings. As your RPMs increase, your noise will increase. Have you tried a moving average?

1000 ticks per second is actually pretty darn slow. That equates to about 470rpm. Is that the speed you're looking for?
__________________
  #5   Spotlight this post!  
Unread 22-02-2012, 18:15
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,554
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: High Speed Encoder Problem

That's the encoder we gave you .

The getrate from the library is an instananeous rate. You'll be better off using the 'get count' function, and then measureing the time between loop updates like this:

(New count - old count ) / loop time

If that ends up still being noisy, you can average, or calculate over more than one loop. Also, make sure you're running in single sample mode rather than 4x to remove phase errors.
  #6   Spotlight this post!  
Unread 22-02-2012, 18:44
kenavt's Avatar
kenavt kenavt is offline
Registered User
AKA: Colin S
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Ann Arbor
Posts: 253
kenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond repute
Re: High Speed Encoder Problem

Here's some more info on the data behind the .getRate() method and the equivalent LabVIEW and C++ functions.

http://www.chiefdelphi.com/forums/sh...d.php?t=101485

As you can see, it requires some processing to smooth out the output. Tom recommended a good alternative and a quick way to smooth out the getRate() output.
__________________
University of Michigan Computer Engineering '17

FRC 2337 student alumni (2010-2013)
  #7   Spotlight this post!  
Unread 22-02-2012, 18:49
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: High Speed Encoder Problem

Quote:
Originally Posted by kenavt View Post
Here's some more info on the data behind the .getRate() method and the equivalent LabVIEW and C++ functions.

http://www.chiefdelphi.com/forums/sh...d.php?t=101485

As you can see, it requires some processing to smooth out the output. Tom recommended a good alternative and a quick way to smooth out the getRate() output.
IIR and FIR filter options explained here:
http://www.chiefdelphi.com/forums/sh...4&postcount=37


  #8   Spotlight this post!  
Unread 22-02-2012, 19:00
Hawiian Cadder's Avatar
Hawiian Cadder Hawiian Cadder is offline
Registered User
AKA: Isaak
FRC #0159 (Alpine Robotics)
Team Role: CAD
 
Join Date: Feb 2010
Rookie Year: 2003
Location: Fort Colins Colorado
Posts: 573
Hawiian Cadder is a name known to allHawiian Cadder is a name known to allHawiian Cadder is a name known to allHawiian Cadder is a name known to allHawiian Cadder is a name known to allHawiian Cadder is a name known to all
Re: High Speed Encoder Problem

Are you sure that your encoder will track that fast? We are making a custom disk for an encoder with only 3 Clicks per rotation to ensure velocity accuracy.
  #9   Spotlight this post!  
Unread 22-02-2012, 19:06
Mr. Rogers's Avatar
Mr. Rogers Mr. Rogers is offline
That? That was in the CAD.
FRC #3539 (Byting Bulldogs)
Team Role: College Student
 
Join Date: Apr 2011
Rookie Year: 2011
Location: Romeo, MI
Posts: 67
Mr. Rogers will become famous soon enoughMr. Rogers will become famous soon enough
Re: High Speed Encoder Problem

Quote:
Originally Posted by Tom Line View Post
That's the encoder we gave you .
Yeah.
I thought about an average value too, but our programmers don't know how to implement that.
__________________
Grow the roses of success!
2011 Archimedes 2nd seed,
2011 Waterford Champion, 2011 Troy Simi-Finalist,
2011 Waterford Rookie all star, 2011 Troy Rookie all star
http://www.bytingbulldogs.com/
  #10   Spotlight this post!  
Unread 22-02-2012, 19:09
Mr. Rogers's Avatar
Mr. Rogers Mr. Rogers is offline
That? That was in the CAD.
FRC #3539 (Byting Bulldogs)
Team Role: College Student
 
Join Date: Apr 2011
Rookie Year: 2011
Location: Romeo, MI
Posts: 67
Mr. Rogers will become famous soon enoughMr. Rogers will become famous soon enough
Re: High Speed Encoder Problem

Quote:
Originally Posted by Tom Line View Post

If that ends up still being noisy, you can average, or calculate over more than one loop. Also, make sure you're running in single sample mode rather than 4x to remove phase errors.
Yeah, I was wondering if we could do that. All the java classes for encoder need an A and B channel. Could we just sample pulses from one digital port and compare it against the code's timer????
__________________
Grow the roses of success!
2011 Archimedes 2nd seed,
2011 Waterford Champion, 2011 Troy Simi-Finalist,
2011 Waterford Rookie all star, 2011 Troy Rookie all star
http://www.bytingbulldogs.com/
  #11   Spotlight this post!  
Unread 22-02-2012, 19:25
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: High Speed Encoder Problem

Quote:
Originally Posted by Mr. Rogers View Post
Yeah, I was wondering if we could do that. All the java classes for encoder need an A and B channel. Could we just sample pulses from one digital port and compare it against the code's timer????
Yes, but with the Counter class instead of the Encoder class.


  #12   Spotlight this post!  
Unread 22-02-2012, 19:28
Mr. Rogers's Avatar
Mr. Rogers Mr. Rogers is offline
That? That was in the CAD.
FRC #3539 (Byting Bulldogs)
Team Role: College Student
 
Join Date: Apr 2011
Rookie Year: 2011
Location: Romeo, MI
Posts: 67
Mr. Rogers will become famous soon enoughMr. Rogers will become famous soon enough
Re: High Speed Encoder Problem

Quote:
Originally Posted by Ether View Post
Yes, but with the Counter class instead of the Encoder class.


Perfect, Thanks.
__________________
Grow the roses of success!
2011 Archimedes 2nd seed,
2011 Waterford Champion, 2011 Troy Simi-Finalist,
2011 Waterford Rookie all star, 2011 Troy Rookie all star
http://www.bytingbulldogs.com/
  #13   Spotlight this post!  
Unread 22-02-2012, 19:28
Hugh Meyer's Avatar
Hugh Meyer Hugh Meyer is offline
Registered User
FRC #1741 (Red Alert Robotics)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Greenwood Indiana
Posts: 158
Hugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud of
Re: High Speed Encoder Problem

The periodic rate can be controlled either by a fixed value or follow the driver station. If it is set to follow the driver station, which is the default, then the period time will vary because of being a windows app. If you set the period to a specific value the cRIO will maintain a very precise periodic rate. This could also be a source of your problem.

-Hugh
  #14   Spotlight this post!  
Unread 22-02-2012, 19:35
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: High Speed Encoder Problem

Quote:
Originally Posted by Hugh Meyer View Post
The periodic rate can be controlled either by a fixed value or follow the driver station. If it is set to follow the driver station, which is the default, then the period time will vary because of being a windows app. If you set the period to a specific value the cRIO will maintain a very precise periodic rate. This could also be a source of your problem.

-Hugh
... or you could read the actual elapsed time since the last sample, rather than assuming it is 20ms.


  #15   Spotlight this post!  
Unread 22-02-2012, 20:00
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: High Speed Encoder Problem

Quote:
Originally Posted by Mr. Rogers View Post
I thought about an average value too, but our programmers don't know how to implement that.
If you use an infinite impulse response filter, it is very simple to do:

new_filtered_value = K*previous_filtered_value + (1-K)* new_sample

... that's all there is to it.

"K" is a tuning constant, which you use to adjust the "strength" of the filter. K must be in the range zero to +1. When K=0, there is no filtering. When K=1, the filtering is so "strong" that the filtered value never changes.



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 19:54.

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