You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old July 8th, 2006, 10:37 AM   #1
adner
Member
Poland

adner is offline
 
Join Date: May 2006
Location: Wroclaw
Posts: 14
Question WinCC felxible VB access to TAGs

Hello,

does anybody know, how to access to single bit of TAG data type Word?

Instruction: SmartTags("TagName") allow only to access whole word.

I want to make something similar like instruction SetBitInTag (but I want only to read one bit from TAG).

BR,
Piotr.
  Reply With Quote
Old July 8th, 2006, 10:54 AM   #2
CharlesM
Member
United States

CharlesM is offline
 
Join Date: Aug 2005
Location: Arkansas
Posts: 1,085
You can call the SetBitinTag from a script. By using the code helper you can use any functions or scripts.

Take a look at system functions in this attachment
Attached Files
File Type: pdf Flex_script.pdf (102.9 KB, 122 views)

Last edited by CharlesM; July 8th, 2006 at 11:18 AM.
  Reply With Quote
Old July 9th, 2006, 03:53 AM   #3
adner
Member
Poland

adner is offline
 
Join Date: May 2006
Location: Wroclaw
Posts: 14
OK. it's great.

But how to get information about single bit from Word TAG?
  Reply With Quote
Old July 9th, 2006, 03:58 AM   #4
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 10,885
I remember that I made some script for Citect to do just that.

Dont remember exactly how I did it, but it involved using word logic (AND, OR, XOR) to mask out the non relevant bits and then comparing with 1 for bit 0, 2 for bit 1, 4 for bit 2, 8 for bit 3 etc.
__________________
Jesper
  Reply With Quote
Old July 9th, 2006, 05:02 AM   #5
adner
Member
Poland

adner is offline
 
Join Date: May 2006
Location: Wroclaw
Posts: 14
hmmm...
in WinCC flexible? I want to do it as simple, as it is possible (I've limited no of lines in VB script - 50 lines in TP270).
  Reply With Quote
Old July 9th, 2006, 09:56 AM   #6
stplanken
Member
Canada

stplanken is offline
 
Join Date: May 2006
Location: Alberta
Posts: 49
Quote:
Originally Posted by adner
But how to get information about single bit from Word TAG?
I don't use WinCC flexible, but maybe you could do something like this (just replace the "HMIRuntime.Tags" part). This function returns a True/False for the bit state 1/0:

Quote:
Function BitState(Byref cTagName, Byval iBit)
Dim oTag
Set oTag = HMIRuntime.Tags(cTagName)
oTag.Read
BitState = (oTag.Value And 2^iBit) > 0
Set oTag = Nothing
End Function
  Reply With Quote
Old July 9th, 2006, 09:58 AM   #7
CharlesM
Member
United States

CharlesM is offline
 
Join Date: Aug 2005
Location: Arkansas
Posts: 1,085
Pointer Check this out

http://www.plctalk.net/qanda/showthread.php?t=16734

Look at this old post. It has code on how to break down a word into bits.
  Reply With Quote
Old July 10th, 2006, 12:40 PM   #8
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 10,885
If we are talking about just one or two words, then a quick-and-dirty way to do it is to create a number of bool tags that point to the same addresses in the PLC as the word tag.
Of course, this isnt useful if you are after processing many words.

edit:
To get more functionality, for use in scripts for example, then create a boolean array tag.
You can access the individual tag in the array like this:

For example "My_bool_array(n)" where "n" is the number of each individual cell in the array.
__________________
Jesper

Last edited by JesperMP; July 10th, 2006 at 12:47 PM.
  Reply With Quote
Old July 11th, 2006, 03:24 AM   #9
adner
Member
Poland

adner is offline
 
Join Date: May 2006
Location: Wroclaw
Posts: 14
unfortunatelly I've lots of this signals. And... I've limitation in no of lines in script. So... I've to write some smart function.
  Reply With Quote
Old July 11th, 2006, 06:03 AM   #10
PLucas
Member
England

PLucas is offline
 
PLucas's Avatar
 
Join Date: Apr 2002
Location: Gillingham Kent
Posts: 1,743
I have kept out of this thread because I don't use WinCC Flex, but I do use WinCC. So I am wondering if WinCC Flex is that much different that you can't access a bit in a word or double word tag like you can in WinCC?

You would do this by selecting 'dynamic dialogue', then 'Bit', assign the tag, than select the bit within the tag, can't you do that in Flex?

Paul
__________________
There are 10 types of people in this world..
Those who understand binary and those who don't!
  Reply With Quote
Old July 11th, 2006, 08:15 AM   #11
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 10,885
There is a similar function "SetBitInTag".

There are a number of ways to access many bits in different tags.
I think that Adner should describe what it is that he want to achieve. Then we can help him better.
__________________
Jesper
  Reply With Quote
Old July 11th, 2006, 11:36 AM   #12
adner
Member
Poland

adner is offline
 
Join Date: May 2006
Location: Wroclaw
Posts: 14
:-)
I want to read one bit from TAG type WORD. But I need some similar function like SetBitInTag... but ReadBitInTag.
  Reply With Quote
Old July 13th, 2006, 03:08 AM   #13
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 10,885
What is it that you want to achieve in the end ?

What we have discussed so far are just methods to achieve what you want to do.

So far, my best bet is to setup a boolean array tag. You can then access the individual bits in a script that doesnt take up much memory.
You can also access the individual bits for use in animations in screens and such with no need for any script code.
__________________
Jesper
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
WinCC with MS Access shandra_ck LIVE PLC Questions And Answers 3 February 6th, 2006 09:08 AM
WINCC and Internal Tags, how... Combo LIVE PLC Questions And Answers 2 December 15th, 2005 08:17 AM
WinCC project reading STEP 7 project symbol table Pandiani LIVE PLC Questions And Answers 1 August 11th, 2005 03:20 PM
WinCC 5.0 sp2, save tags in CSV problem johnny LIVE PLC Questions And Answers 3 May 26th, 2005 07:22 PM
Access to WinCC tags from VB application mareki LIVE PLC Questions And Answers 0 May 22nd, 2004 08:33 AM


All times are GMT -5. The time now is 04:03 PM.


.