Modbus Serial Polling interval
-
Hi,
I am currently using modbus serial datasource for communicating with my devices and got into a issue.
I have several devices in RS485 communication link but I want to use different polling times on different data points.
Is it possible to use custom update period on different data points which are being used in the data source?
Or I have to create a new data source for every datapoint which update period is different and use multiple RS485 ports and assign the datapoints accordingly.
Thanks,
Thomas -
Hi Thomas,
There is no way to set different polling intervals on the data points. An idea of perhaps limiting the poll on a datapoint to every Nth poll seems easy and elegant, but there is not currently a way to do it.
Your intuition is correct, you would have to use multiple data sources with multiple serial ports.
The only workaround I have for you to achieve what you're describing isn't especially elegant, but you could use a scripting datasource to disable the points you don't want polling, and then enable them when you want them polled. Lots of the builtin UI will probably display warnings about the point being disabled (watchLists especially) that may be undesirable but not harmful.
I imagine the script executing on cron 0/1 * * * * ? and doing something like (not tested...)...
var controlledXids = { "DP_12345":5, "DP_67890":10 } var now = new Date(); for( var xid in controlledXids ) { if( now.getSeconds() % controlledXids[xid] == 0 && !RuntimeManager.isDataPointEnabled(xid)) { RuntimeManager.enableDataPoint(xid); } else if (RuntimeManager.isDataPointEnabled(xid)) { RuntimeManager.disableDataPoint(xid); } }
You could try it with the RuntimeManager.refreshDataPoint(xid) but I think that may increase the load on your network. Doing it through enabling and disabling will let the data source handle it, but will make a little more work for your system. The general idea is to correlate an XID to a poll rate in seconds in the controlledXids object.
Edit: This operates under the assumption the Modbus data source is polling every second. You may get better results doing this from a Meta point that is triggered on a context update triggered by a point that you will always leave enabled on the modbus data source. This way the timing issues are resolved, since the meta point would run between modbus polls.
-
Hi Phil,
Thanks for your prompt reply.
The idea of using meta data came into question but the solution was a bit tricky to be thought of.
Thank you for the valuable information. Is there a documentation about RuntimeManager functions somewhere? Maybe you could link it ?
Big thanks,
Thomas -
If you click the Help icon for either the Meta Data Point or the Scripting Data Source there is a link in the bottom section of the help to 'Mango Java Script' which contains lots of good information, including documentation of the RuntimeManager's functions. The same information can be found here:
http://help.infiniteautomation.com/support/solutions/articles/14000022520-about-mango-java-script