PLCSIM Advanced的运行时API的例子讲解(二)



2 Engineering 

2.1 Configuration in the TIA Portal

The enclosed TIA Portal project does not require any further configuration. 

If you  create your own project, make the following settings in order to simulate with  S7-PLCSIM Advanced.

你下载的博图项目不需要做任何设置。

但是如果你创建的博图新项目,则需要做下面图片所示的设置。

image.png

1.通过右键单击项目,打开项目的上下文菜单。 

2.单击属性


image.png

1.选择保护标签。 

2.启用块编译期间的支持模拟选项框。 

3.确认为“OK”



2.2 Programming in Visual Studio

2.2 Programming in Visual Studio


The Visual Studio project included facilitates your access to programming a  S7-PLCSIM Advanced application with a co-simulation.

In the Visual Studio project some basic functions are already programmed, for  example, 

switching on virtual controller and exchanging I/O data. 

With this Visual  Studio project you can develop your applications further. 

In chapter 2.2.2 to 2.2.4 you find an overview of the C#- and API functions that are  programmed in this application example.


Visual Studio项目有助于编程S7-PLCSIM Advanced应用程序,并且与协同仿真一起使用。

Visual Studio项目中已经编程了一些基本功能,例如启动虚拟控制器和交换I/O数据。

此外,在第2.2.2到2.2.4章节中,您将找到本应用示例中编程的C#和API函数的概述。

这表明文档提供了关于如何使用Visual Studio项目进一步开发应用程序的详细信息。

功能描述
启动虚拟控制器通过Visual Studio项目中的代码可以启动虚拟控制器。
交换I/O数据项目中已经包含了交换输入/输出数据的代码。
C#和API函数概述第2.2.2到2.2.4章节提供了关于如何使用这些函数的详细信息。


2.2.1 Integrating the API library

Note

For the path to be updated in the included project 
you have to delete the existing  reference to the library 
“Siemens.Simatic.Simulation.Runtime.Api.x64” and  integrate it again.

Table 2-2: Integrating the API library

image.png


2.2.2 Overview user interface

In graphical user interface of the external application, 

commands (1) are integrated  to interact with the virtual controller (PLC Instance) and the co-simulation. The list box (2) shows info and error messages. 

The text field (3) shows the  respective status.


Figure 2-1: GUI

image.png


Table 2-3: Commands

image.png


2.2.3 Programming the PLC instance

Creating an instance

Table 2-4: Class “MainWindowViewModel.cs”

image.png

Table 2-5: Class “PLCInstance.cs”

image.png

2.2 Programming in Visual Studio

image.png


Unregistering instance

Table 2-6: Class “MainWindow.xaml.cs”

image.png

The application is closed with the “EXIT” button or with the “close” icon of the user  interface. 

This triggers the “Window_Closing” event


Switching on instance

Table 2-7: Class “MainWindowViewModel.cs”

image.png

Table 2-8: Class “PLCInstance.cs”

image.png

image.png

Switching off instance 

Table 2-9: Class “MainWindowViewModel.cs”

image.png

Table 2-10: Class “PLCInstance.cs”

image.png

Starting instance 

Table 2-11: Class “MainWindowViewModel.cs”

image.png

Table 2-12: Class “PLCInstance.cs”

image.png


Stopping instance

Table 2-13: Class “MainWindowViewModel.cs”

image.png

Table 2-14: Class “PLCInstance.cs”

image.png

Exchanging I/O data 

Table 2-15: Class “PLCInstance.cs”

image.png

image.png

2.2.4 Programming the co-simulation 

Simulation parameters 

Table 2-16: Class “MainWindowViewModel.cs”

image.png

Data exchange 

Table 2-17: Class “MainWindowViewModel.cs”

image.png

Table 2-18: Class “PLCInstance.cs”

image.png

Simulation program

Table 2-19: Class “Cosimulation.cs”

image.png



本文出自勇哥的网站《少有人走的路》wwww.skcircle.com,转载请注明出处!讨论可扫码加群:
本帖最后由 勇哥,很想停止 于 2025-01-05 20:57:31 编辑

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

会员中心
搜索
«    2025年4月    »
123456
78910111213
14151617181920
21222324252627
282930
网站分类
标签列表
最新留言
    热门文章 | 热评文章 | 随机文章
文章归档
友情链接
  • 订阅本站的 RSS 2.0 新闻聚合
  • 扫描加本站机器视觉QQ群,验证答案为:halcon勇哥的机器视觉
  • 点击查阅微信群二维码
  • 扫描加勇哥的非标自动化群,验证答案:C#/C++/VB勇哥的非标自动化群
  • 扫描加站长微信:站长微信:abc496103864
  • 扫描加站长QQ:
  • 扫描赞赏本站:
  • 留言板:

Powered By Z-BlogPHP 1.7.2

Copyright Your skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864