I've looked through the documentation of RPIO, and used GPIO18 to get my PWM up and running.

This is my code:

from RPIO import PWM
servo = PWM.Servo()
servo.set_servo(18, 4000)

As explained in the example in the documentation, this is supposed to set a 4000us (4ms) pulse every 20ms.

However, when I run the code - the LED blinks only once - indicating that there was only one instance of the pulse. Even when I check it with an oscilloscope - I am able to fleetingly catch a singular pulse.

Isn't the code supposed to generate an indefinite PWM wave, like one froma function generator?

How do I go about getting a sustained PWM wave as opposed to just a single pulse? I only wish to use RPIO since it is DMA based.

  • "This module is currently in beta, please send feedback to chris@linuxuser.at" – OyaMist Jul 18 '18 at 11:58
  • "Isn't the code supposed to generate an indefinite PWM wave, like one froma function generator?" -> I would guess that the library cleans up after itself, i.e., resets the pin to a default state on exit. So if you run exactly what you have here, not much will happen. Try it with a passive loop at the end -- while true sleep 1000 where the unit for sleep is milliseconds (I'm not a python user but I think that's what os.sleep() uses there). – goldilocks Jul 18 '18 at 12:08
  • pigpio also uses DMA to time pulses (as does servoblaster). – joan Jul 18 '18 at 12:11
  • @goldilocks alternatively, I think enclosing the aforementioned code in a 'for' loop for a sufficient range should also work? – user8244 Jul 18 '18 at 12:23
  • @joan are there functions in pigpio that I can use to get rid of the for loop complication? Is there a provision for me to get a sustained pwm pulse? – user8244 Jul 18 '18 at 12:24

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.