AS编程原则 点击:2447 | 回复:9



gongkongedit

    
  • 精华:1099帖
  • 求助:0帖
  • 帖子:14392帖 | 54470回
  • 年度积分:0
  • 历史总积分:622
  • 注册:2008年9月08日
发表于:2003-08-12 17:31:00
楼主
以下是B&R一个工程师为AS写的编程指南,仅供参考. PROJECT GUIDELINES IN AS 1 PROGRAMMING CONVENTIONS 2 1.1 Data Types 2 1.2 Type Definition for IEC-Types: 2 directory structure 3 1.3 Software module name 3 1.4 Notation of Task 4 1.5 Data module notation 5 1.6 Variable notation 6 1.7 Constant notation 11 1.8 Alias-Names of function blocks 14 1.9 Revision number allocation 14 1.10 Task header 14 1.11 Data module header 15 1.12 Function block header 16 1.13 Function header 16 1.14 Inter Module or Task communication 17 1.15 Module status structure 23 1.16 State machines 24 1.17 allocate Memory 25 1.18 Software tests 29 1 PROGRAMMING CONVENTIONS With the Automation Studio we have a tool which makes it possible to create convincing variable names. · Variable Names 32 Character · Constant Names 32 Character · Task Names 8 Character · File Names W95/W98/WNT Name Conventions · 16 levels of Nesting levels for Structures These Programming conventions should be met when writing software, commissioning, as for SW-Changes later on. 1.1 Data Types In all supported programming languages in Automation Studio should IEC-Data Types be used. Also in ANSI C !!! This makes a change to other architectures later on a lot easier, because only the platform specific parts have to be written new. 1.2 Type Definition for IEC-Types: Data types from „bur\plctypes.h“ typedef unsigned char plcbit; typedef signed long plctime; typedef unsigned long plcdt; typedef char plcstring; typedef plcbit BOOL; typedef signed char SINT; typedef signed short INT; typedef signed long DINT; typedef unsigned char USINT; typedef unsigned short UINT; typedef unsigned long UDINT; typedef float REAL; typedef plctime TIME; typedef plcdt DT; typedef plcdt DATE_AND_TIME; typedef plcstring STRING; directory structure The Automation Studio saves normally all source files in the CPU-path of the project. But with the programming language „C“ it is possible to define sub directories for Source- and Include files, what makes the project more clearly presented. ../Cpu/SRC ../Cpu/INC 1.3 Software module name During the SW-concept-phase the main task gets split up in smaller parts which execute their defined tasks. Such a Software module should be one closed unit. It does a defined task and has a exactly defined interface to other software modules. A software module can either be one or more Tasks and Data modules. This module concept should also be used for Function blocks or functions (Libraries). 1.3.1 Notation of Modules A module get defined by 3 Characters. This character combination can be either letters or numbers. In all elements of the module like Tasks, data modules, global variables, function block names and function names this character combination will be found. 1.4 Notation of Task The affiliation of a Task to a software module has the be apparent of its name. A Task name can have 8 Character and they are defined as follows: mm_ttttt Abbreviation: Meaning mm_ Marker of module ttttt Marker of task in module To make it easier to read the marker after the Module notation should start with a Underline. Example: mi_drv 1.5 Data module notation The affiliation of a data module Task to a software module has the be apparent of its name. In some cases it is necessary to define the memory type of a datamodule. For example: copy in the flashprom, if the application writes onto the data module. A data module name can have 8 Character and they are defined as follows: mm_stttt Abbreviation: Meaning mm_ Marker of Software Module s memory type tttt Marker of Data Module memory type: : Abbreviation: Meaning _ no definition p Eprom/Flashprom x Fix-Ram r Ram example: mi_para Data module in the Software module MMI with the marker Para, no definition of memory type. mi_xpara Data module i



KINGHK

  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 58回
  • 年度积分:0
  • 历史总积分:47
  • 注册:2015年6月27日
发表于:2016-06-05 10:59:50
1楼

???看不见下了就上当下了就上当下了就上当下了就上当下了就上当下了就上当

nqsoon

  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 14回
  • 年度积分:0
  • 历史总积分:24
  • 注册:2016年4月09日
发表于:2016-08-24 15:17:14
2楼

这帖子内容是个狗屁!

小学生83165w

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 2回
  • 年度积分:0
  • 历史总积分:2
  • 注册:2016年4月12日
发表于:2016-09-10 21:26:56
3楼

都是些英文,看了头大

小飞123456

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 486回
  • 年度积分:0
  • 历史总积分:133
  • 注册:2013年10月23日
发表于:2017-03-27 09:02:05
4楼

都是些英文,看了头大

wuhualin77

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 106回
  • 年度积分:0
  • 历史总积分:1618
  • 注册:2012年6月29日
发表于:2018-01-26 20:47:30
5楼

都是些英文,看了头大


lyp6415237

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 40回
  • 年度积分:0
  • 历史总积分:101
  • 注册:2018年1月30日
发表于:2018-02-08 09:12:47
6楼

非常不错的资料,很有借鉴意义。

chun1989

  • 精华:0帖
  • 求助:0帖
  • 帖子:7帖 | 1151回
  • 年度积分:23
  • 历史总积分:1077
  • 注册:2012年11月20日
发表于:2019-12-25 13:32:32
7楼

非常不错的资料,很有借鉴意义。

HPAPPY

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 39回
  • 年度积分:0
  • 历史总积分:71
  • 注册:2003年9月18日
发表于:2020-11-24 13:27:09
8楼

怎么回事,都是字符

雨中漫步

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 26回
  • 年度积分:0
  • 历史总积分:52
  • 注册:2020年11月25日
发表于:2020-11-25 22:00:18
9楼

那么复杂


热门招聘
相关主题

官方公众号

智造工程师