MKFirmware / MarlinKimbra4due

MK4due firmware for Arduino DUE
22 stars 14 forks source link

Stepper #2

Closed Wurstnase closed 9 years ago

Wurstnase commented 9 years ago

There are some bugs in the stepper on the last patch. You should update it. This is also now much faster. https://github.com/Wurstnase/Marlin4Due/commit/1c7857b7a0b9acf2b38a22ea1238bd4a4db567b4

MagoKimbra commented 9 years ago

Wow... thank's.... One question, but I do not understand how do you program these timers, based on what works? As for everything else to me is quite understandable, but these things timers I just can not understand them ..

Wurstnase commented 9 years ago

The interrupt runs at 42MHz. So if I want a stepping rate of 5000 steps/s (this is ~ 62.5mm/s with 1/16 and 80steps/mm) you need to set the counter to 42.000.000 / 5.000 = 8.400. Now the interrupt counts from 0 up to 8.400 and then it overflows and restart the stepper-isr.

While accelerating or decelerating you need to calculate these values every step (or second on doublestepping or forth on quadstepping) to have a smooth move.

MagoKimbra commented 9 years ago

Ok thank's for explain...

Wurstnase commented 9 years ago

your fastio is way too slow to achieve high step rates.

MagoKimbra commented 9 years ago

Hi Wurstnase, I have tried to do it as your own, but the card is blocked and nothing works. I can not understand why, so instead it works fine on the Cartesian, the question remains on the delta. Thank you for your help. But how does the FastIO to influence the speed?

Wurstnase commented 9 years ago

I guess you set a pullup by a WRITE and not a PULLUP (SET_PULLUP).

digitalWrite ~ 46µs WRITE in my version ~4.4µs

MagoKimbra commented 9 years ago

Ok i put your version fastio. All pin function, Bed, Hotend, Fan, Enable, but the motor not move. I read pin for sensor, endstop. Only motor not move. The motor is block when enabled, and not block when disabled. Where is the problem?

EDIT: I found problem... If i put delayMicroseconds(1) in routine step write Hight - step Write low function....

Wurstnase commented 9 years ago

OK, which kind of stepper driver do you use?

MagoKimbra commented 9 years ago

i have this board http://www.3dartists.org/ Alligator with stepper driver Texas Instrument DRV8825. Io ho risolto cosi:

define APPLY_MOVEMENT(axis, AXIS) \

      _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
      if (_COUNTER(axis) > 0) { \
        _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); \
        _COUNTER(axis) -= current_block->step_event_count; \
        count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
        _delay_us(1U); \ <------------------------------------------------- DELAY
        _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
      }
    APPLY_MOVEMENT(x, X);
    APPLY_MOVEMENT(y, Y);
    APPLY_MOVEMENT(z, Z);
    #ifndef ADVANCE
      APPLY_MOVEMENT(e, E);
    #endif
Wurstnase commented 9 years ago

You shouldn't change that part. In the past this was STEP_ADD and STEP_IF_COUNTER. This makes normally enough delay between Step-High and Step-Low.

If that is not enough we should take other ways than a delay in an interrupt.

MagoKimbra commented 9 years ago

I tried to do it that way, I used the part that was already there for stepper toshiba, but not enough, engines vibrated.

I was thinking you remove the macro and make the first step for all axes High then take control of the counter and then the low in this way, you should add a good time of late ..

Wurstnase commented 9 years ago

Anyway, it is way better to use that part of code and only put 1 delay between step_adds and step_if_counters and not a delay for every step.