Iec 61131-3 Second edition 2003-01 Programmable controllers – Part 3: Programming languages


Download 1.35 Mb.
Pdf ko'rish
bet137/158
Sana17.06.2023
Hajmi1.35 Mb.
#1528208
1   ...   133   134   135   136   137   138   139   140   ...   158
Bog'liq
ourdev 569653

Table E.1 - Error conditions
Subclause
Error conditions
3.2.2
Numerical result exceeds range for data type
Current result and operand not of same data type
3.3.1
Division by zero
Numerical result exceeds range for data type
Invalid data type for operation
3.3.2.1
Return from function without value assigned
3.3.2.4
Iteration fails to terminate
4.1.1
Same identifier used as connector label and element name
4.1.3
Uninitialized feedback variable
Copyright International Electrotechnical Commission 
Provided by IHS under license with IEC
Not for Resale
No reproduction or networking permitted without license from IHS
--``````-`-`,,`,,`,`,,`---


61131-3 
 IEC:2003(E)
– 169 –
ANNEX F
(informative)
Examples
F.1 Function WEIGH
Example function WEIGH provides the functions of BCD-to-binary conversion of a gross-weight input
from a scale, the binary integer subtraction of a tare weight which has been previously converted and
stored in the memory of the programmable controller, and the conversion of the resulting net weight
back to BCD form, for example, for an output display. The “EN” input is used to indicate that the scale
is ready to perform the weighing operation.
The “ENO” output indicates that an appropriate command exists (for example, from an operator
pushbutton), the scale is in proper condition for the weight to be read, and each function has a correct
result.
A textual form of the declaration of this function is:
FUNCTION WEIGH : WORD (* BCD encoded *)
VAR_INPUT (* "EN" input is used to indicate "scale ready" *)
weigh_command : BOOL;
gross_weight : WORD ; (* BCD encoded *)
tare_weight : INT ;
END_VAR
(* Function Body *)
END_FUNCTION (* Implicit "ENO" *)
The body of function WEIGH in the IL language is:
LD
weigh_command
JMPC
WEIGH_NOW
ST
ENO
(* No weighing, 0 to "ENO" *)
RET
WEIGH_NOW:
LD
gross_weight
BCD_TO_INT
SUB
tare_weight
INT_TO_BCD
(* Return evaluated weight *)
ST
WEIGH
The body of function WEIGH in the ST language is:
IF weigh_command THEN
WEIGH := INT_TO_BCD (BCD_TO_INT(gross_weight) - tare_weight);
END_IF ;
Copyright International Electrotechnical Commission 
Provided by IHS under license with IEC
Not for Resale
No reproduction or networking permitted without license from IHS
--``````-`-`,,`,,`,`,,`---


– 170 –
61131-3 
 IEC:2003(E)
An equivalent graphical declaration of function WEIGH is:
+-------------------------+
| WEIGH |
BOOL---|EN ENO|---BOOL
BOOL---|weigh_command |---WORD
WORD---|gross_weight |
INT----|tare_weight |
+-------------------------+
The function body in the LD language is:
| +--------+ +--------+ |
| | BCD_ | +-------+ | INT_ | |
| weigh_command | TO_INT | | SUB | | TO_BCD | ENO |
+-------| |-----|EN ENO|--|EN ENO|---|EN ENO|----( )------+
| | | | | | | |
| gross_weight--| |--| |---| |--WEIGH |
| +--------+ | | +--------+ |
| tare_weight---------------| | |
| +-------+ |
The function body in the FBD language is:
+--------+ +--------+
| BCD_ | +-------+ | INT_ |
| TO_INT | | SUB | | TO_BCD |
weigh_command---|EN ENO|---|EN ENO|---|EN ENO|---ENO
gross_weight----| |---| |---| |--WEIGH
+--------+ | | +--------+
tare_weight------------------| |
+-------+

Download 1.35 Mb.

Do'stlaringiz bilan baham:
1   ...   133   134   135   136   137   138   139   140   ...   158




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling