2

Using Pigpio to drive a couple of stepper motors on a CNC-like system, I'd like to "initialize" by setting up a repeating wave to continually step until a limit switch has been reached, at which point I'd issue a wave_tx_stop() to halt the stepper. I'm curious if there's any way of seeing how many pulses have been issued at the point the wave was stopped, so that I could deduce how many steps "wide" the area is between limit switches.

That is, is there any way to see how many total pulses have been executed by the currently-running wave chain? Am I just way off base here and need to try something different?

Jordan Day
  • 23
  • 3

2 Answers2

2

For all those still searching: Actually there is - contradictory to the current answer - a pretty good solution also provided by pigpio (at least for me there was)!

You can use either piscope (a way too much overhead) or if the frequency is not too high you can use pigpio.callback() too keep accurate track of the total pulses sent.

cb = pi.callback(GPIO)
# to create a simple "callback counter" on the pin where the PWM pulses are sent
print(cb.tally()) # to display number of pulses made
cb.reset_tally() # to reset the counter

See also following Stackexchange Post

n0sr3v
  • 21
  • 2
1

You will have to find an alternative mechanism. There is no way to tell how many pulses have been transmitted by an interrupted wave chain (unless the pulses are quite slow and you have an alert set up on the pulse GPIO).

If you run a wave chain with a loop count to completion it will have executed the number of pulses in the loop count.

joan
  • 71,852
  • 5
  • 76
  • 108