WinCC Flexible VBScript Problem

Guimmie

Member
Join Date
Aug 2008
Location
Cerdanyola
Posts
26
Hi!

In a WinCC Flexible script I'm trying to get some bit from some Tag so as I don't have to read to much Tags from PLC.
Now, for example, I'm reading EB0 and E0.0 too by different tags and it's what I want to change.

At first, I was looking for some "BitInTag()" function but I didn't found It...

Then, I decided to make my one "GetBitInTag(Tag,Bit)" function with the next code:

Dim Aux
ShiftAndMask Tag,Aux,Bit,1
If Aux = True Then
GetBitInTag = True
Else
GetBitInTag = False
End If

I was confied that It was going to work (and the compiler was with me) but in the best way, WinCC Flexible Runtime crashes with a "...need to be closed..." error.

If someone knows some function to make this or can improve my script, please reply!!!!!

Thanks!
 
No need for scripts.

Setup a tag as an array of bools. An array only counts as one powertag. Then you can address the individual bool elements like this:
MyBoolArray[1], MyBoolArray[2], MyBoolArray[3] etc.
 
Ok thanks Jesper, I'll try it later and I'll tell you!

Anyway, doing that, could I read the array as a byte?

I need to execute another script with the "Change value" event of this Tag...
 
Last edited:
Guimmie said:
Anyway, doing that, could I read the array as a byte?
You cannot read a BOOL Array as BYTE's.
You can create another Array of BYTE's pointing to the same PLC adresses.
Guimmie said:
I need to execute another script with the "Change value" event of this Tag...
You cannot trigger Change Value on an Array tag.

What is it you want to achieve ?
Maybe there is another way.
 
Well, I'm gonna explain myself a little more...

I'm using an script that change an integer tag (internal) value depending of the state of the bits E0.0 to E0.7.

I want to execute this script when the state of the inputs change so I get the byte so as I don't have to write the event in every Boolean tag that I get.

That's what I have by now, and It works perfectly. The only problem is that this thing is with a lot of bytes (EB0, EB1 , AB0, AB1) and for 4 CPU so, for do that, I take a lot of Tags. So I thought in some way to get every bit from the byte that I take and, on that way, I would only need to read Byte Tags.

Like I said before, I was thinking in make a function "GetBitInTag" that I will call from the other script everytime I need boolean data from this tags.

But if you show me another way to do that, I will adapt my program...

Thanks Jesper,

I'll be waiting for you reply!

P.S.: Sorry if you don't understand well my english, I'm don't speak it to much...
 
Well you are telling me what you are doing, but not what you really want to achive.

Have you setup a lot of BOOL inputs or BYTE inputs ?
Anyway, if BOOL's you could decrease the number of powertags by a factor 32, by switching from BOOL's to DINT's.
And, if BYTE's you could decrease the number of powertags by a factor 4, by switching from BYTE's to DINT's.
Of course the script will trigger if any of the bits within the DINT changes, but that is how it is.
 
Last edited:
Ok. What I had setup is something like that:

TAG TYPE DIRECTION
S1Inputs1 Byte EB0
S1Inputs1_0 Bool E0.0
S1Inputs1_1 Bool E0.1
.
.
.
S1Inputs1_7 Bool E0.7

And the same for EB1, AB0, AB1... and the same too for the three CPU's.
I know it's not the best way... but it works (slowly, but works).

In every Byte Tag I have a calling to one script (corresponding to every CPU) with the event "Change Value".

In this script I use the bool tag to see the state of the I/O.

So I thing it wouldn't be necesary to take bool tag if I get the byte... But I don't know how to get (in the script) the state of every bit from the byte if it's not by getting everyone by different tags (That's what I'm doing by the moment).

I think it answer your questions so as you can help me...
If not, tell me.

Really thanks for all Jesper!
 
At some screens, I've got graphic output field that determinates his state by one tag for example "S1SuctionPadState".
In one script (called S1SuctionPadState too) I look for the I/O bits that need to know the state of the Suction Pad. Depending of that, I assign a value or another to tag "S1SuctionPadState". Then the graphic output field change his state to the correspondic graphic on the graphic list.
And this Script, how I said before, is called when the EB0, EB1, AB0 or AB1 of the corresponding station change.
 
Why didnt you say so from the beginning ?
I dont understand why people jump to scripts every time.
Scripts are best avoided unless you absolutely cannot do it in another way.

Just make one or several bool array tags pointing to the different I/O areas you have.

Then you setup the animation to change on the values 0 and 1.
The tag for the animation then becomes something like InputArray[1], InputArray[2], InputArray[3] etc.
 
If using Graphics list, as you said you were, just change them to Bit (0.1) and the tag on the Graphic output field should be the bool in the arrays, EB0[1] or EB0[14] for example.

When selecting the tags, the array will be grey'ed out, just click on the triangle on the left of it to gain access to the individual items in the array.

Just tested it and it works........as Jesper said, avoid scripts whenever possible.
 
Ok, I thing that the array solution is a good idea and I had tried it when Jesper told me the first time... But I don't know how to create array's on WinCC Flexible... I tried it and I look on the help... But nothing helps me...

I promise that I looked for information about it... maybe I'm not good on searching... If some of you can explain me a little more how to do that... I promise not to ask you more xD

Thanks!
 
In the tag editor, there is a column 'Array Count'. If you change the default array count from 1 to something higher, it automatically becomes an array tag.
The numbering in the brackets always start from 1. I.e. MyTag[1], Mytag[2] etc.
 
I tried it... but I don't exactly understand how it works...

Should I create every tag that way? Or creating the higher one it auto-create the other, I said: If I create the tag S1Input1_7 and in the column "Array count" I write "8" the other seven will be created?

I tried something like this and I didn't get nothing...

It doesn't apears any triangle... I'm getting crazy...
 
Example:
If you have a tag MyBool that points to DB10.DBX0.0, you then set Array Count to 32.
That creates an array of 32 BOOL tags
MyBool[1] = DB10.DBX0.0
MyBool[2] = DB10.DBX0.1
.
.
MyBool[31] = DB10.DBX3.6
MyBool[32] = DB10.DBX3.7

There is no other indication in the tag editor that it is an array tag, than the Array Count value not being '1'.

In your screens, you set for example a visibility animation on n object. For this you specify the tag as for example MyBool[1] and visible when the value is '1'.
 

Similar Topics

Hi, We have upgraded our laptop which includes Windows 11. It appears that WinCC flexible 2008 advanced does not support Windows 11. What...
Replies
11
Views
269
Hello everyone I Have an Issue with the usage of recipes in Wincc Flexible 2008, I create the recipe to change the values in a fast way The...
Replies
0
Views
112
Hi colleagues.We do data logging system.We want to record three temperatures under a certain condition. We prepared the project as follows. We do...
Replies
1
Views
759
Hello to everyone. I change the value of a "PQW" with a button in Wincc flexible. The code of the button is defined as M102.0. Value reset...
Replies
10
Views
4,585
Hello Friends I have installed WinCC Flexible 2008 SP5 Update 2. I have open the software, but the Transfer option does not appear. Is It...
Replies
2
Views
1,480
Back
Top Bottom