![]() |
Re: Unexpected results from Encoder::GetRate()
Quote:
I.E Wouldn't this be a possible problem? Code:
*/Quote:
|
Re: Unexpected results from Encoder::GetRate()
Quote:
If instead you did: Code:
INT32 Counter::Chris_Get()-Joe |
Re: Unexpected results from Encoder::GetRate()
Quote:
I still would like to know the details of your GetRate() algorithm that keeps the rate from reporting on a same edge. Its not obvious where you do this. Also, could you describe the 4x algorithm equations (like your description of the 1x and 2x earlier). |
Re: Unexpected results from Encoder::GetRate()
Quote:
The sliding-window average engine that follows the event timer will reset its pipeline of samples on direction changes as well. This is because the rates are unsigned and averaging rates that refer to different directions without sign has no meaning. It could potentially be modified to be signed, but then we are duplicating direction information. Maybe that's a good thing. Thoughts? -Joe |
Re: Unexpected results from Encoder::GetRate()
Quote:
Ok...I just have to remind myself that the m_counter object register really represents two counter results... output.value and output.count. They are related only when the output.dir is the same as previous dir. The GetPeriod() intro Code:
/*So I think I'm clear on that now. If I wanted to implement my own rate algorithm, I don't think I can determine if a same edge event has occurred by looking at your register information. I believe I would need a same edge flag added to your output register. The only change I would make is to set the rate = zero at this event rather than no report at all. I think you are throwing out some of the A/B information available to you. When a reversal occurs, your rate will be 180 deg out of phase, rather than just 90. This is slightly more destabilizing and if rate is needed by a PID loop to stabilize an otherwise near neutral or unstable plant it will lead to a several count limit cycle which would probably approach the one generated by a hysteresis controller. Plus, your rate estimate will be biased in the presence of oscillations. If you modifiy your GetRate() in the future, I would favor adding the zero rate and same edge flag features. Quote:
Perhaps this phenomenon was present last year when I did a couple of runs with different pulse averaging lengths and did not see much benefit. http://forums.usfirst.org/showpost.p...43&postcount=5 |
Re: Unexpected results from Encoder::GetRate()
Quote:
A => value of A channel currently A' => value of A channel last sample A + B => A XOR B A | B => A OR B A & B => A AND B !A => NOT A Equations: Count = (A + A') | (B + B') Count_Dir = A + B' + !Reverse Count_Up = Count & Count_Dir Count_Down = Count & !Count_Dir (Reverse is a configuration register) -Joe |
Re: Unexpected results from Encoder::GetRate()
Quote:
Quote:
Quote:
Quote:
Does anyone have a better idea for filtering noise from this kind of system than a sliding window average that doesn't reset at 0? Remember that we are HIGHLY space constrained so keep in mind that we need small and simple algorithms that are effective. Thanks, -Joe |
Re: Unexpected results from Encoder::GetRate()
Quote:
|
Re: Unexpected results from Encoder::GetRate()
Quote:
|
Re: Unexpected results from Encoder::GetRate()
Quote:
Well, Ill have to work on you a little more. This flag would make the register a complete representation of the A/B state information which doesn't seem like a bad thing. I don't think a fast read would be practical solution. Quote:
Quote:
The other alternative would be to use a IIR exponential filter. This would weight the latest pulse heavier than prior pulses. I would prefer the FIR pipeline filter over this but it might work fine. |
Re: Unexpected results from Encoder::GetRate()
Quote:
Perhaps I could make the same edge event set the stalled bit immediately, since a same edge represents a stop (except in the ridiculous noise case). Quote:
Quote:
-Joe |
Re: Unexpected results from Encoder::GetRate()
[quote]
Quote:
Quote:
Quote:
Quote:
Quote:
|
Re: Unexpected results from Encoder::GetRate()
1 Attachment(s)
I finally took the time to look into this issue. I found the source of the mysterious factor of 2 that was introduced for the patch. It's caused by the fact that the "Period" variable for TimerOutput is a fixed point number that is not decoded when TimerOutput is read as a complete structure... only when read from the direct accessor. That means the decoding must be done in the driver. Since the fixed point format is 24 bits with 25 integer bits, the data must be shifted by 1 bit position... the factor of two!
I've attached the final patch that went in for those who are curious. -Joe |
Re: Unexpected results from Encoder::GetRate()
Quote:
A few questions/comments: 1) I see you took my suggestion for the x1,x2 and x4 averaging pulse count. Did you take a look to see if this really helped the rate noise increase with the x2 and x4 configs? I sort of have mixed feelings on this now. It should sure help if all the pulses are within a single reference frame, but would be less effective if averaging pulses which are part of different frames. I still would like you to add a SetMovingAveragePulseCount(int max_count) procedure to allow user control of this. 2)Did you set the rate = zero at a same edge event rather than no report at all in your subcode? If not is this in your plans? 3)Did you try to implement the signed pipeline as I suggested so you don't have to reset the pipeline at zero crossings http://www.chiefdelphi.com/forums/sh...5&postcount=85 ? |
Re: Unexpected results from Encoder::GetRate()
Quote:
As far as your concern about frames, an encoder doesn't have "frames". The pulses are from one slit to the next and are typically pretty uniform (more so than the A-B phase or the slit-spoke ratio). I think this works just great. Quote:
Quote:
Quote:
It also means that the direction is available in this TimerOutput register as well as the position output register. We would no longer need to access the position register to dermine the direction as we do today. I still need to decide whether to reduce the range of the timer or the resolution to get the bit I need for the sign bit. -Joe |
| All times are GMT -5. The time now is 12:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi