Signal Generator

Node-RED version of a signal generator.

Screenshot of the Signal Generator Dashboard

About

This flow simulates a signal generator.

It can create:

  • sinus signals
  • rectangular signals
  • sawtooth signals
  • random signals
  • noise signals

You can use it to:

  • simulate a source of data
  • create test messages
  • learn about function nodes

Beschreibung

Dieser Flow simuliert einen Signalgenerator.

Er erzeugt:

  • Sinus-Signale
  • Rechtecks-Signale
  • Sägezahn-Signale
  • Zufalls-Signale
  • Rausch-Signale

Man kann damit:

  • eine Datenquelle simulieren
  • Test-Messages generieren
  • Function-Nodes kennenlernen
[{"id":"3d97c28.21356be","type":"tab","label":"Message Generator A","disabled":false,"info":"- Dieser Message-Generator nutzt eine Rückkoppelung mit Verzögerung um einen Endlosen Strom von Nachrichten zu erzeugen\n- Die Verzögerung kann mit einem Slider verändert werden\n- Vorsicht mit Rückkoppelungen ohne Verzögerung (Das führt zu einer Flut von Nachrichten, die Node-RED lahmlegt)"},{"id":"4de112f423b4a86f","type":"tab","label":"Message Generator B","disabled":true,"info":" - Dieser Generator nutzt einen Injector-Node um Nachrichten zu generieren.\n - Am Anfang wird der das Flow-Attribut flow.counter mit 0 initalisiert.\n - Immer wenn eine Nachricht ankommt wird das Flow-Attribut flow.counter um eins hochgezählt."},{"id":"ec03db3135800605","type":"tab","label":"Signal Generators","disabled":false,"info":""},{"id":"da69ae5c8f93d111","type":"ui_tab","name":"Node-Red Dashboard","icon":"dashboard","disabled":false,"hidden":false},{"id":"587ff1ff10473f73","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#008000","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#008000","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#008000","edited":true},"page-titlebar-backgroundColor":{"value":"#008000","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#333333","edited":false},"group-textColor":{"value":"#00cc00","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#008000","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey","palette":"light"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD.MM.YYYY","sizes":{"sx":120,"sy":40,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"a0e246d1b4737443","type":"ui_group","name":" Signal-Generator","tab":"da69ae5c8f93d111","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"e2d9b4bc01a24b30","type":"delay","z":"3d97c28.21356be","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":530,"y":160,"wires":[["67c4ef4de49bcc61","033fd9b0ea9b4527"]]},{"id":"2746133720b77f16","type":"inject","z":"3d97c28.21356be","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":90,"y":160,"wires":[["e2d9b4bc01a24b30"]]},{"id":"67c4ef4de49bcc61","type":"function","z":"3d97c28.21356be","name":"payload++","func":"msg.payload = msg.payload +  1;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":320,"wires":[["e2d9b4bc01a24b30"]]},{"id":"185e555379e54049","type":"comment","z":"3d97c28.21356be","name":"VARIANTE A)  Message Loop","info":"","x":160,"y":60,"wires":[]},{"id":"67bb106c74ddf404","type":"inject","z":"4de112f423b4a86f","name":"10 msg/s","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":110,"y":280,"wires":[["cba831ab02d964a5"]]},{"id":"cba831ab02d964a5","type":"change","z":"4de112f423b4a86f","name":"msg.payload = flow.counter","rules":[{"t":"set","p":"payload","pt":"msg","to":"counter","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":280,"wires":[["211c14f497a77bc6"]]},{"id":"211c14f497a77bc6","type":"function","z":"4de112f423b4a86f","name":"flow.counter++","func":"let counter = flow.get('counter');\nflow.set('counter', counter + 1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":280,"wires":[["32ae07ea6a27e4fd"]]},{"id":"496c1a1bd4f85bbf","type":"inject","z":"4de112f423b4a86f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":110,"y":160,"wires":[["59a32527878569de"]]},{"id":"59a32527878569de","type":"change","z":"4de112f423b4a86f","name":"flow.counter = 0;","rules":[{"t":"set","p":"counter","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":160,"wires":[[]]},{"id":"d4d8e2c36b825032","type":"comment","z":"4de112f423b4a86f","name":"Initialisierung (1 x am Anfang)","info":"","x":160,"y":120,"wires":[]},{"id":"133aeac8b2de30b6","type":"comment","z":"4de112f423b4a86f","name":"Message Generator (2 x pro Sekunde)","info":"","x":190,"y":240,"wires":[]},{"id":"d74e19cf662e1a2f","type":"comment","z":"4de112f423b4a86f","name":"VARIANTE B)  Flow Counter hochzählen","info":"","x":190,"y":60,"wires":[]},{"id":"807c3b37a29af64a","type":"comment","z":"3d97c28.21356be","name":"Nachricht 1 x am Anfang losschicken","info":"","x":180,"y":120,"wires":[]},{"id":"ccaa806dc3bf375d","type":"comment","z":"3d97c28.21356be","name":"Payload um 1 erhöhen","info":"","x":540,"y":360,"wires":[]},{"id":"93e17ad839ba665f","type":"comment","z":"3d97c28.21356be","name":"Kurze Pause","info":"","x":510,"y":120,"wires":[]},{"id":"32ae07ea6a27e4fd","type":"link out","z":"4de112f423b4a86f","name":"Signal Generator B OUT","links":["658d1c8bc3824c53","4e97d11ad223cb7a"],"x":805,"y":280,"wires":[]},{"id":"033fd9b0ea9b4527","type":"link out","z":"3d97c28.21356be","name":"Message Genrator A OUT","links":["658d1c8bc3824c53","4e97d11ad223cb7a"],"x":775,"y":160,"wires":[]},{"id":"585f12cec57d893d","type":"comment","z":"3d97c28.21356be","name":"Link zu einen anderen Flow","info":"","x":880,"y":120,"wires":[]},{"id":"fab5a8b38038edb6","type":"function","z":"ec03db3135800605","name":"Sinus-Generator","func":"var x = msg.payload * Math.PI / 4;\nmsg.payload = 0.5 + 0.5 * Math.sin(x);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1300,"y":120,"wires":[["5b5c57fad12e15e9"]]},{"id":"497d5073678f7fcb","type":"function","z":"ec03db3135800605","name":"Rechteck-Generator","func":"var x = msg.payload / 4.0;\nmsg.payload = Math.floor(x) % 2;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1320,"y":180,"wires":[["5b5c57fad12e15e9"]]},{"id":"5ce9cc0caa814c1e","type":"function","z":"ec03db3135800605","name":"Sägezahn-Generator","func":"var x = msg.payload / 4.0;\n\n// nachkommastellen extrahieren\nvar y = x - Math.floor(x);\n\n// anpassung, damit die werte tatsächlich bis eins gehen\nvar f = flow.get(\"inputscale\") * 4;\ny = y * f / (f - 1);\n\nmsg.payload = y;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1320,"y":240,"wires":[["5b5c57fad12e15e9"]]},{"id":"ee839400c55291cf","type":"function","z":"ec03db3135800605","name":"Zufalls-Generator","func":"msg.payload = Math.random();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1310,"y":300,"wires":[["5b5c57fad12e15e9"]]},{"id":"57305ffdd187d46c","type":"function","z":"ec03db3135800605","name":"Input-Skalierung","func":"let factor = flow.get(\"inputscale\");\nmsg.payload = msg.payload / factor;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":140,"wires":[["eb5c38c895e0bd9a"]]},{"id":"4e97d11ad223cb7a","type":"link in","z":"ec03db3135800605","name":"Signal Generator IN","links":["033fd9b0ea9b4527","32ae07ea6a27e4fd"],"x":255,"y":140,"wires":[["de67e6d5030992f5"]]},{"id":"0fee2180f03bde24","type":"comment","z":"ec03db3135800605","name":"Input mit Faktor multiplizieren","info":"","x":660,"y":80,"wires":[]},{"id":"eb5c38c895e0bd9a","type":"switch","z":"ec03db3135800605","name":"","property":"generator","propertyType":"flow","rules":[{"t":"eq","v":"sinus","vt":"str"},{"t":"eq","v":"square","vt":"str"},{"t":"eq","v":"sawtooth","vt":"str"},{"t":"eq","v":"random","vt":"str"},{"t":"eq","v":"noise","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":890,"y":140,"wires":[["fab5a8b38038edb6"],["497d5073678f7fcb"],["5ce9cc0caa814c1e"],["ee839400c55291cf"],["529f11c31beecc11"]]},{"id":"5b5c57fad12e15e9","type":"function","z":"ec03db3135800605","name":"Output-Skalierung","func":"let factor = flow.get(\"outputscale\");\nmsg.payload = msg.payload * factor;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1650,"y":180,"wires":[["25c7a108271f89c5","2630b5bf57eb1480"]]},{"id":"fc031ec33ce9ebb9","type":"change","z":"ec03db3135800605","name":"","rules":[{"t":"set","p":"inputscale","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":580,"wires":[["ee36f53d36143dbf"]]},{"id":"1cec7372dd8cf72c","type":"change","z":"ec03db3135800605","name":"","rules":[{"t":"set","p":"outputscale","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":640,"wires":[["3245d8dcd7f87484"]]},{"id":"3a3e2fdd052aa529","type":"ui_dropdown","z":"ec03db3135800605","name":"Signal Selector","label":"<strong>Signal Auswahl:</strong>","tooltip":"","place":"Select option","group":"a0e246d1b4737443","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Sinus","value":"sinus","type":"str"},{"label":"Rechteck","value":"square","type":"str"},{"label":"Sägezahn","value":"sawtooth","type":"str"},{"label":"Zufall","value":"random","type":"str"},{"label":"Rauschen","value":"noise","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":420,"y":700,"wires":[["5971b6e3f9436581"]]},{"id":"5971b6e3f9436581","type":"change","z":"ec03db3135800605","name":"","rules":[{"t":"set","p":"generator","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":700,"wires":[[]]},{"id":"c3e4f341804dd063","type":"inject","z":"ec03db3135800605","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"0.5","payloadType":"num","x":190,"y":580,"wires":[["b23b53cbfd303b6a"]]},{"id":"7215e4ca0cd23e91","type":"inject","z":"ec03db3135800605","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"1","payloadType":"num","x":190,"y":640,"wires":[["e020edd0a7c35558"]]},{"id":"60e9d52518b88531","type":"inject","z":"ec03db3135800605","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"sinus","payloadType":"str","x":190,"y":700,"wires":[["3a3e2fdd052aa529"]]},{"id":"3d8f6242a8230460","type":"comment","z":"ec03db3135800605","name":"Initialisierung","info":"","x":210,"y":460,"wires":[]},{"id":"426884707047b442","type":"comment","z":"ec03db3135800605","name":"Einstellungen","info":"","x":410,"y":460,"wires":[]},{"id":"a8b4f2dee74df532","type":"comment","z":"ec03db3135800605","name":"Flow-Attribute setzen","info":"","x":640,"y":460,"wires":[]},{"id":"caafeb52e611fc9a","type":"comment","z":"ec03db3135800605","name":"Output mit Faktor multiplizieren","info":"","x":1690,"y":120,"wires":[]},{"id":"e055a24fdc150e18","type":"comment","z":"ec03db3135800605","name":"Message Routing","info":"","x":920,"y":60,"wires":[]},{"id":"999ddf89646c036b","type":"comment","z":"ec03db3135800605","name":"Funktions-Generatoren","info":"","x":1320,"y":60,"wires":[]},{"id":"e020edd0a7c35558","type":"ui_slider","z":"ec03db3135800605","name":"Output Slider","label":"<strong>Ausgangs-Skalierung</strong>","tooltip":"","group":"a0e246d1b4737443","order":5,"width":"5","height":"1","passthru":true,"outs":"all","topic":"topic","topicType":"msg","min":0,"max":10,"step":"0.1","className":"","x":410,"y":640,"wires":[["1cec7372dd8cf72c"]]},{"id":"b23b53cbfd303b6a","type":"ui_slider","z":"ec03db3135800605","name":"Input Slider","label":"<strong>Eingangs-Skalierung</strong>","tooltip":"","group":"a0e246d1b4737443","order":3,"width":"5","height":"1","passthru":true,"outs":"all","topic":"topic","topicType":"msg","min":"1","max":"10","step":"1","className":"","x":410,"y":580,"wires":[["fc031ec33ce9ebb9"]]},{"id":"3245d8dcd7f87484","type":"ui_template","z":"ec03db3135800605","group":"a0e246d1b4737443","name":"Output Display","order":6,"width":"1","height":"1","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":900,"y":640,"wires":[[]]},{"id":"ee36f53d36143dbf","type":"ui_template","z":"ec03db3135800605","group":"a0e246d1b4737443","name":"Input Display","order":4,"width":"1","height":"1","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":890,"y":580,"wires":[[]]},{"id":"b08520b966c8dfa5","type":"ui_template","z":"ec03db3135800605","group":"a0e246d1b4737443","name":"Anzeige","order":7,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2120,"y":240,"wires":[[]]},{"id":"25c7a108271f89c5","type":"template","z":"ec03db3135800605","name":"Letzter Wert","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<strong>Letzter Wert:</strong> {{payload}}","output":"str","x":1930,"y":240,"wires":[["b08520b966c8dfa5"]]},{"id":"2630b5bf57eb1480","type":"ui_chart","z":"ec03db3135800605","name":"Plot","group":"a0e246d1b4737443","order":1,"width":"6","height":"6","label":"<strong>10 Sekunden Plot</strong>","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"1000","removeOlderUnit":"1","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#008000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1910,"y":180,"wires":[[]]},{"id":"529f11c31beecc11","type":"function","z":"ec03db3135800605","name":"Noise-Generator","func":"// alten wert aus dem kontext laden\nvar yold = context.get('y') || 0;\n\n// zufallswert addieren\nvar factor = 1.0 / flow.get(\"inputscale\");\nvar ynew = yold + (Math.random() - 0.5) * factor;\n\n// intervall beachten!\nynew = Math.max(0, ynew);\nynew = Math.min(1, ynew);\n\n// neuen wert speichen\ncontext.set('y', ynew);\n\nmsg.payload = ynew;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1300,"y":360,"wires":[["5b5c57fad12e15e9"]]},{"id":"f6400a0bfd940897","type":"ui_switch","z":"ec03db3135800605","name":"Switch","label":"Schalter","tooltip":"","group":"a0e246d1b4737443","order":7,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":390,"y":520,"wires":[["e272a5a5411ce544"]]},{"id":"e006a84955e5ebf8","type":"inject","z":"ec03db3135800605","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":190,"y":520,"wires":[["f6400a0bfd940897"]]},{"id":"e272a5a5411ce544","type":"change","z":"ec03db3135800605","name":"","rules":[{"t":"set","p":"active","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":520,"wires":[[]]},{"id":"ca1d52f2cf59d1cb","type":"comment","z":"ec03db3135800605","name":"Filter","info":"","x":390,"y":80,"wires":[]},{"id":"de67e6d5030992f5","type":"switch","z":"ec03db3135800605","name":"Flow Active?","property":"active","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":140,"wires":[["57305ffdd187d46c"]]}]

Flow Info

Created 3 years, 6 months ago
Rating: 4.666666666666667 3

Owner

Actions

Rate:

Node Types

Core
  • change (x6)
  • comment (x16)
  • delay (x1)
  • function (x9)
  • inject (x7)
  • link in (x1)
  • link out (x2)
  • switch (x2)
  • template (x1)
Other

Tags

  • signal
  • generator
  • sensor
  • noise
  • sinus
  • sawtooth
  • rectangular
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option