I need a signal at the output of the GIPO of approximately this shape.(sub-pulse in pulse)enter image description here

How can this be implemented using PWM on PI? Im trying do it with RPIO,but his ancient GPIO pinout maybe not working for my Rpi 3 b+.

from RPIO import PWM
servo = PWM.Servo()
servo.set_servo(12, 10000)
PWM.add_channel_pulse(0, 12, start=200, width=2000)

Not Signal on pin. enter image description here I'm confused in it and would like to try the built-in library to work with PWM, but I did not find there the possibility of sub-cycles. How else i can a signal of this form be output from different GPIO?


Pin# is the physical pin on the expansion header.

NAME is either the voltage rail connected to that pin or the GPIO connected to that pin. RPIO.GPIO uses the Broadcom numbering system. The different GPIO have different specializations and this is documented by Broadcom GPIO number in the Broadcom documentation (BCM2835 ARM Peripherals)

An alternative to RPIO.GPIO is my pigpio which is a C library but may be accessed through a Python module.

I would use waves to construct any repeating waveform.

Have a look through these general Python examples, some will use waves.

Here is a pigs example of generating the (comment) requested waveform.

$ pigs m 4 w # set GPIO4 as an output

$ pigs wvag 16 0 500 0 16 500 # Set GPIO4 on for 500 us then off for 500 us
$ pigs wvcre # Create wave from pulses, it will have an id of 0

$ pigs wvag 0 0 100000 # Create a 100 ms delay pulse (no GPIO on or off)
$ pigs wvcre # Create wave from pulse, it will have an id of 1

$ pigs wvcha 255 0 255 0 0 255 1 100 0 1 255 3 # Transmit wave chain

The wvcha command sends wave 0 100 times, then sends wave 1, then repeats the whole sequence indefinitely.

  • Please,add some code for this wave 1 Khz freq, off\on every 0.1 seconds. – Dmitrii Sep 16 '17 at 17:38
  • Its very good! Please, add python code for create this waveform like abyz.co.uk/rpi/pigpio/python.html I started bounty for you. You library amazing, but need good example for modulate complex waveform – Dmitrii Sep 19 '17 at 8:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.