![]() |
High speed encoder with slotted / flat end... can't find one.
We've got fairly tight requirements. In order to improve our shooter, we're increasing the number of counts our encoder returns.
Right now we have a bourns 128 count with 1/4 slotted shaft input. What we're looking for is a 512 count with 1/4 slotted shaft input at reasonable cost. With 128 counts per revolution, we see around 7000 counts per second. 512 gets up to 28,000 or so per second. My understanding is that 40,000 per second is the cRio's limit, so I'm happy getting to 3/4 of it. Also note that the encoder will have to be fairly robust to handle the speeds (3000 rpm+) that our shooter runs. We've looked but can't find something in stock that meets these requirements. Does anyone else have an off-the-shelf idea? I understand we could gear the encoder we have now upwards to get the appropriate counts, but we direct drive the encoder to minimize noise and would like to stay that way. We don't have the ability for a drop-over or code wheel style encoder due to mounting real-estate. |
Re: High speed encoder with slotted / flat end... can't find one.
Does it have to have a slotted or flat end?
If it is okay, I've used both the S1 and S5 encoders before from us digital. Your method of calculating and/or filtering velocity could possibly have a much larger impact on control (we ran a 6-tick encoder all season), curious, what are you currently doing? I certainly agree with your logic that more resolution is better though (we're switching to a higher count encoder at IRI for the same reason). |
Re: High speed encoder with slotted / flat end... can't find one.
We are using the S5 encoder at 32 CPR. It has worked fine all year for us. Only problem we had was when testing different wheels/coatings we ended up destroying one after inserting/pulling it out of a tight hole in the shooter shaft about 25 times, which is pretty understandable.
|
Re: High speed encoder with slotted / flat end... can't find one.
we have our shooter logic in a 10 ms timed loop (not a waited loop).
We calculate the rate based on 3 loops worth of data. Each loop we drop the oldest data point and add a new one. Then we average those 3 loops of data and send that into our velocity PID as our actual speed. (I suppose, looking at this now, we really should just be looking at the rate over 9 loops or 90ms, and get rid of the average. It's a bit redundent. For our 'enable to shoot' logic, we use an 8 sample average of rate fed into an IIR filter with a .5 constant. Please, feel free to tell us what we can improve =). I'm an mechanical engineer masquerading as a controls engineer, and systems engineering was always one of my most hated classes :lol: |
Re: High speed encoder with slotted / flat end... can't find one.
Are you using 4x sampling to get the max from your Bourns?
The quoted CPR is based on using only one of the following: 1) rising edge ACounting each and every one of them gives you 512 ticks per revolution with a "128cpr" encoder. |
Re: High speed encoder with slotted / flat end... can't find one.
We're using a 50CPR US Digital S5 encoder. We switched over to this from the S4's based on recommendation from our friends on the Poofs. We are extremely happy with the S5 (particularly the ball bearing version), and will only be using that encoder for applications similar to our shooter wheel in the future.
-Brando |
Re: High speed encoder with slotted / flat end... can't find one.
If you use 4x sampling and you're not using C++, be aware of this: http://www.chiefdelphi.com/forums/sh....php?p=1122730 |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Given a 128 CPR encoder running at approx 3280 rpm (per post#1), there will be approx 70 counts every 10 ms. If a 10ms timed loop is used and the rate is computed by reading the raw sample count and dividing by sample time, a 1-count jitter will equal approx 1/70 of 3280, or 47rpm jitter. Using this processing method and decoding at 4x instead of 1x should reduce the jitter, although perhaps not by a factor of 4 (because of the tolerances of the edge locations). |
Re: High speed encoder with slotted / flat end... can't find one.
What kind of ± resolution on the RPM are you looking to achieve? And at what frequency do you want to know the current RPM of the shooter?
I would suggest creating an Excel document to calculate how various changes to the CPR and sampling time interval affect the resolution of the shooter speed output. Depending on what you are looking for, you may be able to achieve your desired results without hardware changes. For example, with a 128 CPR encoder (and 1x decoding) sampling over a 100ms time interval, you can achieve an RPM resolution of 4.6875rpm per encoder count, while sampling over only a 30ms window yields a resolution of 15.625rpm per encoder count. |
Re: High speed encoder with slotted / flat end... can't find one.
We used a US Digital S5 250CPR, worked great.
-Brian Qty Mfr Part Number Price Description Usage 1 US Digital S5-250-250-NE-S-B $70.65 S5 series, 250 CPR, 1/4" Shaft, No Index, Single Ended, Ball Bearing Shooter RPM |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
That means my rpm may vary from about 2674 to 2619 (single wheel) In retrospect, that means that the 30ms time frame with the 128 encoder we'd been trying to use takes up a huge chunk (30%+) of our tolerance. 5% seems like a more reasonable number. Which means that a 512 count encoder should get us fairly close to having a measurement error of 5% over 30ms. Obviously I'm trying to minimize calculation (delay) time. The fewer cycles required to get an accurate reading means that much less 'lag' between a change in the system and your response to that change. Where is the sweet spot, based on shooter momentum and motor update rate? Heck if I know... |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Quote:
First thing I would like to mention from a previous time is that we had a problem with our encoder where the vibrations of the shooter caused the encoder itself to rupture the casing and then caused it to lose counts at higher speeds as the centripital force of the encoder wheel lost contact during certain phase intervals. We had to tape the outer casing down tight to keep this problem to a minimum, and then needed to use a priority averager to erase this symtom. The priority averager looks like this: Code:
class Priority_AveragerCode:
void KalmanFilter::Reset()And the typical averager Code:
// A templated averager, make sure the type being averaged can handle the +, -, and / functions![]() Where the cyan line is the encoder reading trying to match the magenta ramp velocity. Hope these ideas may help out. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
1 Attachment(s)
It doesn't look like it's holding the final speed very well (see portion circled in red). Do you have a screenshot with a longer time axis showing if it settles out? |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
![]() |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Tom is looking for 2% p-p (2674 to 2619). |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
![]() |
Re: High speed encoder with slotted / flat end... can't find one.
1 Attachment(s)
Quote:
Blue circle: how are you reading the encoder? Are you using WPILib's GetRate, or are you getting raw counts and dividing by the elapsed time since the last sample was taken? If the latter, are you using actual elapsed time (as measured with a microsecond timer) or are you just using the scheduled period of your sampler? If the latter, did you take any measures (like giving it a higher priority) to reduce jitter? |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
I tried both GetRate() preferred, and then the raw counts against a microsecond timer... I believe this one was the GetRate() and both tests look identical (as I did some side-by-side of both method dumps)... where GetRate() did just slightly improve... but not really significant. At slower speeds this noise was not apparent. A part of me thinks this may be a unique problem that this could be a defected encoder... but I can only speculate, and therefore I think it is good to reveal this to the group in case others may have seen something similar. |
Re: High speed encoder with slotted / flat end... can't find one.
Tom,
It sounds like now you're doing a 9 cycle moving average filter now, we found that going to a low pass filter with a gusstimated gain was superior. We had several other performance issues at that time so I can't say for sure that a moving average is poor for flywheel control, but my controls classes would make me think a low pass is far better. We also found that either running in constant time, or compensating for time in all controls calcs increased stability. "Linearizing" the victors helped us a lot too. These three rather simple changes gave us the biggest bang for our buck, and could be implemented/tested with little time/investment. A complete revamp of the control to any number of things would also work, but I aim for the lower hanging fruit. |
Re: High speed encoder with slotted / flat end... can't find one.
Could you also give us more info on your pid loop?
I see you're commanding velocity with pid, are you doing any other math or tricks? Feed forward? Are using p, i and d? There is a lot of potential for poor velocity measurement/filtering, especially when acceleration is calculated for the d term, to cause jitter along the lines of what ether already said. |
Re: High speed encoder with slotted / flat end... can't find one.
All,
We managed to get quite good speed control (1% from the key, slightly more variance at the lower speed fender) using a 4-line code wheel and Banner sensor. We setup the encoder to average 12 samples and used the rate functions of the WPI library (in LabVIEW). We ran the controller to a certain speed and verified it to within a few rpm with a tachometer, the tachometer readings corresponded quite well to the rpm speed measurements in software. We used a feed-forward term as the primary element in the control, with PI (or, it could be thought of as PD with the output integrated) handling the variance and spin up. We had a cap on the max integral value which was limited linearly by the error up to ~300rpm (from memory), at which point the integral would be cut off completely. The controller ran in a 10ms Timed Task at high priority. The feed forward term was calculated by measuring the speed at 25 throttle points, graphing it, and calculating a best fit curve in Excel, although the precision required on some of the terms is high - We didn't get anywhere close to accurate results until we took some of the constants to 10 or more significant digits. If I were to do it again I might come up with a solution that also considered battery voltage, but the I term can deal with battery voltage issues well enough down to around 11v or so, and we don't shoot while moving, so the battery is never that low when shooting. We attempted a controller without a feed-forward term, using PID only, and the results were less than ideal. Since the I term has to wind up to keep a constant velocity, the gain has to be high enough for it to constantly oscillate slightly and never really settle. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
We use P ( essentially I in a positional PID) and D to damp the overshoot. We have a limiter on the P windup (I believe it's 1 and -1). You can also see the code on page 22 in this paper: http://www.chiefdelphi.com/media/papers/2695 |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Would you mind posting the 25 data points? I'd like to play around with it. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
The resulting equation is in the LabVIEW code I posted to CD-Media. The constants are: -4th order = 3.038921E-10 -3rd order = -1.8893034681E-6 -2nd order = 0.003990997414888 -1st order = -2.710486371347 There is no intercept, the equation runs through the origin. The input is the desired speed in RPM, the output is a motor power which is divided by 1000 to produce a pct (0-1 range) number. This equation is obviously only valid with this particular mechanical system. The second order function was similar, but the R/R^2 values weren't quite as good as the 4th order function, so we used the 4th order function. The 3rd order function did not follow the curve very well, and was overall not as good as either the 2nd or 4th order functions. Initially, we scaled the input to 0-1 range, and used the Excel default of two decimal places. The accuracy of this was nowhere near enough, so we scaled the input by 1000 and increased the precision to include many more decimal places (as Excel rounds by decimal places, not significant digits). Looking back, we probably would be OK with as few as 4 digits, but 2 is definitely not enough. |
Re: High speed encoder with slotted / flat end... can't find one.
1 Attachment(s)
Quote:
3.038921E-10*X4 - 1.8893034681E-6*X3 + 0.003990997414888*X2 - 2.710486371347*X ... and got this graph. Are you using just the rightmost part of the graph? Try the following model instead of a polynomial: Y = p1 + p2/(X-p3) You can do that in Excel as explained here. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
The purpose of the feedforward is to anticipate the required steady-state value required. Then you add your closed-loop terms to make the dynamic response acceptable, and to compensate for load and supply voltage variations that were not present when you recorded your feedforward data. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Quote:
(Once I understand this I'm going to finally get the arm working) :) |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
If you are trying to control the position of a turret, just use the position PID provided in the WPILib. Feedforward is not appropriate for a position controller where the load is essentially zero at the target position. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Add our team to the list of those that found using a low count per revolution solution (in our case, two pieces of reflective tape and a 2011 KOP line sensor) and using the built-in getRate() function based on timing consecutive edges performed well (less than 1% p-p variation with a simple low-pass filter). Our design methodology was that if we are only running PID at 200Hz (using a Jaguar), then we want a maximally stable speed measurement every 5 milliseconds. At the speeds our shooter was running at, taking two speed measurements per wheel revolution is very close to this ballpark. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
2 counts per revolution, at a speed of 4000 rpm, nets you 66.67 rps. That's 66.67*2= 133.34 counts per second. That's .6667 counts every 5 ms. So how many loops were accumulating? It seems like 75 - 100 ms would be reasonable to reduce the error of being part-way between counts (+/- 1.5% at 100 ms). So 15-20 loops worth of counts? Something I didn't mention is that we are using a low-pass filter of sorts. We use the labview coerce function and set a max and minimum that limits the amount of change from reading to reading. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
The FPGA has a timer which measures the elapsed time between counts. When you call the GetRate method, the FPGA reports the speed based on that elapsed time, not elapsed time between calls to the function. If the speed is 6000 rpm or higher, you are guaranteed to get a new reading every 5ms, when using a wheel with two counts per rev. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Does that mean that if I were to use getrate with an extremely high-count encoder, the time returned will only be the last two counts it sees? Or does it average between calls? How does getrate calculate the rate? Answer: Correct me if I'm wrong, but a couple posts I just read suggest that the getrate calculation does report only the rate between the last two ticks. In which case, having the longest period between ticks that still gives you new data for each loop would give you the most accurate rate calculation. Am I interpretting this correctly? |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
In the C++ implementation of WPILib (but not the LabVIEW or Java implementations), GetRate does do some averaging in an attempt to reduce the noise, at least according to this post. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Guess I'll figure out our lowest speed tonight and our loop time and determine the lowest count encoder we can use. |
Re: High speed encoder with slotted / flat end... can't find one.
In terms of precision and how wpilib implements them, are getRate and getPeriod comparable?
|
Re: High speed encoder with slotted / flat end... can't find one.
You can configure getRate to tell the FPGA to average a certain number of samples - This is NOT done in the Get Encoder VI, but in a different VI (Counter Set Averaging). You can also set the maximum time between pulses before the counter declares the encoder to be stopped. I believe it sets the time to 0 in that case, which the VI that reads the FPGA register then uses to determine the "Stopped" boolean output, but I don't have the VI in front of me.
We set it to 12 (using a hand made 4-line encoder) and there was very little if any noise. We don't even filter the output and it looks very clean. My current laptop doesn't have WPIlib on it, so I can't read the exact documentation. On a semi-related note, make sure to use Up/Down mode for the counter, and not Semi-Period mode. Semi-Period mode measures the time of either the logical high or logical low pulse (not the time between rising or falling edges), as to read a sensor which outputs a PWM signal, so differences between black and white line size will cause measurement errors in Semi-Period mode (I know the documentation conflicts on this, I have observed this behavior and know it to be true). Edit: All of this applies to LabVIEW. I have not read through any of the other WPIlib's. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Code:
/** |
Re: High speed encoder with slotted / flat end... can't find one.
If using getPeriod or getRate, would the optimal precision be the smallest amount that still guarantees a new data point per cycle of the control loop? Or is this difference likely negligible when compared to other errors in the system?
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Regardless what method you use the read the encoder, it should be mounted so that free play between the encoder and the flywheel is minimized.
|
Re: High speed encoder with slotted / flat end... can't find one.
5 Attachment(s)
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Ether - the method you described of calculating our own rate is the own we switched to when we threw out the getrate because of noisy returns with our high-count counters. Now that I'm comparing the two I wonder which would be more accurate: a 512 count encoder using our own rate calculation, which will potentially lose accuracy based on when the last count happened, or a low encoder count method using the FPGA... how precise is the FPGA's internal timer? |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
There are two (Actually three, only two are exposed) sets of Encoder VI's in LabVIEW: -Encoder (what most people use for Encoders, can be set to 1x,2x,4x decoding, set number of distance per count, etc.) -Counter (what Encoder internally uses for 1x or 2x encoding, can be set in many more ways than Encoder, can set averaging) -There is another module which is not exposed which handles Encoder 4x decoding, it is like Counter but uses a different set of FPGA modules. The FPGA has 8 Counter and 4 Encoder4x modules which can be used. Counter can do 1x or 2x quadrature or single wire, as well as Gear Tooth and PWM input handling. Encoder4x can do 4x quadrature decoding. I have been talking about Counter as the Encoder VI's, since we use Counters directly for our shooter controller. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
" and set a max and minimum that limits the amount of change from reading to reading " The kalman limits the amount of change from reading to reading when noise is introduced. I looked at the labview's definition of coerce and it looks like it is more like the priority averager I showed earlier... from what I can tell. (I do not use labview, so these terms are unfamiliar to me). |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
well that's the question... what exactly did you use? We used GetDistance() which is virtually GetRaw(). I did not see the need for critical sections, so I'd be curious to see how you did this. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
And we use WindRiver... so now I'm wondering if we really did get some averaging features in the WindRiver builds. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
at 4000rpm, a variation of +/-0.13 degree in the absolute location of the edges1 could produce the +/-200 counts/sec jitter you saw when using GetRate. 1 equivalent to +/- 0.26 degree with respect to adjacent edges |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Not trying to be a pest, but what do you mean by "we were taking readings from the chain with a sprocket on the encoder"? Could you post a picture? |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
All: What are teams doing as a better alternative to a chain-driven encoder for the shooter? |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Makes a difference. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Our particular shooter wheel has the end of the shooter wheel shaft drilled out. We then just wrapped the encoder shaft in a layer or two of Teflon tape and inserted the encoder into the shooter shaft. The encoder was mounted to a simple rectangular plate and some standoffs space the encoder off the shooter wheel's mounting plate. -Brando |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
-Using a live axle shooter and connecting the encoder directly to it -Using a live or dead axle shooter with a code wheel and optical sensor (Banner and Rockwell sensors seem to be the most popular) In addition to the vibrations of a chain, I assume the constant modification of output power by the control loop would cause additional jitter if the chain was slightly (or more than slightly) slack, probably more than any other single source of jitter. In our shooter system, I can hear the difference between running the control loop and applying fixed power, especially at low speeds where we're approaching the Victor deadband. The motor is pulsing at a low frequency, and I can hear the gears in the gearbox make nasty noises as they're being driven by the motors, then the motors back off and the inertia of the system drives the output gear faster than the motors, then the motors pick up. It's much less noticeable at high speeds. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
-Parker |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
![]() |
Re: High speed encoder with slotted / flat end... can't find one.
1 Attachment(s)
Quote:
1) You might want to consider converting your large (1+ megabytes) BMP file attachments to a compressed format (PNG would be nice) before uploading. Attached PNG file is 380 times smaller (only 3 kilobytes) than the BMP you posted, with no noticeable decrease in quality 2) 35 revs/sec @ 64 counts/rev = 2240 counts/sec = 22.4 counts/(10 ms), so +/- 1 count should give jitter of approx +/-1/22.4 = +/-4.5%. So I can't draw any conclusion from your graph except that something is not right. |
Re: High speed encoder with slotted / flat end... can't find one.
With regards to the questions about how we were running our encoder in the past: we had a sprocket on the encoder shaft riding against the chain that drove the shooter. The shooter sprocket was smaller than the encoder sprocket by a ratio of 2:1, resulting in 2 turns of the shooter for 1 turn of the encoder.
Since then, in our quest to lower noise, we now have the encoder coupled directly to the output shaft with a very short piece of surgical tubing. That has worked very well (it puts less stress on the encoder shaft as well). |
Re: High speed encoder with slotted / flat end... can't find one.
1 Attachment(s)
Quote:
That explains a lot of the noise:) Quote:
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
Yes, exactly like that. |
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
For now... I'll conclude that the encoder was defected with the problems I mentioned before. At some point, since we have both bots... I'll get an up to date reading from both and present them here. One thing I do find interesting though is how much better GetRate() worked for this stress, but for now I want to dismiss this as evidence until I do further testing. While I'm here I want to thank Brandon and Palardy for their suggestions... we are very grateful for your input as we learn new stuff everyday. :) |
| 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