常量

         常量都用大写字母来表示, 用下划线 “_” 加强可读性。
VAR CONSTANT

         STEP_CONDITIONING: USINT := 23; (* [-] *)
         HEATING_TIME_OUT: UINT := 5000; (* [s] *)
         MAX_PRESSURE: REAL := 6.7e+006; (* [Pa]*)

END_VAR

Definition of object names

Object

Prefix

Description

Example

FUNCTION_BLOCK

FB_

Function Block

FB_GetData

STRUCT

ST_

Structure

ST_BufferEntry

ENUM

E_

Type of Enumeration

E_SignalStates

TYPE

T_

Reference

T_Nibble

PROGRAM

P_

Program

P_Axis

FUNCTION

F_

Function

F_Convert

Generating instances of objects

Object

Prefix

Description

Instance

Call example

function block

fb

Instance name from function block

fbGetData

fbGetData();

struct

st

Instance name of the structure

stBufferEntry

stBufferEntry.nCounter := 5;

enum

e

Enum instance

eSignalState

eSignalState := E_STOP;

alias type

none

Instance name of a reference type

Nibble

Nibble := 1;

Generating instances of variables

Type

Prefix

Description

Example

SINT, USINT, …, DINT, UDINT, BYTE, WORD, DWORD, LWORD....

n, i

numeric / integer

nCount, iError

BOOL

b

bit

bSwitch

REAL, LREAL

f

float

fValue

STRING

s

string

sName

TIME

t

time

tDelay

DATE

d

date

dMonday

DATE_AND_TIME

dt

date and time

dtNewYear

ARRAY[...] OF ...

arr

arrays

arrMessages

p

p

pointer

pData

Other prefixes that may also be used

Prefix

Description

Example

cb

count of bytes

cbLength

cw

count of words

cwRead

硬件链接变量

Prefix

Type

di

Digital input

do

Digital Output

ai

Analog input

ao

Analog output

 


文件标题

每个文件必须包含一个标题, 它包括:
• 作者和版权信息
• 简单介绍( 摘要注释) , 重点是程序目标, 输入输出变量, 程序运行的结果, 限制和接口设定
• 定时动作和内存要求( 临界状态)
• 版本号, 历史和数据

空格

为了增加可读性, 在每个操作符的前后都加上一个空格:
xAxisPos = x0 + deltaX;
if (machineState == STATE_RUN)

 


最后修改: 2019年08月1日 星期四 10:42