4-axis half-stepping translator in AVR

Chris started with a MAXNC 10 open-loop machine. The included driver boxes (which we came to understand were complete crap) use one pin per winding. This requires two parallel ports for 4 axes. So, a year or so ago, before he switched to L297/8-based boards, I helped Chris design an avr-based translator from step+direction pulses to the individual winding activation signals. Today I'm posting the program, which I compiled with avr-gcc. In the future I might post the board, which was a double sided design created in eagle.

The program itself is small, but a atmega16 is required because of the requirement for 8 inputs and 16 outputs.

A trick is used to increase the number of interrupts: In addition to the INT0 and INT1 signals, the external counter pins are used as interrupts. By preloading the counters with 0xff (8-bit T0) and 0xffff (16-bit T1), the next rising edge seen on the pin will trigger an interrupt.

We initially had problems with the board losing steps. I believe this was fixed by making the correct settings in EMC: The "step" signal is active high, and the direction signal is latched after the "step" signal is asserted.

I don't know for sure how fast this board can go; It obviously depends on the clock speed you choose from the AVR. Based on what I recall about reading the disassembly, a "step" pulse took around 50 AVR cycles to finish being translated. This means that if it sees an edge on all 4 step pins at once, the direction output must still be valid up to 200 AVR cycles after the step, or 12.5us at 16MHz. Similarly, this would indicate a maximum step rate of 80kHz at 16MHz. In practice, I think that Chris's machine was limited to about 12ipm at that time, a step rate of 1600Hz, so we didn't get anywhere near these theoretical limits.

I had one thought when I looked at this program today. With an atmega16 there is no reason to use PROGMEM for the motor stepping pattern.

Files currently attached to this page:

maxnc.c3.9kB



Entry first conceived on 15 October 2005, 19:11 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2024 Jeff Epler