I'm trying to generate 2 simultaneous square waves (50% duty cycle PWM signals) to step two stepper motors (STEP signal to separate motor drivers) on the Raspberry Pi Zero W. I use GPIO12 and GPIO19, which are supposed to control two independent PWM channels. I've tried two different methods, neither of which seem to work as I expect them to.

Method 1: Uses bcm2835 library

Use calls to bcm2835_pwm_set_data and bcm2835_pwm_set_range and system timer delays to start/stop motion after certain number of PWM pulses

Method 2: Uses pigpio library

Use calls to gpioWaveAddGeneric, gpioWaveCreate, and gpioWaveChain to send pulse trains to motor drivers

Both of these methods have also been threaded, and the outcome is that one channel is pulsed quickly and then turns off before the other channel drives its full pulse sequence. To me it seems like the PWM channels are interferring with one another. Does anyone know if simultaneously driving two independent PWM signals is possible using the Pi?

  • Could you post actual code snippets? How you call functions can matter a lot. Perhaps concentrate on one method which you think is the easiest. – Dmitry Grigoryev Jan 14 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.