![]() |
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.
|
Re: High Speed Encoder Problem
How are you calculating the rate? Are you using WPILib?
|
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.
|
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? |
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. |
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. |
Re: High Speed Encoder Problem
Quote:
http://www.chiefdelphi.com/forums/sh...4&postcount=37 |
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.
|
Re: High Speed Encoder Problem
Quote:
I thought about an average value too, but our programmers don't know how to implement that. |
Re: High Speed Encoder Problem
Quote:
|
Re: High Speed Encoder Problem
Quote:
|
Re: High Speed Encoder Problem
Quote:
|
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 |
Re: High Speed Encoder Problem
Quote:
|
Re: High Speed Encoder Problem
Quote:
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. |
Re: High Speed Encoder Problem
Quote:
Does the FMS follow the user's DS, or is it designed to send TeleOp packets at 20ms ? And even if it is designed to send at 20ms (rather than following the user's DS), I guess the problem would still exist, albeit perhaps in a slightly different form, yes? no? still thinking about it. |
Re: High Speed Encoder Problem
At competition the DS packets are still sent by the DS.
FMS only orders the DS to change modes, but the DS has to send that command to the robot. Any slow down in the DS PC will delay packets. One of the checks for slow or lost packets is the CPU utilization on the DS. (If in the Classmate Driver acct. use: CTRL-Shift-Esc -> Performance) A saturated netbook can be a cause of lost and delayed packets. I see that pretty often. |
Re: High Speed Encoder Problem
Quote:
We use C++. There is a configuration variable that sets the periodic rate. If it is zero then the rate will follow the driver station. If it is not zero then the value entered will be the periodic rate. I tell our programmers to ALWAYS set the rate. We have not settled on a value for this year yet. We use a scope to be sure all of our traffic on the CAN bus is complete. This is detailed in other threads as you know. As best I know FMS does not fiddle with this. Last year we used 100 msec and would show up on FMS as a long ping time. A few times the FTA would tell us about it, but it didn't seem to be a problem. I have some photos of the FMS screen showing this. I will try to find them and post here, but this season has been very busy, so don't hold your breath. :-) Maybe we should start a new thread about this? -Hugh |
Re: High Speed Encoder Problem
Quote:
So Hugh's comment about DS packet timing variations caused by Windows scheduling of the DS applies equally at home and at competition. |
Re: High Speed Encoder Problem
Quote:
What is the class.method that you call to set this? Is it available in Java? |
Re: High Speed Encoder Problem
Quote:
EDIT: Here's the link: http://www.chiefdelphi.com/forums/sh...d.php?t=103676 |
Re: High Speed Encoder Problem
Quote:
With our recent encoder issue (sorry I don't know how to link to it)... I tried using the blend, but found that it would introduce latency when it is tuned too high. I prefer this over averaging though, but the real winner is the Kalman filter... that one gave good enough results without the latency. And latency makes it much more difficult to tune the PID. (Especially to someone who has not yet mastered the skill of it yet). |
Re: High Speed Encoder Problem
We have a similar filter in our library but we called it MovingAverage filter. In a sense, it is averaging the last N points.
Code:
/* |
Re: High Speed Encoder Problem
Quote:
As you've shown, it's identical to what was posted earlier. |
Re: High Speed Encoder Problem
You are right, it does carry the history of all pass data points.
|
Re: High Speed Encoder Problem
Here is the Kalman Filter:
Code:
/***********************************************************************************************************/ |
Re: High Speed Encoder Problem
the problem is the time between updates can vary. In our c++ program we execute every 20 to 100 millisec. That means if we were doing the count divided by time there could be a 1-5 range of counts. The best thing to do is get the period of the last cycle. That will be in seconds and will not depend on the cycle time of the calls to the actual program.
For those with good control they used a a custom painted code wheel with one or three cycles to get the longest possible period with the highest quality of timer counts to calculate the speed. |
Re: High Speed Encoder Problem
1 Attachment(s)
Quote:
Wow 20-100 ms... what are you guys processing (video imaging?) ;) Anyhow... it should not matter if you have uneven time delta's as the rate will still work out correctly. Now then our problem is a bit unique in that using the GetDistance() technique... the actual pulses got updated irratically where 1 out of every 3 iterations it would update. I suspect this is because we used 4x setting, and I'll need to test with 1x or 2x to see if this behavior changes. Fortunately, our last years robot produces a fluent rate as I'd expect. In which case dividing by time works really well. Check out this Encoder Test attachment... l1 = left wheels using GetRate(), l2=left wheels using GetDistance(). The r1 and r2 same for the right side. As you can see these are virtually identical, as these units are in RPS. The iteration intervals are around 10-11 ms, but it wouldn't matter what their size is as the rate would still be the same. |
Re: High Speed Encoder Problem
Quote:
We ran into a stroke of luck tonight to find the ROOT cause of a similar problem. This can be best explained like so: Our shooter was not quite aligned for some time, and as it hit those higher speeds the vibrations of the casing were so intense that it cracked the casing around the encoder... the little wheel inside the encoder started to roll around inside its own casing as such where during certain intervals it briefly lost connection and did not deliver the pulse counts. When I say brief, I mean about 3 iterations per 10 where each iteration ran about 10-11ms. We fixed the damage the best we could with electrical tape, and ensured the wheel inside kept constant contact. It was interesting how we found this problem by sheer luck... as we just happened to press against it while I was reading the dump, and saw the numbers looking much better during the period it was touched. Hope this helps. |
| All times are GMT -5. The time now is 05:55. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi