Page 1 of 1
Tag valueChange event order during a mobus poll
Posted: Wed Oct 24, 2012 2:20 pm
by charliehbeijer
Say I have a modbus master controller in my t7a. Say I have tag T1 bound to modbus address 40001 and T2 bound to modbus address 40002, and I have valueChange handers on both tags.
For a given polling event, assuming the values of T1 and T2 both changed, can I assume the T1.valueChange will fire before T2.valueChange, because of the order of modbus addresses?
Say I also have T17 bound to modbus address 40017. (I gather from the documentation that the modbus master will fetch T17 in a separate package from T1 and T2). Can I assume the valueChange event for T17 will fire after the valueChange for T2?
Is there some sort of "poll complete" event I can handle, so I could be sure all the tags have values based on the polling event?
Re: Tag valueChange event order during a mobus poll
Posted: Wed Oct 24, 2012 2:48 pm
by mark.monroe
You can not assume that the ValueChange event will fire in a given order. iX is multi-threaded and the events are managed by the underlying framework. They may fire in any order.
You can force iX to read a tag in script by calling its Read function, "Globals.Tags.MyTag.Read()".
There is no way to test for a poll complete or trigger a group of tags to be polled.
Re: Tag valueChange event order during a mobus poll
Posted: Wed Oct 24, 2012 4:27 pm
by charliehbeijer
Oh my. The thing is, my modbus slave reports 32-bit floating point numbers in pairs of registers. For example, modbus address 40001 holds the high 16 bits and 40002 holds the low 16 bits of a floating-point number. Say I have tag T1 on 40001 and T2 on 40002. If I handle valueChanged on T1, I don't know if T2 has the new value or the old value.
Can you think of any solution?
Re: Tag valueChange event order during a mobus poll
Posted: Thu Oct 25, 2012 3:21 am
by charliehbeijer
I'll give my solution.
Turns out there is one register in the slave device which always changes. It is a timestamp with one-second resolution. I'll put a valueChange event handler on the tag for that register. When the timestamp changes, I'll set a timer for an absurdly long time - in my case one second, since my polling interval is five seconds. At the end of the one second I am very confident that all the tag values will have settled.
Re: Tag valueChange event order during a mobus poll
Posted: Thu Oct 25, 2012 10:06 am
by Patrick Hall
What format does your device store this 32bit float? If it is a standard IEEE (IEEE 754) or ISO International Standard format (ISO/IEC/IEEE 60559:2011) could you not simply choose a single Tag mapped to 40001 and set the controller type to Float? I have been sending and receiving float values (32bit) over the modbus driver for a while now with no problems.
I have had to change settings on some slaves to get the byte order and word swap settings to match the master. One project communicating with a Mettler Toledo Weigh terminal (IND131) required this approach.
Re: Tag valueChange event order during a mobus poll
Posted: Thu Oct 25, 2012 11:47 am
by charliehbeijer
Well I'll try that, thanks!