On Wed, 27 Jun 2012, Scott Hasse wrote:
> Date: Wed, 27 Jun 2012 23:09:32 -0500
> From: Scott Hasse <[email protected]>
> Reply-To: "Enhanced Machine Controller (EMC)"
> <[email protected]>
> To: "Enhanced Machine Controller (EMC)" <[email protected]>
> Subject: [Emc-users] encoder component in counter mode velocity stability
> issues
>
> All-
>
> I've been attempting to get a simple low-cost frequency-based analog input
> to LinuxCNC using an LM331 voltage-to-frequency chip for measuring
> temperature inputs from thermistors (as part of my RAMPS board parallel
> port adapter I mentioned in a different thread). The good news is that I
> have that basically working and will provide a documented circuit once I
> get the bugs worked out. Interestingly, when I use the software encoder
> hal component in counter mode, I get a lot more variance in the velocity
> than I would expect. In my test cases, the pulse rate is very stable, the
> pulse frequency is low enough that the parallel port input is capturing
> every pulse, and the encoder.0.count is going up linearly as I would
> expect. I've attached an image showing a halscope capture of the parallel
> port input, the encoder counts and the velocity. The velocity varies by
> 10-20% with a stable input frequency.
What is your base thread? a 10 KHz base thread would cause ~10% PP noise in a
1 KHz frequency measurement at 1 KHz servo thread due to sampling time
quantization, that is the time stamp would only have a resolution of 100 usec.
Of course base thread jitter adds to this as well.
>
> I initially thought perhaps the fact that my input pluses were not
> symmetric could causing some velocity issues, but according to the encoder
> component documentation (and source from what I can tell) the encoder in
> counter mode only counts the rising edges. In any case I tried x4-mode
> false and it was still just as unstable.
>
> I understand that I can smooth this out with a lowpass filter, but even
> with a gain of 0.001 there is enough variance to be noticeable. More gain
> than that and the measurement takes noticeably long to come up from zero to
> the measured value. (As an aside, I am wondering about the value of a
> simple enhancement that could be made to the lowpass component such that on
> the first read it sets the out value to the initially in value to make the
> initial settle period much lower. As I improve my .comp skills I'll look
> to create a patch. There is a load mode on the lowpass already, but it
> needs to be enabled then disabled.)
>
One thing that commonly done for this is a step acquire mode. What this does
is check the filter output and input and if they differ by more that some
threshold (a ratio) the filter output gets set to the input value.
This does not work well for "spikey" noise but is good for noise that has a
bounded amplitude (like quantization noise)
>
> Interestingly, the frequency of my analog input is just about the same as
> the servo thread (1000000 uS) and 1kHz. If I increased the servo thread
> interval then the velocity variance decreases, seemingly in proportion to
> how much I increase the servo thread. This makes a certain amount of sense
> (in essence I am averaging the measured interval over more than one data
> point), but I'm hoping to understand why I am getting so much variance in
> my current case.
For temperature measurement it probably does not make much sense to caulculate
more often than about every 100 1 ms servo threads anyway (which should
reduce your noise to the 0.1% to 0.2% region
>
> Looking at the source code for the encoder component it looks like the
> update function keeps track of the timestamp of the last pulse seen, and
> the capture function uses that timestamp if no pulses were seen in the last
> servo loop to estimate a velocity, but only uses the estimated velocity if
> it is lower than the last actually-measure velocity. That all seems good
> from what I can see, so I'm having trouble understanding how so much
> variance could be coming into the velocity value for a stable frequency
> input.
>
> Anyone have thoughts on why I might be experiencing that?
>
> Thanks much,
>
> Scott
>
>
> Thanks in advance for any thoughts on this subject.
>
Peter Wallace
Mesa Electronics
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users