Jeff Epler wrote: >>> > On Tue, Oct 26, 2010 at 08:29:52PM -0500, Jon Elson wrote: > > Actually, the modified pid is intended to be entirely compatible with > the original pid without any ini/hal changes. The way I accomplish this > is a little bit gross (it treads on a hal implementation detail, the > "dummysig") but it means less disruption or duplication of code (at_pid, > I'm looking at you!). > Ah, very good! >> The UPC firmware has what I believe are the requisite functions. >> There is a 16-bit timestamp running at 1 MHz, and a 16-bit latch that >> records the timestamp at each encoder transition. If I can get this >> working, I will then add the function to the UPC and PPMC boards. >> > > Cool! I recall that with hostmot2 it took a number of iterations on the > driver side to deal fully with direction reversals and counter overflows > in all the corner cases, but the timestamp is the basic building block > that makes the high-quality velocity estimae possible. > Yes, I'm expecting some of the same difficulty. I've been looking at the encoder hal component, but I couldn't really see any code to handle those cases, so I was wondering how the heck it worked. It seems a direction reversal shouldn't actually be a special case, except in some kind of crazy case where there were several counts in the minus direction and the last count was in the + direction, all in the same servo period. That seems like it shouldn't happen, except maybe due to encoder dither.
The counter overflow would be rare on the hal component, it uses a 32-bit integer, and whatever the BASE_THREAD is running at, so that's maybe every 85000 seconds or just about once a day. I'm using a 16-bit counter and a 1 MHz clock, so it overflows every 65 milliseconds. I may have to look at the hostmot2 code to see how they do it there. Jon ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers