I am using pigpiod C interface to drive the Nema17 Stepper Motors by DRV8825 / stepper drivers. I am able to drive the motors by wave_chain() method.

After calling the wave_chain() method, it starts the pulse the stepper. If I cancel the transmitting process of the current wave form by wave_tx_stop(), can I get the current stepper position or all information is lost when I call the wave_tx_stop()?

I am using this code to drive the motor ;

void generate_ramp(int step_pin, int ramp0, int ramp1)
    int wid = -1;
    int f = ramp0;
    int micros = (int)(500000/f);
    gpioPulse_t pulses[2] =  {{1 << step_pin, 0, micros},{0, 1 << step_pin,micros}};
    wave_add_generic(Global.pi, 2, pulses);

    wid = wave_create(Global.pi);

    int steps = ramp1;
    int x = steps & 255;
    int y = steps >> 8;
    char wave[7] = {255, 0, wid, 255, 1 , x, y};
    wave_chain(Global.pi, wave , 7);

    wave_delete(Global.pi, wid);

Maybe combination of wave_tx_at() and wave_tx_stop() will helpful, but I can't find any way to remember the position just before the cancelling the transmitting.

1 Answer 1



The information is held internally within the DMA blocks but there is no method to get that information.

  • Thank you Joan. So I have to wait the wave form complete to send new wave form in case of the next wave form is undefined while sending the first wave ?
    – tango-1
    Apr 30, 2021 at 23:09
  • Yes, that's the only way to be sure of the number of pulses sent.
    – joan
    May 1, 2021 at 7:38
  • Thank you joan. I have another question, I didn't post a new topic. Are the set_servo_pulsewidth() and get_servo_pulsewidth() methods thread safe? Should I care synchronization while I am calling these two methods in different threads ?
    – tango-1
    May 1, 2021 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.