Scl tia portal мануал

В данной статье рассмотрим основы программирования в Tia Portal  на примере  структурированного языка управления SCL (Structured Control Language), являющегося высокоуровневым текстовым языком, основанным на языке PASCAL.

Данный язык поддерживает типовые операторы программирования, такие как присвоение (: =), математические функции (+ для сложения, — для вычитания, * для умножения,  / для деления), а также использует стандартные операторы языка PASCAL, такие как IF-THEN-ELSE, CASE, REPEAT-UNTIL, GOTO и RETURN. Другие инструкции для SCL, такие как таймеры и счетчики, соответствуют LAD и FBD инструкциям.

Начнем мы изучение SCL с простых логических операций и математических выражений и сравним их с программированием на языке LADDER.

Ниже на рис. приведен пример FB блока на LAD, состоящий из пяти Network, в которых выполняются простые логические и математические операции, в том числе один таймер. Создадим подобный блок на языке SCL.

Tia Portal. Язык программирования SCL

Создаем в программе новый функциональный блок и в раскрывающемся списке выберем SCL в качестве языка программирования.

Tia Portal SCL

Таблицу тегов будем использовать ту же самую, что и для LAD.

Начнем с самой простой задачи – логической операции AND. Значение TRUE на i1 и i2 активирует выход q1.

Для написания программы на SCL необходимо запомнить синтаксис команд — переменная всегда начинается с кавычек или #, двоеточие разделяет инструкции,  = присваивает результат. Разницы между строчными и прописными символами нет. При вводе переменных, достаточно ввести первый символ и TIA Portal автоматически  предложит выбрать переменную из раскрывающегося списка.

Комментарии в программе указываются с помощью двойной косой линии – слеша.

Напомню, что каждая строка должна заканчиваться точкой с запятой. Во второй строке оператор RETURN после косой черты указывает на конец программного блока, достаточно удалить эти косые черты и ПЛК не выполнит следующие строки программы. Это удобно при отладке программы.

Одна важная деталь. В блоке, созданном на языке LAD, мы можем легко добавить сегмент на языке SCL с помощью правой кнопки мыши. Таким образом, при необходимости, мы можем написать несколько длинных логических операций на SCL прямо в функциональном блоке LAD.

Переходим ко второму сегменту. В данном случае, выход будет активен, если значение хотя бы одного из входов (i1 или i3) выражения в скобках будет принимать значение TRUE и нет сигнала на входе i2.

Далее из меню основных инструкций добавим таймер с задержкой выключения — TOF. Параметры таймера указываются в скобках.

Тип таймера можно легко изменить, просто щелкнув по нему мышью.

В следующей строке напишем  простое математическое выражение «А умноженное на В равно С». Если необходимо, вместо умножения можно использовать и другие операторы – сложение, вычитание, деление, сравнения и т.д.

Наконец, еще одно выражение «A + B = C», на этот раз с использованием временных переменных в функциональном блоке. В последней строке используется  команда RETURN, то есть конец программного блока.

Наши последние несколько строк, написанных на SCL, заменили эти два сегмента программы LAD.

В принципе, это вся программа на  SCL, которая представляет собой аналогичную программу на LAD, согласно первому рисунку в статье.

Как видим, получилось все более компактно. Кроме того, программный код можно еще немного уменьшить, удалив ненужные комментарии.

В следующем уроке мы продолжим изучение SCL и рассмотрим работу с детекторами фронтов, счетчиками.

Siemens Industry, Inc. [email protected] 800-333-7421 Page 1 of 1 Automation — SIMATIC S7 with TIA Portal TIA Portal Programming with SCL General Information Course Code: SCT-PTSCLP3A Length: 3 Days Audience This course is for engineering and maintenance personnel, who create, diagnose and troubleshoot SIMATIC STEP7 applications with Structured Control Language (SCL) content. Prerequisites TIA Portal Programming 1 Profile 2 CEUs (Continuing Education Credits) This course provides an in depth look at Totally Integrated Automation Portal (TIA Portal) to inform participants about the working environment for end-to- end engineering with SIMATIC STEP 7 and SIMATIC WinCC. Participants will explore the complete language and performance scope of the Structured Control Language (SCL) development environment. Using simple examples, we will show you the advantages offered by a high-level programming of SIMATIC S7-1500. During the training course, you will create, commission, and test your own SCL programs. This is a hands-on course filled with programming exercises in SCL. Participants should have a solid working knowledge of STEP7, SIMATIC TIA Portal and the basic diagnostics and editor tools. Learners will use advanced software tools of STEP7 to complete system integration programming, troubleshooting, and functional testing of applications. After the course, the learner will be able to reduce the amount of time spent on creating and maintaining programs through the use of a high-level programming language (SCL) instead of Statement List (STL). Objectives Upon completion of this course, the student shall be able to: Build or modify a simple STEP7 project using SCL. Efficiently use the SIMATIC Manager program editor tools. Use the STEP7 program monitor, diagnostics and troubleshooting tools. Build or modify SCL programs. Package an SCL program into a custom library block and use within a STEP7 project. Explore the SCL syntax requirements and the system debug functions. Create, commission, and test programs in SCL Topics 1. Engineering Tool SCL 2. Training Unit S7-1500 3. First Steps with SCL 4. Data Types, Arithmetic Functions and Addressing 5. Source Handling and Basic Programming with SCL 6. Complex Data Types 7. Code Blocks and Control Statements 8. Strings and String Processing 9. Indirect Addressing and Data Views

SMV23

Профан
Сообщения: 2
Зарегистрирован: 29 май 2017, 10:35

phantom

Любитель
Сообщения: 71
Зарегистрирован: 02 дек 2017, 18:56

Re: Мануалы на русском языке TIA Portal и TIA Portal Opennes

Сообщение

phantom » 02 дек 2017, 19:40

Добрый день, перешел по ссылкам, а там все на английском. И вообще на сайте сименс не нахожу мануалов на русском, такое ощущение будто сименс делает это специально. Или я слепой не те ссылки скачиваю( Поделитесь пожалуйста мануалами на русском Step7 Poff и WinCC Prof для TIA Portal V14. :[


phantom

Любитель
Сообщения: 71
Зарегистрирован: 02 дек 2017, 18:56

Re: Мануалы на русском языке TIA Portal и TIA Portal Opennes

Сообщение

phantom » 03 дек 2017, 12:25

Михайло писал(а):Они это по-любому специально делают. Ведь труд переводчика допустим стОит не менее 3000 рублей за страницу. Это значит, что на перевод надо потратить сотни миллионов рублей, и это только на один Step 7 Basic V14, который постоянно обновляется…

Честно пионерское, вот мои аргументы:
Изображение

Поделитесь пожалуйста ссылками на русскоязычные мануалы по STEP7 и WinnCC для Tia Portal V14, желательно проф.


phantom

Любитель
Сообщения: 71
Зарегистрирован: 02 дек 2017, 18:56

Sos

Профан
Сообщения: 1
Зарегистрирован: 04 апр 2018, 00:39


Search


DMC, Inc. Logo

Efficient SCL Development in TIA Portal V14

    TIA Portal, SCL

With the recent release of TIA Portal V14 and V14 SP1, several new additions have been added to increase the efficiency and organization of code written in SCL (structured control language).

Recently, I have been using many of these new features while writing code in SCL and wanted to share them with you. We will start by defining SCL and its uses in programming, then we will compare ladder to SCL, next we will discuss inline SCL networks, Regions and Region Synchronization, and will finish by reviewing the streamlined Surround With…

What is SCL and When Should I Program Using it?

SCL stands for Structured Control Language and is a text-based form of programming Siemens PLCs.

SCL opens up several new constructs that are unavailable while programming in conventional ladder logic, including the FOR and WHILE loops as well as the CASE statement. These are particularly useful when dealing with large amounts of data in an array form. Using SCL also increases the readability of any sort of arithmetic calculation.

What Does SCL Look Like?

Below is an example of code written in both ladder and SCL to accomplish the same result.

Ladder Logic

I have created an array of five integers and I would like to check and see if any indexes of my array are equal to three. In order to get this information in a single scan of my logic, in Ladder, I would need to check each index individually to determine if any of them are equal to 3.

Screenshot of Network 2 - checking the array.

For a small array, writing this code in ladder logic doesn’t seem so bad. However, imagine I had an array of a hundred or even a thousand integers and I needed to check all them.

SCL

Examining SCL logic, suddenly, the ladder logic solution seems inefficient in comparison. Using a combination of a FOR loop, IF statement and an EXIT, I can easily check an array of any size in a single scan.

Network 4 - checking the array.

If my application required, I could even nest FOR loops within each other in order to check or set values of a UDT which contains an array of variables.

Inline SCL Networks

In TIA Portal V14, there is now the ability to create function blocks and function calls that contain code written in both LAD and SCL. An SCL network can easily be inserted into a function without the need to create a separate SCL function.

For example, it was previously necessary to use LAD math operations or a separate SCL function to string together a complex calculation that can now easily be written in an SCL network.

Regions

  • Regions are a new SCL organizational tool that provides a similar level of organization as a network does in a LAD function.
  • Regions are collapsible and easy to navigate through the sidebar.
  • Regions can be nested, if needed, to provide an even greater level of organization.
  • Keep in mind that regions cannot cross logical boundaries. For example, if a region begins inside one case of a case statement, it must also end in the same case. Failure to do so will result in a compiler error.
  • Regions make lines of comments that serve only as a separator for a new section of code unnecessary.

BEFORE

AFTER

Synchronizing Regions

  • The sidebar navigation that shows the regions in an SCL function can also be set to be synchronized with the code. This means that when expanding or contracting a region in the sidebar, the body of code will reflect the change.
  • With synchronization turned on, large bodies of SCL code can easily be minimized or maximized without heavy use of the scroll wheel to find where a region starts.
  • Keep in mind that logical statements like IF…THEN… can also be expanded or contracted but are not synchronized with the region they are within.

SYNCRONIZED, COLLAPSED

SYNCRONIZED, ALL EXPANDED (NESTED REGIONS)

Surround With

As of V14 SP1, the ability to add logical statements, regions, and comments to existing code has been greatly streamlined with the addition of the “Surround with…” option.

Simply highlight a body of code, right-click it and choose what you would like to surround it with. This is especially helpful for quickly adding regions to code written previously to V14 or to quickly comment out chunks of code while debugging.

Hopefully, some of these tips will allow you to create more efficient PLC code and increase your development speed at the same time. 

If you are in need of DMC’s expertise, check out our Siemens PLC Programming Services or Contact Us to get started on a project today.

Comments

MaKu

Friday, June 22, 2018 12:58 PM

The else part in the SCL code is missing. bAnElementIs3 will become FALSE in Ladder if all array elements are FALSE.
In SCL bAnElementIs3 will stay TRUE if all array elements are FALSE again.

Sipho

Wednesday, April 11, 2018 12:09 AM

Mr David,

Sir please help me out, I need a Direct On Line (DOL) program in SCL, and Forward Reverse SCL program.
I will be very happy sir if can help out.

Thanks in advance

John Sullivan

Thursday, January 4, 2018 1:31 PM

Luciano,

There is no way to convert an compiled STL program into SCL. For a conversion I was able to reverse engineer some STL files into SCL, but it is a very difficult and intensive process.

If the OEM will not provide the original SCL, and it wasn’t loaded onto the controller (which is rare) then you are unfortunately out of luck.

David Berno

Thursday, January 4, 2018 9:12 AM

Hi Luciano,

What version of TIA Portal are you using and what type of controller?

Luciano Vasconcelos

Wednesday, January 3, 2018 4:23 AM

Dear David, Do you know a way to revert a program made using SCL language back to it original form ? I have a source program, some file used SCL but the supplier delivered just the STL converted form. Now, I want to study the program, but a compiled SCL into STL is very difficult to understand.

Do you know a way to revert back to it SCL form ?

Sometimes it’s hard writing PLC code in LAD (ladder logic) or FBD (function block diagram). Especially, if you have to do some math work or mass operations.

In these cases you can easily use SCL/ST (Structured Control Language/Structured Text.)

Writing your first TIA code in SCL:

Step 1 – Create or open TIA project

Just like programming LAD or FBD, it’s necessary to create or open a project with a PLC to program in. SCL is supported by all SIMATIC PLCs (S7-300, S7-400, S7-1200 and S7-1500).

In this example, I’ll use a S7-1515-2 PN, but it will also work with other S7-1500 or S7-1200 PLCs.

Step 2 – Add FB/FC

After the project is opened and a PLC is available, we can add a function [FC] or a function block [FB]. The difference between FC and FB is the storage capability. A FB can store data which is still available after a PLC cycle. In our case we only need a FC.

Double click “Add new block” within the “PLC/Program blocks” folder. Now the “Add new block” dialogue is opened. Here we can select the block type to create, in our case FC.

After the block type is chosen, we have to select the language to program in. The drop down list will show all possible programming languages available for the selected block type in combination with the PLC type. We will use “SCL” of course.

If you want, you can also add additional information below in the Additional Information compartment e.g. author, version, etc.. Now we can create the block by click OK in the dialogue.

Step 3 – Modify the block interface

After the block is created, we can modify the Interface of the FC. In our case we will enter an input of type [Array[0..5] of INT], an output of type [INT], and two temp variables of type [INT].

Note: In a FB there is also a static section shown due capability to store data for more than the actual PLC cycle.

Step 4 – Enter SCL code

In the next step we enter the code to determine the maximum value of the array elements. The code will iterate from index zero to five through the array and compare if the actual value is greater than the “tempMax” value. At the end we will get the maximum value contained in the array.

At the line one we set the “tempMax” to a defined value. In this case zero.

In Line three we start the “FOR” loop. This will use the “tempCount” variable to store the actual index of our loop. It is set to zero for the start and will run until it has reached five. So we will run the loop for six times (0->1->2->3->4->5). The code of the “FOR” loop is encapsulated by the “FOR …” statement in line three and “END_FOR;” statement in line seven.

This code block contains an “IF” block which will only process its inner code if the statement “#In[#tempCount] > #tempMax” will return a “TRUE” and so the actual “maxTemp is smaller than the value of the array element with index of #tempCount.

Due to intellisense the TIA portal provides suggestions while typing code. Additional you have a favorite instruction list at the top of the text editor area just like in the editor of the other languages. Here you can add other instructions by drag them from the instructions tab.

Step 5 – Provide some data

To be able to provide our program with some values we have to create a global data block [DB] to provide some data, like we did it for the FC.

We will also enter some startup data, which is provided to the global DB at Startup of the PLC.

Step 6 – Call the FC in OB1

To use the FC in our PLC, we can call the block within the Main [OB1] and provide it with values from the “dbGlobal”. After we added the call, we can compile the program code and load it into our PLC or simulate it with PLCsim.

Step 7 – Testing

After connecting to the device (by selecting the PLC and click “go online”) and activate observe mode in the blocks, we can check the behavior of our program.

We can create a watch table to observe and modify values to test our code. Enter in the column “Modify value” a new value to set and click on the set button in the tool bar. The new value will be set into the variable and the code will process with the new values.

Note: Keep in mind a variable which is set by the PLC program will overwrite the manual set value at every new cycle.

You can modify the display format to e.g. show a variable in hex or binary notation like  16#09 or 2#0000 1001. So it is easier to read e.g. “status words”.

Step 8 – More generic approach

At the block interface it is possible to define the input array with variable limits to offer better reusability for blocks with arrays of different length. Here for we have to adapt the interface at the FC and add code to determine the lower and upper bound of the array. It is also able to do this with multidimensional arrays.

Note: Keep in mind this feature is only available in the newer PLCs (1200/1500).

Pros and cons

Pro Con
Easy to write complex code Hard to track signal sequences (reason why it is not used for failsafe PLC coding)
Good for mass operations Bad logically overview
Easy programming of switch case Sometimes hard to read

Note: You are free to use the programming language of choice which fits best to your needs. In previous courses we saw using SCL networks within FBD code. E.g. program complex code in an SCL Block and interlocking section of Outputs in an FBD Block.

Some other hints

To get an overview over the available commands in the different languages, there is a document from SIEMENS online support which helps me a lot.

  • https://support.industry.siemens.com/cs/us/en/view/109778377

Written by Michael Elting
Mechatronics & Automation Engineer and Freelance Writer

Have a question? Join our community of pros to take part in the discussion! You’ll also find all of our automation courses at TheAutomationSchool.com.

Sponsor and Advertise: Get your product or service in front of our 75K followers while also supporting independent automation journalism by sponsoring or advertising with us! Learn more in our Media Guide here, or contact us using this form.

  • Author
  • Recent Posts

Michael is a freelance writer for The Automation Blog, as well as a degreed engineer of mechatronics, automation engineer, developer, trainer and mentor of internship. Beside his interests in techical topic he is a dedicated hicker and traveler.

Latest posts by Michael Elting (see all)

  • S7 PLCsim Advanced — July 20, 2021
  • S7 PLCsim — July 19, 2021
  • Writing your first TIA code in SCL — April 28, 2021

Понравилась статья? Поделить с друзьями:
  • Siruba dl7200 bm1 16 инструкция на русском
  • Нейромультивит уколы инструкция цена в уфе
  • Руководство для партнеров
  • Лего ниндзяго корабль мастера ву инструкция
  • Eveline укрепляющее средство для ногтей с бриллиантами инструкция