Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   High Speed Encoder Problem (http://www.chiefdelphi.com/forums/showthread.php?t=103631)

Mr. Rogers 22-02-2012 18:04

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.

Ty Tremblay 22-02-2012 18:05

Re: High Speed Encoder Problem
 
How are you calculating the rate? Are you using WPILib?

Mr. Rogers 22-02-2012 18:10

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.

Ty Tremblay 22-02-2012 18:14

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?

Tom Line 22-02-2012 18:15

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.

kenavt 22-02-2012 18:44

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.

Ether 22-02-2012 18:49

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by kenavt (Post 1132884)
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



Hawiian Cadder 22-02-2012 19:00

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.

Mr. Rogers 22-02-2012 19:06

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by Tom Line (Post 1132868)
That's the encoder we gave you :) .

Yeah. :rolleyes: :rolleyes:
I thought about an average value too, but our programmers don't know how to implement that.

Mr. Rogers 22-02-2012 19:09

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by Tom Line (Post 1132868)

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????

Ether 22-02-2012 19:25

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by Mr. Rogers (Post 1132900)
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.



Mr. Rogers 22-02-2012 19:28

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by Ether (Post 1132912)
Yes, but with the Counter class instead of the Encoder class.



Perfect, Thanks.:)

Hugh Meyer 22-02-2012 19:28

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

Ether 22-02-2012 19:35

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by Hugh Meyer (Post 1132914)
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.



Ether 22-02-2012 20:00

Re: High Speed Encoder Problem
 
Quote:

Originally Posted by Mr. Rogers (Post 1132897)
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.





All times are GMT -5. The time now is 11:10.

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