# Pulse Generator in RPi 3B+

**URL:** <https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825>\
**Category:** Dashboard\
**Created:** [9 January 2021 08:33 UTC](https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825 "2021-01-09T08:33:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![plcguy](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@plcguy](https://discourse.nodered.org/u/plcguy)\
**Post date:** [9 January 2021 08:33 UTC](https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825/1 "2021-01-09T08:33:40Z")

</div>

Hi,

I am looking for a code to generate pulse output based on the integer input from the dashboard.  
user will input a value between 1 - 200 and this is pulse per min and a led connected to the GPIO 12.  
can anyone give me any idea how to do this as I'm new to the node-red.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 January 2021 14:20 UTC](https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825/2 "2021-01-09T14:20:04Z")

</div>

Node-RED uses Node.js and generally runs on Linux, Windows or Mac. None of that really supports real-time processing. So while you could easily enough produce a message in a time period, it wouldn't be exact. So you need to identify how exact you need the pulses to be. You also need to say whether you are looking for on/off pulses or just a trigger.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 January 2021 14:21 UTC](https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825/3 "2021-01-09T14:21:04Z")

</div>

Welcome to the forum @plcguy.

You can do that with a couple of Trigger nodes. The first generates a stream of messages that the appropriate rate and the second turns them into on/off pulses.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c6421e47e026fdfa28b5a5af4a4de99b330f8361.png)

```auto
[{"id":"f5ac7f1a.c6f05","type":"trigger","z":"bdd7be38.d3b55","name":"Configureable repeater","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":300,"y":4300,"wires":[["bd460116.6b503"]]},{"id":"16b6ad6b.3e7e4b","type":"inject","z":"bdd7be38.d3b55","name":"60/min","props":[{"p":"payload"},{"p":"delay","v":"1000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":90,"y":4260,"wires":[["f5ac7f1a.c6f05"]]},{"id":"23f3f81c.77ac28","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":310,"y":4420,"wires":[]},{"id":"e19eaf37.90732","type":"inject","z":"bdd7be38.d3b55","name":"30 per min","props":[{"p":"payload"},{"p":"delay","v":"2000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":100,"y":4340,"wires":[["f5ac7f1a.c6f05"]]},{"id":"bd460116.6b503","type":"trigger","z":"bdd7be38.d3b55","name":"Pulse","op1":"","op2":"0","op1type":"pay","op2type":"num","duration":"50","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":290,"y":4360,"wires":[["23f3f81c.77ac28"]]}]

```

If that works for you then all you need to do is work out how to use the dashboard to enter a value and then convert that into a period between pulses for sending to the first node.

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [9 January 2021 14:33 UTC](https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825/4 "2021-01-09T14:33:59Z")

</div>

Hi and welcome @plcguy.

For near microsecond hardware accuracy in generating pulses and timing input events I use the user mode pigpiod C library via the script commands provided.  
[http://abyz.me.uk/rpi/pigpio/pdif2.html](http://abyz.me.uk/rpi/pigpio/pdif2.html)  
Look for a simple example of scripting on the site and play around in a terminal.  
Start pigpiod on boot.  
Run your text script from an exec node to start stop pulses.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 February 2021 14:34 UTC](https://discourse.nodered.org/t/pulse-generator-in-rpi-3b/38825/5 "2021-02-08T14:34:06Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
