Using global DBs in SCL FB for S7-1200

DLMUK

Member
Join Date
Jun 2013
Location
Southampton
Posts
311
Hi,

I am new to Siemens and SCL. I have a datablock which is a global data block. I want to use some of the values in this DB in a FB block.

When I reference local data in SCL I would do the following

#localData

What I want to do is the following

IF globalData > #localData THEN
#localOutput := 1;

ELSE #localOutput :=0;

END IF;

But when I try and use the global data it lets me input the whole DB within quotation marks but I cannot figure out how to address the specific data value within the DB.

Can anyone help?

Thanks.
 
Typical reference for a global variable:

"RigDataRetained"."B Total pumped" := 1;

"RigDataRetained".Total_Paint_in_Line := 1;

The easy way is to open the DB, highlight the line of the data, then Copy and Paste.

The quotes are only needed when the you spaces in names.

Of course if we were proper programmers we would never use a Global Variable within an FC/FB, you would pass the variable as an In/Out parameter.
 
Last edited:
Thanks - worked perfectly. I was trying this... "Display Values.H1" whereas I should have been doing it as you suggested.

Would you normally do this programming a PLC? To me it seems like it would just create more work/points for potential error?

Of course if we were proper programmers we would never use a Global Variable within an FC/FB, you would pass the variable as an In/Out parameter.
 
I never said 'I' was a proper programmer!!

There is a whole world of argument about 'proper' technique, but for me, so long as the program makes sense and is simple to follow, then we are probably doing it right.

Just to contradict myself. When I am working in 'C', then I tend to follow, proper technique, even though I do find it tends to make it harder to follow a program sequence. At least if you use Global Variables then it is called the same thing everywhere in the program, where as a passed variable may be called something different in a sub routine.
 

Similar Topics

new to PLC programming, new to the forum. have been lurking and learning for a bit and am excited to learn as much as i can here, now for my...
Replies
10
Views
3,482
I want to change color or make a animation of some thing in Wincc, and I was write a code in Global Script C(that is a application in WinCC). But...
Replies
0
Views
2,591
Hi I have a DH+ network with SLC500s on it. During a recent project, I have to add a Controllogix on to the network using DHRIO card. I need to...
Replies
0
Views
1,864
I am about to implement the Global Status Flags on my DH+ network of PLCs and I am thinking about using the integers in the files instead of...
Replies
9
Views
3,907
I have a project to automate four generator sets. The system will monitor and store the load demand of the factory. Once there's Power outage, the...
Replies
0
Views
64
Back
Top Bottom