Siemens WinCC Checkbox Set & Reset Bit

ansariobaid

Member
Join Date
Mar 2014
Location
Muscat
Posts
15
Hello Everyone!!!

Dear Experts:beerchug:,

I am new to Siemens WinCC:confused::confused:. I have created one Internal Tag 100_XV_01 (Unsigned 32-Bit), All I want to do is, If I check the Checkbox it should Set Bit 0 of the Tag and If i uncheck the checkbox it should Reset Bit 0. Same thing I would like to do with the Push button linked with PLC Tag. Please help me out to solve this issue.

I will be grateful for your kind guidance on the mentioned subject.
 
Thank you sir for you response.
Switch button is not there in WInCC 7.2. There is only Button (Momentary)we can make it switch by activating the Latch Down Property. But In this case how to Link a Tag 100_XV_01 (Unsigned 32-Bit) to set and Reset the Bit 0 for Press and Release of PB respectively???
 
You need two functions to achieve what you want GetPropWord and SetTagDWord.
GetPropWord reads properties (word value) of objects.

Place your script in miscellaneous>Object change of your check box.

First you need to know if your check box is checked or not.
You can do it like this
Code:
selected  = GetPropWord(lpszPictureName, lpszObjectName, "Process");
selected is word type variable.
If selected = 1 check box is checked, if selected = 0 it is not checked.
Basically:
Code:
if(selected == 1)
{
//set bit in tag
}
else
{
reset bit in tag
}
Now when you know when to set and reset bit in your tag you need to do it.
To set bit you need:
tag_val=GetTagDWordWait(TAG); //TAG is your unsigned 32bit tag
temp=tag_val|1; //OR your tag with 1 to set first bit
SetTagDWordWait(TAG, temp); wright new value to tag
To reset bit you need:
tag_val=GetTagDWordWait(TAG); //TAG is your unsigned 32bit tag
temp=tag_val&0xFFFE; //AND your tag with 32bit value where all bits ecxept 1st are set to 1 to reset first bit
SetTagDWordWait(TAG, temp); wright new value to tag
tag_val and temp are DWORD type varialbles.
You can declare variables like this:
Code:
DWORD tag_val,temp;
WORD selected;
put these lines right before main code.
Put it all together and you'll have working script.
 
Thanks a bundle Mr. Moggie, Mr. Marcius and Mr. JesperMP for your kind assistance. I have tested the mentioned things and it worked, thanks a lot once again!!!
 

Similar Topics

Hello colleagues, On a Siemens Multi panel (MP 377 12") of a machine (S7-300) at a customer's site, some parameters need to be changed that have...
Replies
7
Views
298
I thought I was nearly finished on this TIA Portal/s7-1212C project (famous last words)... Up until now, I'd developed the PLC/HMI such that the...
Replies
10
Views
1,554
Hi, I have a HMI which is a KTP1200 Basic. Let's suppose USER03 is logged in. How do I create a simple "Lock Screen" that appears if the screen...
Replies
2
Views
672
Hi, At the moment, If the user fails to provide a valid username/password, the image attached appears "Invalid password or user name. Logon has...
Replies
12
Views
1,568
Hello guys, Im using a siemens with WINCC in a computer and need to import to tag´s data fom a specific row in a SCV file, i have a working...
Replies
15
Views
1,683
Back
Top Bottom