|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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. Last edited by Tom Line : 21-05-2012 at 01:07. |
|
#2
|
|||||
|
|||||
|
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). Last edited by AdamHeard : 21-05-2012 at 01:11. |
|
#3
|
|||||
|
|||||
|
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.
|
|
#4
|
||||
|
||||
|
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: |
|
#5
|
|||||
|
|||||
|
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. Last edited by Mark McLeod : 21-05-2012 at 08:57. |
|
#6
|
|||||
|
|||||
|
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 |
|
#7
|
||||
|
||||
|
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 |
|
#8
|
||||
|
||||
|
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). |
|
#9
|
|||||
|
|||||
|
Re: High speed encoder with slotted / flat end... can't find one.
Depending on how much processing/filtering is performed on the encoder results, using anything except the 1x mode could introduce jitter. Picking one transition and sticking with it gives the "cleanest" measurement.
|
|
#10
|
|||||
|
|||||
|
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. |
|
#11
|
||||
|
||||
|
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 |
|
#12
|
||||
|
||||
|
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... |
|
#13
|
||||
|
||||
|
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_Averager
{
private:
std::priority_queue<double> m_queue;
const size_t m_SampleSize;
const double m_PurgePercent;
double m_CurrentBadApple_Percentage;
size_t m_Iteration_Counter;
void flush()
{
while (!m_queue.empty())
m_queue.pop();
}
public:
Priority_Averager(size_t SampleSize, double PurgePercent) : m_SampleSize(SampleSize),m_PurgePercent(PurgePercent),
m_CurrentBadApple_Percentage(0.0),m_Iteration_Counter(0)
{
}
double operator()(double newItem)
{
m_queue.push(newItem);
double ret=m_queue.top();
if (m_queue.size()>m_SampleSize)
m_queue.pop();
//Now to manage when to purge the bad apples
m_Iteration_Counter++;
if ((m_Iteration_Counter % m_SampleSize)==0)
{
m_CurrentBadApple_Percentage+=m_PurgePercent;
//printf(" p=%.2f ",m_CurrentBadApple_Percentage);
if (m_CurrentBadApple_Percentage >= 1.0)
{
//Time to purge all the bad apples
flush();
m_queue.push(ret); //put one good apple back in to start the cycle over
m_CurrentBadApple_Percentage-=1.0;
//printf(" p=%.2f ",m_CurrentBadApple_Percentage);
}
}
return ret;
}
};
Code:
void KalmanFilter::Reset()
{
m_FirstRun=true;
//initial values for the kalman filter
m_x_est_last = 0.0;
m_last = 0.0;
}
KalmanFilter::KalmanFilter(): m_Q(0.022),m_R(0.617) //setup Q and R as the noise in the system
{
}
double KalmanFilter::operator()(double input)
{
//For first run set the last value to the measured value
if (m_FirstRun)
{
m_x_est_last=input;
m_FirstRun=false;
}
//do a prediction
double x_temp_est = m_x_est_last;
double P_temp = m_last + m_Q;
//calculate the Kalman gain
double K = P_temp * (1.0/(P_temp + m_R));
//the 'noisy' value we measured
double z_measured = input;
//correct
double x_est = x_temp_est + K * (z_measured - x_temp_est);
double P = (1- K) * P_temp;
//update our last's
m_last = P;
m_x_est_last = x_est;
//Test for NAN
if ((!(m_x_est_last>0.0)) && (!(m_x_est_last<0.0)))
m_x_est_last=0;
return x_est;
}
And the typical averager Code:
// A templated averager, make sure the type being averaged can handle the +, -, and / functions
template<class T, unsigned NUMELEMENTS>
class Averager
{
public:
Averager() : m_array(NULL), m_currIndex((unsigned)-1)
{
if (NUMELEMENTS > 1)
m_array = new T[NUMELEMENTS];
}
virtual ~Averager() {if (m_array) delete[] m_array;}
T GetAverage(T newItem)
{
if (!m_array) // We are not really using the Averager
return newItem;
// If the first time called, set up the array and use this value
if (m_currIndex == -1)
{
m_array[0] = newItem;
m_currIndex = -2;
m_sum = newItem;
return newItem;
}
else if (m_currIndex < -1)
{
// We have not populated the array for the first time yet, still populating
m_sum += newItem;
int arrayIndex = (m_currIndex*-1)-1;
m_array[arrayIndex] = newItem;
// Still counting backwards unless we have filled all of the array
if (arrayIndex == (NUMELEMENTS-1)) // This means we have filled the array
m_currIndex = 0; // Start taking from the array next time
else
--m_currIndex;
// Return the average based on what we have counted so far
return (m_sum / (arrayIndex+1));
}
else // 0 or greater, we have filled the array
{
m_sum += newItem;
m_sum -= m_array[m_currIndex];
m_array[m_currIndex] = newItem;
++m_currIndex;
if (m_currIndex == NUMELEMENTS)
m_currIndex = 0;
return (m_sum / NUMELEMENTS);
}
}
void Reset(){m_currIndex=-1;}
private:
T* m_array;
int m_currIndex;
T m_sum;
};
![]() Where the cyan line is the encoder reading trying to match the magenta ramp velocity. Hope these ideas may help out. |
|
#14
|
||||
|
||||
|
Re: High speed encoder with slotted / flat end... can't find one.
Quote:
|
|
#15
|
||||
|
||||
|
Re: High speed encoder with slotted / flat end... can't find one.
Each pixel represents a 10ms iteration... for completion, the green is the voltage applied while the yellow is the voltage scaler from PID (or actually PD). Notice how quickly the voltage peaks to full voltage... then drops when the encoder reading got too high... I cannot explain why it is trying to calibrate at a fixed offset below the desired velocity, but fortunately any issue of that would not be contributed to the averagers. I suspect that issue is due to the tolerance size (I'll need to review the code).
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|