400kHz Triple quadrature divider for atmega8 and quadrature state table generator

I promised a single, 800kHz quadrature divider for the attiny13. Well, I haven't done that yet (I don't have any attiny13s to test on anyway), but I have something else instead. Update, 2007/01/04: Want true high-resolution PWM and multi-MHz quadrature counting with emc2, for under $100? Try this!

As I mentioned earlier, Chris had already milled a servo control board for his lathe. Like the Etch Servo board, it controls two servo motors with a single L298 chip. Unlike the Etch Servo, it has 3 encoder inputs (X, Z, and spindle). His servo motors have 500-line encoders and have a no-load speed of about 4000 RPM, while the spindle will have a 1024-line encoder with index pulse, but rotate slower (much less than 2000RPM when threading). 133kHz is too fast to count in the PC, but divided by 8 or 16 it's very managable.

mkstate.py is a Python program which generates a quadrature divider table. By changing 'N', 'M', 'x' and 'ux', it's possible to generate tables with different properties. After generating the table, a variety of tests are performed on it to verify that it is correct. Output can be a "C" array or a table of bytes for an assembler program.

qq2.S is a GNU assembler program that actually performs the quadrature division. According to my cycle counting, it polls at 470kHz when a 16MHz crystal is used, so it is expected to work reliably with a 133kHz quadrature signal. So far, though, it has been tested with a single motor spinning at hundreds of RPM.

mkstate.py and qq2.S are released as free software under the terms of the GNU GPL.

Files currently attached to this page:

mkstate.py5.5kB
qq2.S5.7kB



Entry first conceived on 2 June 2006, 18:02 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2014 Jeff Epler