On 26.04.12 09:31, Gabriel Willen wrote: > Andy would you care to enlighten me a little on your sign lookup table? I > have an xmega laying around I have been playing with. I have it decoding > and picking up the hall positions. But I'm not grasping the sign lookup > table. I have read a half a dozen articles on it. In sure I will figure > out, I always do but I figured maybe you could help. Also I thought about > porting your bldc component, removing the real time and Hal includes and > trying to make it work. But honestly I don't need all the wonderful bells > and whistles you have included in yours.
Just in case it's interesting, there is a much more compact method than trigonometric lookup tables, and it generates sine and cosine simultaneously, with tangent costing only an additional division, IIRC. It is called CORDIC, and wikipedia has a good go at explaining it: <http://en.wikipedia.org/wiki/Cordic> I haven't stopped to wade through that, but my recollection, from nearly 40 years back, is that we start with a short table of binary weighted table of arctangents, e.g artan(45°), artan(22.5°), artan(11.25°), ... down to the desired resolution. Twenty table entries gets us to 6 decimal digit angle resolution¹, because any angle can be arrived at by adding or subtracting the twenty values. (Plus some fiddling.) But why binary weighted? Because now the multiplication in the CORDIC algorithm reduces to a shift. (Queue angel chorus & thunder roll.) The whole thing runs like greased lightning, even on a microcontroller. (It was used on digital calculators 40 years ago, and they nibbled at maths.) I have a CORDIC algorithm implementation, but it's in TMS9900 assembler. <digression> Prior to its extinction, that processor had a programmable shift operation, so it did a *2^n in one hit, rather than repeated one bit shifts, making it ideal for this kind of stuff. (Mind you, an xmega would still be one to two orders of magnitude faster than the TMS9900, which had only 3 on-chip registers. The 16 user registers were memory resident, and so could be bank switched, just by changing the Workspace Pointer to use another part of memory, with the previous WP,PC,ST registers replicated in the new R13,R14,R15.) </digression> Anyway, it wouldn't be that hard to translate to AVR assembler or C. Must try that one day. Erik ¹ But a dozen table entries use up a 16 bit sine value range, so one might settle for a slightly shorter table than that. -- How many seconds are there in a year? If I tell you there are 3.155 x 10^7, you won't even try to remember it. On the other hand, who could forget that, to within half a percent, pi seconds is a nanocentury. -- Tom Duff, Bell Labs ------------------------------------------------------------------------------ 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
