Assign value to tags in wincc

P

Thread Starter

prakash

Hello
I have a table in Sybase Central it has one field and one record I want to assign the record value to one of the tags which is a memory
variable. I am using that memory variable to reset a counter in Step7. The Sybase central is connected to a Visual FoxPro front-end, which
inputs value to the table so in one way I am interactively accepting value form user and feeding it in Step 7. Is this possible? How?
Prakash
 
S

Salma Ghafoor

The easiest way would be to have a script that runs cyclically and queries the table and writes the value to the memory tag.

The following project function is a sample script which will read data from a database using Microsofts ActiveX Data Objects. You will have to modify the script to connect to Sybase (instead of SQLServer), change the SQL query to use your table name, and write the results to a tag instead of just printing them to the screen.
This can be done easily using the SetTagX function.

If you are not familiar with ADO/WinCC scripting, let me know and I can e-mail you a help file I'm putting together which has a simple explanation of the following script.

void QuerySQLServer()
{
__object *cn;
__object *rs;

cn = __object_create("ADODB.Connection");
rs = __object_create("ADODB.Recordset");

cn->ConnectionString = "PROVIDER=SQLOLEDB; SERVER=MYSERVER; DATABASE=PUBS; UID=sa;
PWD=";
cn->Open;

rs = cn->Execute("SELECT fname, lname FROM authors");
printf("Firstname \t Lastname \r\n");
while(!rs->eof) {
printf("%s \t %s\r\n", rs->Fields(0),rs->Fields(1));
rs->Movenext;
}
rs->Close;
cn->Close;
}

Alternatively, there is a product Siemens offer called DataXchange which will set up a constant link from any database (Sybase) and and OPC Server (WinCC). However if you are just interested in this one value then DataXchange would definitely be overkill.

Hope this helped

cheers
Salma
 
N

Nijssen.Ronald

You need to write a script that connects to the Database, reads the record field value and writes it to the PLC Tag
You can access a Database in three ways from WinCC
1. Use the WinCC option DataXChange, reads-writes from/to Databases and OPC servers including the WinCC-OPC Server
2. Write a script with ODBC Function calls
3. Write a script that uses the MSDAC RecordSet Object

For the last two, send me your E mail address and I can provide a sample.
The first one is more expensive but maintenance will be much easier

Regards
Ronald
[email protected]
 
Top