winCC software to attach code to a button

M

Thread Starter

MM

Does anybody know how I would use winCC software to attach code to a button on the graphics editor to enable me to force on or off a particular output.
Is winCC using C or is this a visual -basic type of language.
Also I would appreciate it if anybody knows of a source of any code examples with the use of winCC, or small projects.

Thanks!! MM
 
J

Jeff Winborn

Hello,
There are existing 'smart' objects, like buttons, in the global symbol library that only require a tag assignment. Access this library from the graphic designer by selecting 'View' and then 'Library'. However if you want to use one of the button objects from the object palette, you will need to add a C-action. Below is the code for a custom toggle button. If you only want to set the tag value, then the 'GetTagBit' and 'if' statements are not necessary.

#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)
{
// WINCC:TAGNAME_SECTION_START
// syntax: #define TagNameInAction "DMTagName"
// next TagID : 1
#define TAG_0 "NewTag"
BOOL TAG_1;
// WINCC:TAGNAME_SECTION_END

// WINCC:pICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:pICNAME_SECTION_END

TAG_1 = GetTagBit(TAG_0); //Return-Type :BOOL

if (TAG_1 == 0)
SetTagBit(TAG_0,1); //Return-Type :BOOL
else
SetTagBit(TAG_0,0); //Return-Type :BOOL}
return;
}

Hope this helps. I now work for a systems integrator, Industrial Systems Design, after 16 years as an app engineer with Siemens. Always
looking for new business!

Jeff Winborn
(423) 282-6088
[email protected]
 
MM,

Are you wanting to create a toggle button to turn the output on/off? Let me know a few more details and I'll see if I can help.

Scott
 
Dear MM,

1. WinCC is an MMI software for middle to large scale industrial control applications and the cost of software is probably 4 to 5 thousand dollars depending on where you get it. Do you want to use it for forcing simple outputs...an overkill.
2. WinCC permits, in addition to conventional MMI facilities, global scripts based on C that make it an extremely powerful tool. To make a proper use of it one should be well versed with basic concepts of C and naturally the control and automation principles.
3. WinCC runs on Windows NT or Windows 2000. Acomplete station including hardware and software from Siemens would land you a bill in the vicinity of 7 to 8 thousand dollars.

Regards

Sunil
 
MM,

WinCC uses ansi C. Are you trying to just toggle bit? Because you wont be able to "force" it.

To toggle just go (on your object)under "object properties" then the event tab, mouse, direct connection , make source a 1 on mouse press
left (for example) then source a 0 for mouse release.
 
S

Scott Haulsee

I don't know if my last reply got posted. Are you wanting to create a button that will toggle an output?

Scott
 
This is quite an easy task in WinCC
1. Double click the button
2. Click the 'Events' tab
3. Drill down to 'Mouse' event
4. Double click e.g. 'Press Left'
5. Then

#define TAG_0 "your_tag_here"
SetTagBit(TAG_0,1); // to switch on

SetTagBit(TAG_0,0); // to switch off

Easy to toggle using if statement first. You can also do easy things like disable button when pressed etc so that an operator does not
multiple click etc.

Hope this helps...

Regards,
Oldie. [email protected]
 
Dear MM,

1. WinCC is an MMI software for middle to large scale industrial control applications and the cost of software is probably 4 to 5 thousand
dollars depending on where you get it. Do you want to use it for forcing simple outputs...an overkill.
2. WinCC permits, in addition to conventional MMI facilities, global scripts based on C that make it an extremely powerful tool. To make a
proper use of it one should be well versed with basic concepts of C and naturally the control and automation principles.
3. WinCC runs on Windows NT or Windows 2000. Acomplete station including hardware and software from Siemens would land you a bill in the vicinity of 7 to 8 thousand dollars.

Regards

Sunil
 
J
Open the object properties of the button. Under 'Font' there is a 'Text' attribute. Add a dynamic dialog to this attribute. In the dynamic
dialog window, you can select the tag, data type (in this case boolean), and the text displayed for the on and off states. The tag you choose should be the same tag that the button is toggling. You can do the same thing for 'Font Color' if you want a different color for each
text string.

Jeff Winborn
Industrial Systems Design
[email protected]
(423) 282-6088
 
S

Shahid Chaudhry

There are multiple ways:
1) Write a C-Script. WinCC uses simple ANSI-C standard and the learning curve is not very steep (given you are familiar with a high level language).
The code would be simple:
Step a) Define a Tag (Binary) and assign it to the output of the PLC (Say Q0.0 for example)
Step b) In Graphics Editor, place a button and open its properties. In the Events->Mouse->On_Click, double click on the arrow and write the following code in the coming window:
SetTagBit("TagName", TRUE); // This would set the value of TagName
Step c) Save. You are done!

2) A simpler method would be to use one of the Built-In WinCC Dynamic Wizard. The one you need is called "Setting/Resetting a Bit". It is part of the Standard Dynamics. Double click on the wizard and follow instruction. It would automatically generate the C-Script for setting/resetting of the bit.

A good start would be to get the WinCC manual (you can grab a copy from www.ad.siemens.com) and a book of ANSI-C. Good Luck

- Shahid Chaudhry
 
M

Maguire, Kevin

WinCC has 8-10 toggle-button objects in the library. All you need to do is specify the tag being toggled.
 
M
Something that is often overlooked with WinCC is that often you do not need to write a script to solve a problem. For a simple one operation button i.e. a button that simply SETs a flag, or a button that RESETs it. You can use direct access.

I don't have WinCC installed at the moment and its a few months since I used it. But if you select the direct option when you right click in the property explorer you will get a window that allows you various options. The left hand window shows you source options one of which (top most) is 'Constant' set this to TRUE (or 1) , the right hand side is the destination options, one of which is 'Tag'. Enter a tag in here and then whenever that control is operated the Constatnt value entered will be copied directly to the tag - no programming.

The Direct Actions can be used for a number of useful functions and are invaluable for 'tag prefixing'.

Regards
Mark Hutton
Software Engineer
YAC # 07092 032237
e-mail:[email protected]
internet: http://www.plcprogrammer.co.uk
 
Top