Software PWM on RPi

I'd like to create a node for the Software PWM which supports any GPIO pins and support a fixed frequency(38kHz) and fixed duty cycle(50%).
In other word, I just need 5~6 GPIO pins that output 38kHz/50% PWM signal.

I have tried pigpiod implementations(node-red-node-pi-gpiod (node) - Node-RED, GitHub - miketrebilcock/js-pigpio) but neither works with this specific frequency on any GPIO pin.

Does anyone have a chance to create a software PWM on any GPIO pin?


You want to output, on a Pi and under s/w control, a signal that switches every 26 microseconds, to 6 GPIO pins?

If that is possible, which I rather doubt, then node-red will not be involved.

1 Like


Actually, I would like to create a custom node to output 38kHz on a configured pin to control an IR transmitter.

I was trying to think of a way to say the same :slight_smile:

@wester.weerdt A node will NOT control the GPIO, it would control the library or custom code that would control the GPIO. You need to figure out that part first.

You might also consider looking at an add-on board with true hardware PWM.

Is this for a specific IR communication? or general purpose "programmable"

It is just to emit 38kHz, 50% duty cycle signal. :slight_smile:

Then find some way to do that via library, custom code, hardware PWM, etc... then once you have that, and not before, you can make your custom node to control the process.

1 Like

What is the highest frequency that you can do with the pigpio node?

You can do 40kHz easily with pigpio in C. The default accuracy is 5us and you need to set 1 us accuracy.

You may write a C program and use EXEC node to do it.

Google for LIRC (Linux Infrared Remote Control) library and how to install it.
With this lib you can send Ir commands from the command Line and thus with the EXEC node.