Dot Field in InTouch

Riddler

Member
Join Date
Apr 2023
Location
Colombo
Posts
3
What is the meaning of this analog expression? I understand the default dot field such as .Value, .Ack, .HiLimit etc. But I don't understand which property accessing by .00,...,.07

L18M1_STAT.00 + (L18M1_STAT.01 * 2) + (L18M1_STAT.02 * 2) + (L18M1_STAT.03 * 16) + (L18M1_STAT.05 * 8) + (L18M1_STAT.06 * 16) + (L18M1_STAT.07 * 16)

L18M1_STAT is a byte variable.

eventually, I need to convert this to WINCC supported expression.
 
Last edited:
In that context, the compiler casts the individual bit (boolean) expressions (e.g. L18M1_STAT.03) as integers with a value of 0 or 1.

An alternative but equivalent form would be
(L18M1_STAT AND 3) + ((L18M1_STAT AND 4) / 2) + ((L18M1_STAT AND 8) * 2) + ((L18M1_STAT AND 96) / 4) + ((L18M1_STAT AND 128) / 8)
assuming the AND in that context is interpreted by the compiler as a bitwise operator.
 
Thank you everyone. Now it's clear.
By the way, I couldn't simplified the expression as you mentioned drbitboy. I have derived it as followings. But don't know how to simplify further. Could you please explain?

L18M1_STAT AND 1 + (L18M1_STAT AND 2) * 2 + (L18M1_STAT AND 4) * 2 + (L18M1_STAT AND 8)*16 + (L18M1_STAT AND 32)*8 + (L18M1_STAT AND 64)*16 + (L18M1_STAT AND 128)*16
 
If the bit L18M1_STAT.03 has a value of 1, the the expression (L18M1_STAT AND 8) should have a value of 8. Since the multiplier of bit .03 is 16 in the original expression, multiplying (L18M1_STAT AND 8) (=> 8 or 0) by 2 gives the same result (i.e. 2*8 => 16 or 2*0 => 0).

TL;DR

The "AND 8" performs an bitwise masking of the bits in the integer L19M1_STAT.

The integer value "8" has bit 03 set (=1); all other bits 00-02, 04-07 are cleared (=0).

So when when we do a bitwise integer AND of the eight bits in L18M1_STAT with the integer mask with a value of 8, each bit of integer LM18M1_STAT is logically ANDed with the corresponding bit of the integer value 8:

Code:
[U]Bit#        => 7 6 5 4  3 2 1 0[/U]

LM18M1_STAT    x x x x  [B][COLOR=#ff0000][I]?[/I][/COLOR][/B] x x x
                    |
                   AND
                    |
                    v
Mask=8         0 0 0 0  [B][COLOR=#ff0000][I]1[/I][/COLOR][/B] 0 0 0

                    |
                    =
                    |
                    v
 Result         0 0 0 0  [B][COLOR=#ff0000][I]?[/I][/COLOR][/B] 00 0
The result value will either be the integer value 8 if ? is 1, or will be the integer value 0 if ? is 0.

"x" means we don't care if a bit is 0 or 1, because those bits are always masked out to 0 in the result i.e. their corresponding bits in the ANDed result will be 0 because their corresponding bits in the mask are 0.

In the original formula, that bit L19M1_STAT.03 was used in a expression as + (L18M1_STAT.03 * 16), so if the bit 03 is 1 or 0, then the integer value added to the sum was 16 or 0, respectively.

So when using my ANDed expression, if the integer result of (L18M1_STAT AND 8) has a value of 8 or 0, then multiplying it by 2, via the expression + ((L18M1_STAT AND 8) * 2), adds an integer value of either 16 or 0, respectively, to the sum, just like the original (L18M1_STAT.03 * 16) expression.
 

Similar Topics

Hi guys, I write a script on a button's action: interlockcheck5 is a indirect tag(I/o descrete), gassing_hood_in and gassing hood out are (I/o...
Replies
7
Views
2,152
Morning gents, I've got an existing program infront of me from a wastewater plant that has some custom AOIs in it, and one of the icons has a...
Replies
3
Views
949
Hello, I have an issue with the latest version of FTView Studio 12.00 where when I select the 3 dot button as is displayed in the photo...
Replies
8
Views
4,126
RSLogix 500, what is the little image next to the ladder in the project tree? it looks like a little blue bug with a red dot on its back. just...
Replies
5
Views
2,045
Can you use dot fields in View SE like you can in Wonderware? I'm using a single template for HOAs and PIDs and want to reference the tag's...
Replies
2
Views
1,725
Back
Top Bottom