Applies To:
  • CitectSCADA 5.xx

The reason for this work instruction is to ensure that when a Citect SCADA system is used on top of a Siemens S7 PLC, that certain rules are followed when constructing their databases to communicate to each other, to prevent two major problems:

1) Because the Citect database and Siemens databases can be constructed differently (i.e. you can build them separately), there is opportunity to name the same physical address differently. For example, DB121.DBX1.2 could be called PA_OperatorModeOn say in the S7 PLC, but in actual fact you may call it PA_OPMODEOn in the Citect Database, or similar which can cause confusion.

2) The second reason is to maintain a low communications turn around time between Citect and the Siemens S7 PLC by constructing the databases contiguously, meaning, leaving no holes in the database, but only small amounts of space for redundancy. This keeps the Citect response times down to acceptable levels where the page update time is then optimised, as well as the eventing in the event list will be more accurate.


2.1 Rules

2.1.1 All Citect Data going into the S7 PLC shall be written to DB120

2.1.2 All Citect Data going out of the S7 PLC shall be written to DB121

2.1.3 Both DB120 and DB121 shall be fully dimensioned to allow for spares as well, so that they are dimensioned once only. The databases will be created within the Citect variable.dbf file first, using the save_dbf.xls macro to edit the Citect database, then this will be saved as a normal spreadsheet, edited, and imported into S7 to create the datablocks DB120 and DB121.

2.1.4 All spare bits or integers etc.. shall be labelled as follows: if the address is DB121.DBX1.5, the tag name will be DB121DBX15, or similarly, if the address is DB121.DBW190 the tag name will be DB121DBW190.

2.1.5 Tag names cannot be longer than 24 characters, use the CELL LENGTH option after loading the save_dbf.xls macro to check entered tag names to see how long you have made them. If they are longer, the S7 program will fail during compilation of DB120 or DB121.

2.1.6 Data shall be arranged in such a manner which is functionally based in each data block, and shall be very contiguous, i.e. no gaps between functionally based addresses, except for redundancy (spares).

2.1.7 There shall be 3 or 4 bytes of boolean (digital) space after the last digital tag is defined before the first integer tag is defined.

2.1.8 Both data blocks shall start with boolean data (digital) at DB120 or DB121.DBX0.0

2.1.9 PLC Code shall be written for each functional device (i.e. an FC for each BIN system) to send the actual status of a bit in the real time PLC code to the Citect bit for that status. See the Primary Alloys & Direct Flux PLC program for an example of how this is to be achieved.

2.1.10 See Attachment 1 for an example of how the DB120 and DB121 databases are to be defined.

2.2 Creating the Common Databases

2.2.1 If you are creating a new Citect project for the first time, create the project first in Citect explorer, then follow on to step 2.2.2 below.

2.2.2 Create the entire database firstly for all Citect data going into the S7 PLC, which will be entered into DB120 (Citect Data INTO PLC). This must be done in Microsoft Excel, by editing the Citect Variable Tags database: variable.dbf file which can be found under the Citect/User/[project name] folder on your hard drive. You must also load the save_dbf.xls macro file (found in the Citect/Bin directory) once you have loaded the variable.dbf file before you edit it, otherwise corruption of the original citect database file is possible. See the Citect Training Course manual (a copy of which can be found in the BOS Maintenance filing system) for information on editing the Citect database using Microsoft Excel.

2.2.3 Ensure that the above RULES are followed when creating your database, i.e. all addresses are contiguous with only small amounts of space between used variables for spares. Please check Attachment 1 for reference.

2.2.4 Once you have defined all variable tags to be used for data going into the S7 PLC, (both boolean and integer type), continue on in Microsoft Excel to edit the variable.dbf Citect database, to include all variable tags for Citect data coming from the PLC, to be read from DB121 (Citect Data OUT PLC), again paying attention to the rules outlined above. Start this variable tag declaration directly after the last variable tag for Citect Data INTO PLC. See Attachment 1 for reference.

2.2.5 Once you have completely finished declaring all variables to be exchanged between the Citect system and the S7 PLC, (via DB120 and DB121), you must now save the variable.dbf file as "VARIABLE.XLS" stored in your own directory or on the desktop.

2.2.6 You now need to edit the TYPE of data declaration column in this spreadsheet to allow the Siemens S7 Simatic Manager program to read it.

(a) Highlight the column TYPE by clicking on the column B to highlight the entire column, then press CTRL F to FIND.

(b) When the pop-up box appears, type in the "Find What" field the word "DIGITAL", then click on the REPLACE button, then type in the "Replace With" field the word ": BOOL ;" (ensure the spaces exist between the colon and the semi-colon).

(c) Then click on the FIND NEXT button, this will find the first variable tag with the declaration DIGITAL, then click on the REPLACE ALL button. This will replace all variable tags with declaration DIGITAL, and replace them with declaration : BOOL ; which is required by the Siemens Step 7 Source File to compile the required data blocks.

(d) You must now also repeat steps (a) to (c) above for the integer declarations. "Find What" field = "INT", "Replace With" field = ": INT ;" again making sure you have spaces between the colon and the semicolon. This will prepare all the integer variable tag declarations ready for the Siemens Step 7 Source File.

(e) Save the excel spreadsheet again to protect your work.

2.3 Creating an Empty Siemens Source File to Compile DB120 & DB121

2.3.1 Start the Siemens Step 7 Simatic Manager program, and open your PLC project.

2.3.2 Open the BLOCKS container in your project, and create new data blocks DB120 and DB121.

2.3.3 Open DB120 first by double clicking on it from the BLOCKS container in your project, select the data block parameter, then in the first available symbol declaration cell at the top of DB120 (db120.dbx0.0), under the column NAME, enter a name such as FIRST_TAG, this is only a false name which will be deleted later. Then for this tag, under the TYPE column type in BOOL.

2.3.4 Click on the save icon to save your data block.

2.3.5 Repeat Step 2.3.3 and 2.3.4 above for DB121.

2.3.6 Close the data block in the LAD/STL/FBD program by going to the File menu and clicking on CLOSE.

2.3.7 Then go to the File menu again inside the LAD/STL/FBD program and click on GENERATE SOURCE.

2.3.8 In the "Object Name" field, type in a name for your source file for DB120, a good name is CITECT DB120. Then click on OK.

2.3.9 Then from the next menu which appears, select DB120 from the left hand list by clicking on it, then click on the "à" arrow button to attach it to the source file.

2.3.10 Click on OK, and the source file will be generated, and a message will appear at the bottom of the screen to confirm that it has done so successfully.

2.3.11 Repeat steps 2.3.7 through to 2.3.10 to create the source file for DB121, and name the source file CITECT DB121.

2.4 Opening the Source Files for DB120 & DB121 and Editing them

2.4.1 Go to the File menu in the LAD/STL/FBD program, and click on OPEN. A pop-up box should appear with the two source files for DB120 and DB121 which you created in the previous step in front of you. If you cannot see them double click on the SOURCES folder in that window to see all of the source files in the project.

2.4.2 Select your source file for DB120 (CITECT DB120) by clicking on it, and then click on OK. This will open the source file ready for editing.

2.4.3 You should see this:









2.4.4 Delete the line: FIRST_TAG : BOOL ; after the STRUCT line.

2.4.5 You should now see this:








2.4.6 Now go back to the Microsoft Excel program where you have the VARIABLE.XLS file still open.

2.4.7 You now require to copy and paste the Variable tag names and declarations (NAME & TYPE COLUMNS) for DB120 ONLY from this spreadsheet file into the source file. Do this by going to the very top of the VARIABLE.XLS file in Excel, and highlight all of the records of DB120 starting with the first tag name and declaration in the two columns just underneath the column titles at the top (i.e. do not include the column title names!), and drag your mouse so all of the DB120 records are highlighted. Once you have done this, press CTRL C to copy it to the clipboard.

2.4.8 Now go back to the LAD/STL/FBD program where the empty source file is for DB120. Click on the deleted line in between STRUCT and END_STRUCT and press CTRL V to paste in all of the records from the VARIABLE.XLS sheet for DB120.

2.4.9 Now with all of the Variable tag records for DB120 pasted into the DB120 source file, you must declare the first BOOLEAN and first INTEGER variable tag INITIAL VALUES. Scroll down to the bottom of the source file for DB120, where you should see the following:





2.4.10 Change the FIRST_TAG name you see in the line between BEGIN and END_DATA_BLOCK, to the name of your very first variable tag for DB120. Note, the name needs to be exactly the same as what you have called it at the top of the source file.

2.4.11 Then, insert a line after this Initial value declaration for the first BOOLEAN TAG at the bottom of the source file so you can now declare the initial value for the first INTEGER TAG. You should see something like this:



SYS_CitectHeartBeat := FALSE;


2.4.12 Now, click on that empty line in between the declaration for the first BOOLEAN TAG and END_DATA_BLOCK, and type in the name of your first INTEGER TAG NAME here followed by : ":= 0;" you should then see something like the following at the bottom of your source file once you have finished:



SYS_CitectHeartBeat := FALSE;

PA_HP1_Setpoint := 0;


2.4.13 Now go to the File menu and click on CHECK CONSISTENCY. This will check your source file for any errors you may have. If there are errors, it will indicate the error at the bottom of the screen, as well as highlight the particular line in question. Check that you have only up to 24 characters in your tag names, and more than this and this consistency check will fail, as the maximum number of characters you can have in a DB is 24.

2.4.14 Once you have checked the consistency of your source file and no errors are found, go to the File menu and click on SAVE.

2.4.15 Then go back to the File menu again, and click on COMPILE. This will compile your source file for DB120 (you must still have the source file for DB120 open), and re-create DB120 with all of the variable tags you have created in Citect, as seen in your source file.

2.4.16 Go to the File menu and click on CLOSE to close the source file for DB120.

2.4.17 Go to the BLOCKS container in your project in the SIMATIC MANAGER program, and open the newly generated DB120 by double clicking on it. Check to make sure that all variable tags have been entered in correctly. A good method is to pick a spare variable tag which you would have labelled as the correct address (i.e. in the attached example, DB120DBX167 lines up exactly with DB120.DBX16.7 If you have forgotten to put an address in somewhere in your VARIABLE.DBF file you will notice that your addresses will not line up correctly. Ensure that all tags do in fact line up as required.

2.4.18 When you are happy you have DB120 the way you want it, go to the File menu and click on CLOSE.

2.4.19 Repeat all of the above steps in 2.4 to create DB121 also.