Tag valueChange event order during a mobus poll

Discussion of configuring and troubleshooting communication to PLC's or other devices using iX Developer.
Post Reply
charliehbeijer
Posts: 40
Joined: Sat Jun 02, 2012 7:43 am

Tag valueChange event order during a mobus poll

Post 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?

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Tag valueChange event order during a mobus poll

Post 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.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

charliehbeijer
Posts: 40
Joined: Sat Jun 02, 2012 7:43 am

Re: Tag valueChange event order during a mobus poll

Post 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?

charliehbeijer
Posts: 40
Joined: Sat Jun 02, 2012 7:43 am

Re: Tag valueChange event order during a mobus poll

Post 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.

Patrick Hall
Posts: 22
Joined: Fri May 25, 2012 7:44 am
Location: Charlotte, NC. USA

Re: Tag valueChange event order during a mobus poll

Post 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.
Best Regards,
Patrick Hall

charliehbeijer
Posts: 40
Joined: Sat Jun 02, 2012 7:43 am

Re: Tag valueChange event order during a mobus poll

Post by charliehbeijer »

Well I'll try that, thanks!

Post Reply