Archive

Posts Tagged ‘stepper motor controller’

Stepper Motor Controller Update

November 13th, 2009

It’s a step forward, two steps back. I burnt out one of the channels running some preliminary tests, and I just got the replacement board in from Pololu.com. Spent longer than I wanted trying to hook it up (note to self: don’t use such low gague wire). But I was still seeing more jitter in the clocking than I wanted. I tried a few different configurations, and finally came up with an approach that seems to work well, and exhibits a jitter equal to the resolution of the micros() call (4uS). In this approach, it computes the time when the next step happens, figures out which channel needs to step next, then waits for that time in a tight loop:

// start move
while (xaxis->delta_steps || yaxis->delta_steps || zaxis->delta_steps) {
        a = nextEvent();
        while (micros() < (starttime + a->nextEvent) ); //wait till next action is required
        if (can_move(a)) {
                _STEP_PORT |= a->direct_step_pin;
                //need to wait 1uS
                __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
                __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
                _STEP_PORT &= ~a->direct_step_pin;
        }
        if (--a->delta_steps) {
                a->nextEvent += a->timePerStep;
        } else {
                a->nextEvent = 0xFFFFFFFF;
        }
}

The latest version of the code is checked into SVN on google code.

So anyhow, I get everything working nicely only to find that the Z-axis controller is also fried — these guys are way too sensitive. Need to order yet another board.

Reza

Uncategorized