Time Delay For Pulse Trigger Digital Output

#1

Hi All,

I'm stuck in delay function for pulse delay signal High and Low. I've tried trigger node, but i cant control the low signal time. So, i want control relay with specific time in high position and low position.

image

[{"id":"b906ff4d.da3d3","type":"ui_chart","z":"c5964b54.39bb98","name":"","group":"6a67f261.dd3924","order":0,"width":"0","height":"0","label":"Pressure Intake Real","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"4","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":853.0000076293945,"y":269.3333692550659,"wires":[[],[]]},{"id":"7c278af4.03c094","type":"comment","z":"c5964b54.39bb98","name":"0 = ON ; 1=OFF","info":"","x":843.3333740234375,"y":435,"wires":[]},{"id":"1c939f07.8abe49","type":"modbus-read","z":"c5964b54.39bb98","name":"pi","topic":"pi","showStatusActivities":false,"showErrors":false,"unitid":"6","dataType":"InputRegister","adr":"200","quantity":"1","rate":"1000","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"7a22729d.02c024","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":175,"y":348.3333435058594,"wires":[["2e941233.01da86"],["1c33c696.aad3a1"]]},{"id":"1c33c696.aad3a1","type":"modbus-response","z":"c5964b54.39bb98","name":"","registerShowMax":20,"x":415,"y":368.3333435058594,"wires":[]},{"id":"73f55646.e7ef5","type":"rpi-gpio out","z":"c5964b54.39bb98","name":"","pin":"13","set":true,"level":"1","freq":"","out":"out","x":906.3331909179688,"y":662.6666564941406,"wires":[]},{"id":"625f1c8.b974364","type":"ui_text","z":"c5964b54.39bb98","group":"ddeba1c2.c1e0f8","order":0,"width":0,"height":0,"name":"","label":"Pi Real","format":"{{msg.payload}} ","layout":"col-center","x":785,"y":308.3333435058594,"wires":[]},{"id":"33b030d8.49a7d","type":"modbus-response","z":"c5964b54.39bb98","name":"","registerShowMax":20,"x":423.00000762939453,"y":129.33336925506592,"wires":[]},{"id":"322d854c.ff7b72","type":"function","z":"c5964b54.39bb98","name":"Global Variable Declare","func":"global.set(\"pi\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":583.0000076293945,"y":309.3333692550659,"wires":[["625f1c8.b974364","b906ff4d.da3d3","8f82dc90.12a7b"]]},{"id":"89f08e22.6a6ff","type":"modbus-read","z":"c5964b54.39bb98","name":"setpoint","topic":"setpoint","showStatusActivities":false,"showErrors":false,"unitid":"6","dataType":"InputRegister","adr":"130","quantity":"1","rate":"1000","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"7a22729d.02c024","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":175,"y":188.33334350585938,"wires":[["33b030d8.49a7d","46c08db1.a80524"],[]]},{"id":"ab7216fd.84514","type":"function","z":"c5964b54.39bb98","name":"Global Variable Declare","func":"global.set(\"setpoint\",msg.payload);\nreturn msg;\n","outputs":1,"noerr":0,"x":663.0000076293945,"y":189.33336925506592,"wires":[["30e01438.d23794"]]},{"id":"30e01438.d23794","type":"ui_text","z":"c5964b54.39bb98","group":"ddeba1c2.c1e0f8","order":0,"width":0,"height":0,"name":"","label":"Pi Setpoint","format":"{{msg.payload}} ","layout":"col-center","x":863.0000076293945,"y":189.33336925506592,"wires":[]},{"id":"4088fa7.8d1d784","type":"function","z":"c5964b54.39bb98","name":"Raise","func":"var setpoint = global.get(\"setpoint\");\nvar pi=global.get(\"pi\");\n\nif (setpoint > pi)\n{\n return {payload: \"1\"}\n} \n\nelse {\n return {payload: \"0\"}\n}\n\n\n\n","outputs":1,"noerr":0,"x":375,"y":528.3333435058594,"wires":[["7dfda5ad.862a7c"]]},{"id":"b104f6eb.96e69","type":"inject","z":"c5964b54.39bb98","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":195,"y":528.3333435058594,"wires":[["4088fa7.8d1d784"]]},{"id":"7dfda5ad.862a7c","type":"rpi-gpio out","z":"c5964b54.39bb98","name":"","pin":"11","set":true,"level":"1","freq":"","out":"out","x":804.6666259765625,"y":526.0000610351562,"wires":[]},{"id":"5f54d5bb.79f7f4","type":"function","z":"c5964b54.39bb98","name":"Lower","func":"var setpoint = global.get(\"setpoint\");\nvar pi=global.get(\"pi\");\n\nif (setpoint < pi)\n{\n return {payload: \"0\"}\n} \n\nelse {\n return {payload: \"1\"}\n}\n\n\n","outputs":1,"noerr":0,"x":375,"y":668.3333435058594,"wires":[["3c67b48f.361f7c"]]},{"id":"cca7195e.51d7b","type":"inject","z":"c5964b54.39bb98","name":"","topic":"","payload":"","payloadType":"date","repeat":"0.095","crontab":"","once":false,"onceDelay":0.1,"x":195,"y":668.3333435058594,"wires":[["5f54d5bb.79f7f4"]]},{"id":"8e367b36.189f68","type":"comment","z":"c5964b54.39bb98","name":"Condition Setpoint Higher Than Real Value","info":"","x":273.00000762939453,"y":609.3333692550659,"wires":[]},{"id":"111878b3.d0ff97","type":"comment","z":"c5964b54.39bb98","name":"Condition Setpoint Lower Than Real Value","info":"","x":273.00000762939453,"y":469.3333692550659,"wires":[]},{"id":"a88cd6ad.683908","type":"comment","z":"c5964b54.39bb98","name":"Get Pi Modbus Data","info":"","x":215,"y":268.3333435058594,"wires":[]},{"id":"3cbe1437.d2e12c","type":"comment","z":"c5964b54.39bb98","name":"Get Setpoint Modbus Data","info":"","x":235,"y":88.33334350585938,"wires":[]},{"id":"2e941233.01da86","type":"function","z":"c5964b54.39bb98","name":"","func":"msg.payload=msg.payload/10;\nreturn msg;","outputs":1,"noerr":0,"x":235,"y":308.3333435058594,"wires":[["8823440d.bb5bb"]]},{"id":"8f82dc90.12a7b","type":"ui_gauge","z":"c5964b54.39bb98","name":"","group":"6a67f261.dd3924","order":0,"width":"0","height":"0","gtype":"gage","title":"PI Real","label":"Psi","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":780,"y":346.3333435058594,"wires":[]},{"id":"3961e4f8.9e12a4","type":"ui_text","z":"c5964b54.39bb98","group":"523f1271.dae8dc","order":0,"width":0,"height":0,"name":"","label":"Set Point Pi","format":"{{msg.payload}}","layout":"row-spread","x":453.38885498046875,"y":938.4445190429688,"wires":[]},{"id":"53d90ff9.284838","type":"modbus-write","z":"c5964b54.39bb98","name":"","showStatusActivities":false,"showErrors":false,"unitid":"6","dataType":"HoldingRegister","adr":"130","quantity":"1","server":"7a22729d.02c024","x":435.3888397216797,"y":880.4444932937622,"wires":[[],["97206510.d28e9"]]},{"id":"97206510.d28e9","type":"modbus-response","z":"c5964b54.39bb98","name":"","registerShowMax":20,"x":660.3888549804688,"y":884.1112670898438,"wires":[]},{"id":"8823440d.bb5bb","type":"function","z":"c5964b54.39bb98","name":"","func":"msg.payload = msg.payload.toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"x":383.00000762939453,"y":309.3333692550659,"wires":[["322d854c.ff7b72"]]},{"id":"46c08db1.a80524","type":"function","z":"c5964b54.39bb98","name":"","func":"msg.payload=msg.payload/1;\nreturn msg;","outputs":1,"noerr":0,"x":323.00000762939453,"y":189.33336925506592,"wires":[["c950d572.732178"]]},{"id":"c950d572.732178","type":"function","z":"c5964b54.39bb98","name":"","func":"msg.payload = msg.payload.toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"x":443.00000762939453,"y":189.33336925506592,"wires":[["ab7216fd.84514"]]},{"id":"6a982d0.343fb54","type":"ui_text_input","z":"c5964b54.39bb98","name":"","label":"Set Pi","group":"523f1271.dae8dc","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":"300","topic":"","x":102.99994659423828,"y":891.0000867843628,"wires":[["53d90ff9.284838","3961e4f8.9e12a4"]]},{"id":"19f386b9.bdcdd1","type":"inject","z":"c5964b54.39bb98","name":"","topic":"","payload":"100","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":135.83334350585938,"y":143.33334350585938,"wires":[["46c08db1.a80524"]]},{"id":"6a604045.cbf21","type":"inject","z":"c5964b54.39bb98","name":"","topic":"","payload":"10","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":142.22222900390625,"y":402.22222900390625,"wires":[["2e941233.01da86"]]},{"id":"3c67b48f.361f7c","type":"delay","z":"c5964b54.39bb98","name":"","pauseType":"delay","timeout":"0.095","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":609.166748046875,"y":669.4443664550781,"wires":[["73f55646.e7ef5"]]},{"id":"f15a88f.6b73178","type":"inject","z":"c5964b54.39bb98","name":"","topic":"","payload":"0","payloadType":"str","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":392.5000305175781,"y":711.6666259765625,"wires":[["a5bd8b10.0fd9a8"]]},{"id":"a5bd8b10.0fd9a8","type":"delay","z":"c5964b54.39bb98","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":598.888916015625,"y":710.5554504394531,"wires":[["73f55646.e7ef5"]]},{"id":"6a67f261.dd3924","type":"ui_group","z":"","name":"Chart Realtime","tab":"178311c4.46912e","disp":true,"width":"6","collapse":false},{"id":"7a22729d.02c024","type":"modbus-client","z":"","name":"GDM Tipe B","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"6","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"ddeba1c2.c1e0f8","type":"ui_group","z":"","name":"Downhole Sensor Realtime Data","tab":"178311c4.46912e","disp":true,"width":"6","collapse":false},{"id":"523f1271.dae8dc","type":"ui_group","z":"","name":"Pressure Intake Real Time","tab":"178311c4.46912e","disp":true,"width":"6","collapse":false},{"id":"178311c4.46912e","type":"ui_tab","z":"","name":"Downhole Sensor","icon":"dashboard"}]

Regards,
wiguna

0 Likes

#2

here's a couple of examples to produce pulses of defined 1/0 times

the top one will produce a 1 for 3 secs and a 0 for 1 sec

the bottom one will produce a continuous train of pulses like that

[{"id":"43eda91e.221358","type":"inject","z":"e4e1f6c6.d50648","name":"","topic":"","payload":"start","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":180,"wires":[["6c4ea6e1.a2d528","474d7dbb.e90f64"]]},{"id":"6c4ea6e1.a2d528","type":"trigger","z":"e4e1f6c6.d50648","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"3","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":480,"y":160,"wires":[["d64ef6b.74d3908"]]},{"id":"474d7dbb.e90f64","type":"trigger","z":"e4e1f6c6.d50648","op1":"","op2":"finished","op1type":"nul","op2type":"str","duration":"4","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":480,"y":220,"wires":[["d64ef6b.74d3908"]]},{"id":"d64ef6b.74d3908","type":"debug","z":"e4e1f6c6.d50648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":180,"wires":[]},{"id":"cf90e92d.32c6a8","type":"inject","z":"e4e1f6c6.d50648","name":"","topic":"","payload":"start","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":380,"wires":[["80fd4145.02be7"]]},{"id":"80fd4145.02be7","type":"trigger","z":"e4e1f6c6.d50648","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"3","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":620,"y":380,"wires":[["3e263cde.16c344","95500936.6dd878"]]},{"id":"3e263cde.16c344","type":"debug","z":"e4e1f6c6.d50648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":380,"wires":[]},{"id":"14cfbea5.9851f1","type":"delay","z":"e4e1f6c6.d50648","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":460,"wires":[["80fd4145.02be7"]]},{"id":"95500936.6dd878","type":"switch","z":"e4e1f6c6.d50648","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":460,"wires":[["14cfbea5.9851f1"]]},{"id":"1bfc8878.37cde8","type":"inject","z":"e4e1f6c6.d50648","name":"reset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":460,"wires":[["4b2947a2.e420f8"]]},{"id":"4b2947a2.e420f8","type":"change","z":"e4e1f6c6.d50648","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":460,"wires":[["80fd4145.02be7","14cfbea5.9851f1"]]}]
0 Likes

#3

Errr. why not just use a repeating inject set for the overall period... and single trigger node ?

[{"id":"fc1d822d.5bd83","type":"inject","z":"dfe4ec36.0a5a5","name":"4 secs","topic":"","payload":"1","payloadType":"num","repeat":"4","crontab":"","once":false,"onceDelay":0.1,"x":550,"y":580,"wires":[["ee6bdd03.70486"]]},{"id":"ee6bdd03.70486","type":"trigger","z":"dfe4ec36.0a5a5","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"3","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":700,"y":580,"wires":[["7c25a8e4.81d748"]]},{"id":"7c25a8e4.81d748","type":"debug","z":"dfe4ec36.0a5a5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","hideButton":false,"x":870,"y":580,"wires":[]}]
2 Likes

#4

Safety time :zap:

I do like the simplicity of the solution of @dceejay :slight_smile:
But for elementary safety reasons it should never used directly in real application with real equipment.

There should be some easy way option to stop the timer at any point of time
If flow is running, the interruption of running timer should be avoided. (inject node allows re-trigger with button)

Safety first :slight_smile:

0 Likes

#5

Hi All,

Thank you for all advice. Now i can make the time for high and low. This signal using to rise/lower frequency variable speed drive, so there is need to setup specific time to make the drive working fine. The minimum length of time for change the frequency is 0.1 ms for trigger and 10 s to make up & down frequency very slow.

0 Likes