Modulate complex signal on all gpio

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

How can this be implemented using PWM for PI? I am trying to do this using RPIO, but its ancient GPIO clipping may not work 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) 

There is no signal on the contact. enter image description here I got confused about this and would like to try the built-in library for working with PWM, but I did not find the possibility of subcycles there. How else can I output this waveform from different GPIOs?

+7
python raspberry-pi pwm
source share
3 answers

It seems you should use such code. Unfortunately, I have no way to check it, because I do not have a frequency meter or an oscilloscope.

 import time import pigpio GPIO=12 pulse = [] # ON OFF MICROS pulse.append(pigpio.pulse(1<<GPIO, 0, 5)) pulse.append(pigpio.pulse(0, 1<<GPIO, 5)) pulse.append(pigpio.pulse(1<<GPIO, 0, 5)) pulse.append(pigpio.pulse(0, 1<<GPIO, 1e7)) pi = pigpio.pi() # connect to local Pi pi.set_mode(GPIO, pigpio.OUTPUT) pi.wave_add_generic(pulse) wid = pi.wave_create() if wid >= 0: pi.wave_send_repeat(wid) time.sleep(60) # or another condition for stop processing pi.wave_tx_stop() pi.wave_delete(wid) pi.stop() 
+1
source share

The documentation allows you to simply pass a list of channels as the first argument to both GPIO.setup and GPIO.output, doing what you ask.

 chan_list = [11,12] # add as many channels as you want! # you can tuples instead ie: # chan_list = (11,12) GPIO.setup(chan_list, GPIO.OUT) GPIO.output(chan_list, GPIO.LOW) # sets all to GPIO.LOW 
+2
source share

I had a much better PWM experience with pigpio compared to RPi.GPIO. Wiringpi is also good, but PWM support in pigpio is much better than IMO.

The documentation has several functions for generating PWM on any pin:

http://abyz.co.uk/rpi/pigpio/python.html#set_servo_pulsewidth http://abyz.co.uk/rpi/pigpio/python.html#set_PWM_dutycycle

Do you have * to use RPi.GPIO? I understand that this is not an exact answer, but I hope that it at least points you in the right direction.

+1
source share

All Articles