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);
while(wave_tx_busy(Global.pi));
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.