![Xinje XD Series User Manual Download Page 298](http://html.mh-extra.com/html/xinje/xd-series/xd-series_user-manual_887444298.webp)
297
is the start ID of W and B. Take the above graph as the example, start with D0 and M0,
then W[0] is D0, W[10] is D10, B
[
0
]
is M0, B
[
10
]
is M10; if the used parameters
in the ladder are D100, M100, then W[0] is D100, B
[
0
]
is M100; if the parameters
in the ladder are HD0, HM0, then W[0]=HD0,B[0]=HM0; if the parameters in the
ladder are D100, HM100, then W[0]=D100, B[0]=HM100. So, word and bit
components start address are defined in PLC program by the user.
Note:
The coil and data type in one C language should be the same. All the coils in C
language are power loss retentive, or not power loss retentive; so is the same with data
register.
Parameter
W
: represent
Word
soft component, use it in the form of data group. E.g
W[0]=1; W[1]=W[2]+W[3]; in the program, use soft components according to standard
C language rules.
Parameter
B
: represent
Bit
soft component, use it in the form of data group. Support
SET
and
RESET
. E.g: B[0]=1; B[1]=0; And assignment, for example, B[0]=B[1].
Double word operation: add
D
in front of
W
. E.g. DW[10]=100000, it means
assignment to double-word W[10]W[11]. Double-word operation: Support the
definition of floating variable in the function, and execute floating operation;
(
E.g:
float register D0(double word) means FW[0], FW[0]=123.456
)
Other soft elements definition in C language:
In C language of PLC, if you want to use input(X) and output(Y), then macro definition
‘#define SysReg Addr_X_Y’ is needed; E.g: send the state of input X0 to given coil M0, then
B[0]=X[0]; send the state of Y0 to given coil M10, then: B[10]=Y[0];
(
Note: corresponding
X Y in C language is decimal, not Octonary number
)
.
Note: Marco definition #define SysRegAddr_X_Y should be behind the variable
definition, otherwise, it will be error.
Eg.
int a,b,c;
#define SysRegAddr_Y
b=3000;
c=W[1030];
a=b+c;
if(B[a]==1)
Y[3]=0;
In a similar way, if the not-power-loss-retentive flow S, Counter C, timer T, counter register
TD is in the C language, macro definition ‘#define SysRegAddr_S_C_T_CD_TD’ is also
needed; if the power-loss-retentive flow HS, counter HC, timer HT, counter register HCD,
timing register HTD etc, macro definition ‘#define
SysRegAddr_HS_HC_HT_HCD_HTD’ is
needed.
E.g: W[0]=CD[0];W[1]=TD[0];B[1]=C[0];B[2]=T[0];
Function Library: In
Function Block
, users can use the Functions and Constants in
function library directly. For the Functions and Constants in function library, see 9-8.
The other data type supported:
BOOL;
//BOOL Quantity