How to control the frequency of a message in modbus dynamically

Hi.
I have searched high and low for a node that could handle this but nothing seemed to be available.
Im using the Modbus getter nodes. You can control the polling frequency by injecting the input of the getter nodes with any message. using the core inject node you can set it up and leave it to poll indefinetly.

Im trying to find a way i can dynamically alter the speed of the polling.
The end scenario will be a mqtt input node passing a msg object with a number payload. the number will control the polling dynamically. The output payload will speed up and down as per the value i send.

Does anyone know of a node capable of doing this or would i need to write this in a function node ?

Thanks

Anyone have any ideas ?

First thing I would think of is using a delay node and some kind of loop where you set the delay property to your needs. You would need the start the loop once at start-up using a trigger node.

Basically something like:

[{"id":"8abca4e5.2422e","type":"inject","z":"c154316d.413728","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":310,"y":280,"wires":[["fdac95ba.4bc3c8"]]},{"id":"fdac95ba.4bc3c8","type":"delay","z":"c154316d.413728","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":520,"y":280,"wires":[["f1687e0d.6dea38"]]},{"id":"137b8350.1c0e0d","type":"debug","z":"c154316d.413728","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":990,"y":280,"wires":[]},{"id":"3102c38b.63b7b4","type":"change","z":"c154316d.413728","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"1000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":400,"wires":[["fdac95ba.4bc3c8"]]},{"id":"f1687e0d.6dea38","type":"function","z":"c154316d.413728","name":"(modbus get)","func":"\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":280,"wires":[["3102c38b.63b7b4","137b8350.1c0e0d"]]}]

Needs some fine tuning and some extra nodes to control the loop (break behavior), but should give the general idea.

Thanks Kuema.
Delay node it is. I was hoping there was a node that packed all the functions.

Here is the flow. Works well. The idea is to replace the slider with Mqtt.

[{"id":"8edb54a2.4f9348","type":"inject","z":"49c5393e.540eb8","name":"","topic":"","payload":"Poll","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":210,"y":120,"wires":[["dc08b636.516748"]]},{"id":"dc08b636.516748","type":"delay","z":"49c5393e.540eb8","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":180,"wires":[["b976b2b1.9da97"]]},{"id":"5f2ce01c.9f2ac","type":"debug","z":"49c5393e.540eb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":180,"wires":[]},{"id":"bef1b27b.ec59f","type":"change","z":"49c5393e.540eb8","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"number","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":300,"wires":[["dc08b636.516748"]]},{"id":"b976b2b1.9da97","type":"function","z":"49c5393e.540eb8","name":"(modbus get)","func":"\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":180,"wires":[["5f2ce01c.9f2ac","bef1b27b.ec59f"]]},{"id":"9427554a.eff3c8","type":"ui_slider","z":"49c5393e.540eb8","name":"","label":"slider","tooltip":"","group":"9180e33e.1a4c2","order":0,"width":0,"height":0,"passthru":true,"outs":"all","topic":"msg.delay","min":"1000","max":"10000","step":"1000","x":250,"y":360,"wires":[["28bb28d5.293468"]]},{"id":"28bb28d5.293468","type":"change","z":"49c5393e.540eb8","name":"","rules":[{"t":"set","p":"number","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":360,"wires":[[]]},{"id":"9180e33e.1a4c2","type":"ui_group","z":"","name":"Solar","tab":"2d5d3e80.108712","order":1,"disp":true,"width":"6","collapse":false},{"id":"2d5d3e80.108712","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

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