Download global safety db via command-interface (C#)

rick-brinkman

Member
Join Date
Dec 2012
Location
Overijssel
Posts
21
Hello all,

Question:
Is it possible to download the global safety database “F-SHARED DB” by using the
Siemens command-interface in a C# application? If so, how?


Background:
I created a Windowsapplication with Visual C#.
This application is created to control a Siemens PLC (e.g. Start PLC, stop PLC and download to PLC).
Therefor I’ll make use of the Siemens command-interface.

The Windowsapplication works fine as long as I don’t try to download safety blocks. So in other words; starting, stopping the PLC or even downloading a complete PLC program (including
HW-Config with safety) without safety blocks works fine.

My problem occurs when I try to download a safety block to PLC. This is because Simatic manager generates the following (error)message (see picture below).

2ql4fi1.jpg



I noticed that the core of my problem is because the “F-GLOBAL DB” or “F-SHARED DB” isn’t present in the PLC. I know this because downloading of safety blocks works fine with the Windowsapplication when I do the following:

1. Download the safety program in the PLC with the safety utility in Simatic manager
2. Delete all safety blocks except the “F-Global DB”
3. Download all blocks with the Windowsapplication using command interface​


Used Code (Simplified):
4vlcty.jpg
 
The block folder itself has a download property that fires a download of the complete program. If i recall correctly it also downloads the safety program.

Code:
S7Container m_BlockFolder = m_Simatic.Projects(strProjectName).Programs(strProgramName).Next("Blocks");
m_BlockFolder.Download(S7OverwriteFlags.S7OverwriteAll);
 
Firstly, thanks for the reply

I tried the code that you have suggested but the compiler will then generate the following error:
"Cannot implicitly convert type 'SimaticLib.IS7SWItem' to 'Simaticlib.IS7Container'."

Therefor I changed the code as shown in the picture below.

2niv1vr.jpg



I think this code functions the same as you were implying
Unfortunately this code still can't handle safety blocks because it still gives the error that the F-Shared DB does not exist on the F-CPU.

PS. the code in the picture works indeed fine for normal blocks.
 
It was strange that the code did not work it works for me. I am however using vb.net and not C#
Code:
    Dim m_BlockFolder As S7Container = m_Simatic.Projects(myProjectName).Programs(myProgramName).Next("Blocks")
            If m_BlockFolder.Program.ModuleState = S7ModState.S7Run Then m_BlockFolder.Program.Stop()
            m_BlockFolder.Download(S7OverwriteFlags.S7OverwriteAll)
            m_BlockFolder.Program.NewStart()
I did some tests today and the code does download safety blocks even if they are changed and recompiled but only if they have been downloaded using the safety download in step7 before.
Just like you have tried it does not download the safety if the CPU is cleared. I guess i never tried with a clean cpu before.

I will make a support request to Siemens and see if they can tell us why
 
Last edited:
Bratt,

Thanks again!
I already submitted a support request at the Dutch Siemens support.
And my colleague will also submit a support request at the German support.
So I don’t know if it useful to add more support request for this issue.

I will of course give feedback if I know more.

Of Course other thoughts are always welcome ;)
 
Using PLCSIM you have to download the h/w config before you can download the safety blocks. I don't have access to a real plc to try this on one at the moment.
 
Hello LD[AR2,P#0.0],

Thanks for the reply

I already tried what I think you’re suggesting and to be sure I tried it once again.

What I tried is the following:
I made sure that there are no safety-blocks downloaded to the PLC (i.e., the PLC doesn’t contain any program). This, of course means that there is no “F GLOBAL DB” present at the PLC. In this situation I opened the HW-config, saved & compiled the HW configuration and I downloaded the HW configuration to the PLC. Finally I looked online to check which blocks are present on the PLC and noticed there is still no “F GLOBAL DB” present or any other building block for that matter.

So back to my start position, can’t download safety blocks without the presence of an “F GLOBAL DB”.
 
No, unfortunately not!
I called Siemens today to check if they are still looking into it.
I’ve been told that they will call me back.

So I’m still waiting with interest but low expectations.



PS. do you know if I can check via the command interface if there is a bus failure or system failure active??
 
One way to do this is to dump and read the diagnostic buffer with the command GetOnlineDiagBuffer. This is requires a little coding since you need to compare timestamps and filter out faults. Maybe there is an easier way to get a sum of the errors for instance reading the leds of the CPU but i don't know of it
Code:
 Dim themodule As S7Module6 = S7Program.Module
  themodule.GetOnlineDiagBuffer("pathToTxtFile")
Reading the LED's is possible with other libraries for example Libnodave.
If you are interested in this i can send you a simple vb.net application that can read the led status of the CPU over ethernet using libnodave.
 
Finally got a reply from Siemens support and as promised, here is the feedback.

I quote:

The error is because off the following reason:

"Das laden des Sicherheitsprogramms muss immer über den Dialog "Sicherheitsprogramm generieren" erfolgen. Sie können nicht einzelne Safety Bausteine aus dem Bausteincontainer laden.
Über den Bausteincontainer können nur Standardbausteine geladen werden."

Basically, this means that the way I want to load the F_Global_DB is not allowed. Therefore the error".

Whit the quote, the post is answered.

Thanks All!
 

Similar Topics

Hi everyone, I got a Parker HMI, CTC PA2. I tried to download program to it but it froze in the process and could not finalize. Now, when I try to...
Replies
0
Views
27
I am new In a CCW and as a beginner I am trying to learn programming but i am noticing that my CCW software is taking around 1 minute to download...
Replies
2
Views
71
Hello all, I'm trying to use the Logix Designer SDK to upload and download a single ACD to many controllers. I got this to work fine copying...
Replies
0
Views
42
Hello! When trying to load the hardware configuration I get error 0050-133 2 2458, check the diagnostic buffer. When checking the buffer, it says...
Replies
4
Views
128
Hi, I'm trying to add ethernet modules to one of our plcs, but I get about 15 errors that say "Invalid Signature. Reseal instruction to resolve."...
Replies
5
Views
227
Back
Top Bottom