WinCC Flex scripts doubts

juanmdx

Member
Join Date
May 2007
Location
SLP
Posts
281
Hi everyone,

Well I'll use scripts to solve my problem posted on my previous thread (KY data S5) and I'm basically using the code PeterW showed me.

For those who didn't check my previous thread what I have is a word on S5 that consists on two bytes, each one of them represents something for me, so I want to display them separatelly on a panel, I'm building the proyect for the panel on WinCC Flex. So I'm dividing the word with a code PeterW showed me. I already tryed a lot of things to get the two bytes and this one seems to be the best way (and also the only one...)

But I'm pretty new to this scripts stuff so I hope someone can guide me, here is what I have:

I added a new script and called it "kydata", the type is "Sub" and the Parameters it have are V, H and L.

The code is like this (and it's all that appears on the Script window):

If (V > 255) Then H = (V/255) : L = V - (H*256)
Else H = 0 : L = V
End If

So far I get this error when I check for errors:
* Expected "End" in line 9, Column 1 (that is the line of the Else)
I also doubt the division will give me only the above 0 value (like if the division is 5/3 and the result is 1.6667 I will only need the 1).

Know I'm planning on, when I enter a screen where I need this, on the "Load" action of the "Event" properties I will configure the script and the tags for H, V and L.


How I'm doing so far???
Can anyone help me with my questions and so far errors please


Thanks in advance


Juan
 
Ok, I solved my first problem, the error that appeared to me when I checked the script for errors. The problema was that I had everything on the same line, so now the script is like this:

If (V > 255) Then
H = (V/255) : L = V - (H*256)
Else
H = 0 : L = V
End If


And the H, V and L are assigned when the screen is loaded, so in the script I don't have any Dim or Set instruction.

But it isn't working, well at least the IO Fields which tag I'm linking to H and V aren't showing me anything, they remain in 0.

Also, what is the instruction that will give the truncated value of the division?.


Thanks in advance.


Juan
 
Thanks a lot, now I'm using the Mod instruction.

The last thing that I need to do (and what is taking most of my time) is that the tags aren't showing the data of the script.

So I have the script without any Dim or Set instruction, and the variables I use (V, H, L) are setted as parameters.

Now, on the screen I use this I have two IO Fields working as Outputs the tags of those IO Fields are tag1 and tag2.
On the "Load" action of the "Events" of the screen I configured the script kydata, and linked V to a value (46723 decimal), H to tag1 and L to tag2.

But the tags aren't showing me the value that H and L should be getting from the script, I don't know if the scrip isn't working or if I have the configuration wrong or what.

I really hope someone can help me.

Thanks in advance.


Juan
 
----I reviewed and the instruction I have to use is \ and not Mod, but I'm still having my problem----
 
Make sure the tags you are putting the data in from the script are set to cycle cont not on demand. This is done int the properties of the tag.
 
Yeap, they are cyclic continuous,
I think is something on how I wrote the script (is my first one), but I just can't get what it is....

It is just as I posted it


Juan
 

Similar Topics

To activate a script I change values... On Change Value of the tag I call my script. In the PLC I do something like this: A...
Replies
6
Views
3,508
I'm continuing my Siemens education. I need some help with compatibility details. My customer has a machine that was made by a company no longer...
Replies
6
Views
4,040
Hello all. I mainly work with Siemens PLC's and panels for our machines. But now I am faced with a pilot project that has to be as price friendly...
Replies
15
Views
8,988
Hi Folks. I have an older application that weighs pallets and prints labels for them. We used to capture the time/date of weighing, but we...
Replies
2
Views
1,623
Hi, I have WinCC Felxible 2008 SP5 installed on my Windows 10. I want to program Simatic panel TP177B using USB transfer cable. But i can't...
Replies
8
Views
2,118
Back
Top Bottom