moderatelyfunky
Posts: 20
Joined: Mon May 07, 2018 7:12 pm
Location: Vermont, US

abort pigpiod wave_chain?

Wed Sep 19, 2018 10:34 pm

I've added some limit switches to my stepper project and if they are reached before the wave_chain is completed, I'd like to cancel the chain. I saw wave_tx_stop(), but that is built for wave_send_repeat.

Is there a way to interrupt and cancel the remainder of a wave_chain?

Thanks for any ideas

User avatar
joan
Posts: 13616
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: abort pigpiod wave_chain?

Thu Sep 20, 2018 7:26 am

wave_tx_stop() will work.

moderatelyfunky
Posts: 20
Joined: Mon May 07, 2018 7:12 pm
Location: Vermont, US

Re: abort pigpiod wave_chain?

Thu Sep 20, 2018 12:35 pm

I should have just tried it. Thanks, Joan!

moderatelyfunky
Posts: 20
Joined: Mon May 07, 2018 7:12 pm
Location: Vermont, US

Re: abort pigpiod wave_chain?

Thu Sep 20, 2018 11:08 pm

I am getting some unexpected behavior with my motors not running to their destinations using wave_chains. It's an odd symptom. The motors are woken up and the code shows print messages as expected, but the motors act like their step pins aren't set high.

When I run the motors with PWM, the limit switches work as expected and home the motors

Here is my setup:
1. Callbacks are setup for each of the four limit switches. If closed, set a "global" halt flag and run a homing method for each.
2. Callbacks are setup for each of the four motors. The callbacks are used to count steps for each.
3. A check in the gotoPreset method that cancels the wave_chain if the halt flag is true

Code: Select all

   
        ...wave chain creation and send...
        
	while self.pi.wave_tx_busy():
            if (self.haltAll == 1):
                self.pi.wave_tx_stop()
            else:
                time.sleep(0.1)
    
If I remove the limit switch callback, the motors run to their destinations as expected.

If I add back the limit switch callback and comment the self.pi.wave_tx_stop() in the while loop above, the motors run to their destinations as expected.

One complication that may play a role is that when running to a preset destination with wave_chains, all four motors may be running at once, whereas when using the PWM method, only one motor is running at a time.

Thanks for any suggestions

Return to “Python”