10/30/2010 1:48 PM | |
Posts: 111 Rating: (0) |
Dear Ashok Sridharan, You simply can replace 4 instead of 1 when you want to write a value in the tag and it isn't matter if this tag is binary or not.To make sure, I have copied the program that worked properly. By moving 4 infact you set the third bit of your tag. Dim a,b b=MsgBox("Are you Sure?", vbYesNo, "Question") If b=6 Then Set a=HMIRuntime.Tags("8 unsign bit name") a.Write(4) End If Tell me please if you get your answer or not. Regards |
11/2/2010 6:54 AM | |
Posts: 111 Rating: (0) |
Hi Ashok Sridharan, In order to reset the 8 bit tag, you only need towrite 0 to your tag. To make it completely clear for you I have again copied an example. For instance,you can copy wholebelow programat the mouse action of a new button. Please tell me if your problem solved or not. Dim a,b b=MsgBox("Are you Sure?", vbYesNo, "Question") If b=6 Then Set a=HMIRuntime.Tags("8 unsign bit name") a.Write(0) End If |
11/2/2010 4:03 PM | |
Joined: 5/24/2010 Last visit: 2/8/2022 Posts: 46 Rating: (5) |
Dear Ashok Sridharan, Look: Dim obj,tag Set tag=HMIRuntime.Tags("Tag Name") obj=MsgBox("Are You Sure?", vbYesNo+ vbCritical, "Question") If obj=6 Then tag.Write(tag.Read() Or (2 ^ 2)) Else tag.Write(tag.Read() And Not (2 ^ 2)) End If it should work |
This contribution was helpful to2 thankful Users |
11/4/2010 9:49 AM | |
Joined: 10/3/2010 Last visit: 4/29/2024 Posts: 1552 Rating: (188) |
@r2407, I think your solution is fine as long as no other bit is changed meanwhile. Suppose that in your example, all bits are 0 and you set bit 0 & 3 by putting 9 in the tag. If for example bit 7 is meanwhile set in the PLC and you want to reset afterwards only bit 0 without disturbing the other bits, putting 8 in the tag is not the right options because you will also overwrite bit 7 which is not meant to be, right? for things like this, we have c-script in project functions void SetByteBit (char* tagName, int bit) { BYTE tagValue; BYTE bit2Set; tagValue = GetTagByteWait(tagName); bit2Set = pow(2,bit); tagValue = tagValue | bit2Set; SetTagByteWait(tagName,tagValue); } |
B r g d s , |
|
This contribution was helpful to1 thankful Users |
Follow us on