23
8. Function/Function block libraries 8-109 8.2 Function block libraries

8.2 Function block libraries - · PDF file8. Function/Function block libraries CTU 8-112 CTU Up counter(function block) Product GM1 GM2 GM3 GM4 GM5 Applicable Function Description

Embed Size (px)

Citation preview

8. Function/Function block libraries

8-109

8.2 Function block libraries�� ��������� ��� ����������������

�� ��� ��������������� ��� ���������������������������������� � ����� ��� �����������������������

���� ��� �������������� ������� ������ ��������� ��������

8. Function/Function block libraries CTD

8-110

CTDProduct GM1 GM2 GM3 GM4 GM5Down counter

Applicable � � � � �

Function Description

CTD

BOOL CD Q BOOL

BOOL LD

INT PV CV INT

Input CD : Down_Count pulse inputLD : Load preset valuePV : Preset Value

Output Q : Count_Down output

CV : Current Value

���� Function

� ��� �������� ��� ���!" ����������!#����������� ��� �������������! ��������$�� ���

� % ������� !#� ��� �������������� ��� ��� �������� ���� &��'()� �������� *+"� ����� ��� ��� �� �������������� ��

��� ����&��'()�

� ,���- �������.#����� ���� �!#�/!#0.#1

� 2����3����������!#�������������$�

���� Time chart- /.���������������1

! / �4! �����1

!#/!���������1

3/! �4 �� ���1

���� Program example.� ������������������ ����� �����536$���$��������������� ���� ������ �����5*$����7�

LD IL

%IX0.1.14

%QX0.3.0

CAL CTD COUNT_0

CD %IX0.1.14

LD _1ON

PV 5

LD COUNT_D.Q

ST COUNT_Q

LD COUNT_D.CV

ST COUNT_CV

LD COUNT_Q

S %QX0.3.0

.#/.����������1

8�9��� ������/&��'()1$

CTD 8. Function/Function block libraries

8-111

/�1 :������������ ��!" ����� ��� ���/!2;+"4 1

/�1 *������������ �����5*6$����7������������������������ ����� �! �

/�1 *���;����<���42+/���������� 1������� ����.#�� �!#�

/71 *������ �.#������������*+"�����/&��'()=��'('1�

/�1 *������������� ������������/!2;+"4!#1�� �!#�

/(1 *������������� ������������/!2;+"431�� �3�

/'1 >������ �������������� �������9���������� ���������������� �.-!�

/)1 �9���������� ���������/?� ��→�:1�������� ���������������

/@1 �� ��.#���������� ���� �!#/! �4!#1����������� ��������

/�$1 :�����!#/!2;+"4!#1���������������������� ���� ������ �����5*�$����7�

/��1 ,���+ ����������� ���� ���������� ������!#���������$����3�/!2;+"431�����������

/��1 ,���3�/!2;+"431������� ����� �����53$���$��������

8. Function/Function block libraries CTU

8-112

CTUProduct GM1 GM2 GM3 GM4 GM5Up counter(function block)

Applicable � � � � �

Function Description

CTU

BOOL CU Q BOOL

BOOL R

INT PV CV INT

Input CU : Up_Count pulse input

R : Reset input

PV : Preset Value

Output Q : Up_Count output

CV : Current Value

���� Function

� ;��� �������� ��� ���!";���������!#������������� �������������!;��������$�� ���

� % �������!#����������������������������������'('� ����9����*+"������������ ��������������������� ���

��'('�

� ,�������������:�������!#�����������/$1�

� 2����3����������!#���������������.#�

� ���������������!";��9�������.#������� ������� �!";����������� ������!";���������������� �� ������ �

���� Time chart

:/:��������1

!;/;�4! �����1 8�9��� ������/��'('1

.#/.������#���1

!#/!�����#���1

3/;�4! �� ���1

���� Program example.� ������������������ ����� �����536$����������$��������� ���� ������ �����5*6$������

LD IL

%IX0.1.5

%QX0.3.0

CAL CTU COUNT_U

CU %IX0.1.15

R %IX0.1.5

PV 10

LD COUNT_U.Q

ST COUNT_Q

LD COUNT_U.CV

ST COUNT_CV

LD COUNT_Q

S %QX0.3.0

CTU 8. Function/Function block libraries

8-113

/�1 :������������ ��!";����� ��� ���/!2;+"4 1

/�1 *������������ �����5*$����������������������������� ����� �!;�

/�1 *����$�� �.#�

/71 ?������������������ ������ �:�������������A���!#/5*$����1�

/�1 *���������������������/!2;+"4!#1�� �!#�

/(1 *������������� ������������/!2;+"431�� �3�

/'1 >������� ����������9���������� ���������������� �.-!�

/)1 �9���������� ���������/?� ��→�:1�������� ���������������

/@1 !����������!#/! �4!#1�������������������������������������� ���� ������ �����5*$������

/�$1 >�� ������ ����� !#� ��� �$� ��� ����� � � ������� ����� ���� + ��$� ����� ��� ��� � � ���� � ������ ���� ���

3/!2;+"431�����������

/��1 ,���3�/!2;+"431������� ����� �����53$���$��������

8. Function/Function block libraries CTUD

8-114

CTUDProduct GM1 GM2 GM3 GM4 GM5Up/Down counter(Function block)

Applicable � � � � �

Function Description

CTUD

BOOL CU QU BOOL

BOOL CD QD BOOL

BOOL R

BOOL LD

INT PV CV INT

Input CU : Up_Count pulse input

CD : Down_Count pulse input

R : Reset input

LD : Preset Value load

PV : Preset Value

Output QU : Count_Up output

QD : Count_Down output

CV : Current Value

���� Function

� ;�B ��� �������� ��� ���!"; ���������!#������������� �������������!;��������$�� ������!#���

�������������������� ��� �������������! ��������$�� ���

!#������������� ����������������!#����������������������&��'()������9�����������'('�����!#���

�������������� ����9����������!#������ �������������� ������������

� ,���- �������������������.#����� ������� �������!#/!#0.#1�

� ,���:������������������!#�����������/$1/!#0$1�

� 2����3;���������������!#����������������.#����3 ���������������!#�������������$�

� "��� ������ �� ���������������������9�������� ����� ��:�C�- �C�!;�C�! �����������������������������������

������ � ������������ ���������9������

���� Time chart

- /.��������������1

:/:��������1

!;/;�4! �����1

! / �4! �����1

!#/!���������1

3;/! �4;�� ���1

3 /! �4 �� ���1

.#/.����������1

$

CTUD 8. Function/Function block libraries

8-115

?">!D48>6/�$$��>1

$

���� Program example

LD IL

IN

OUT

CAL CTUD INS_CUD

CU:= IN

CD:= OUT

R := %M0

LD:= %M1

PV:= STACK_MAX

LD INS_CUD.QU

ST STACK_FULL

LD INS_CUD.QD

ST STACK_EMPTY

LD INS_CU.CV

ST STORED_NUMBER

"������������ ������� ����������������������� ���������������$$�/?">!D48>61����*+��������������������������������

���� ������� ����������2;"��������������������� ������� ���������������� ���� ������,���������������� ������

� � ������ ������� ���� � ������?">!D4<;--����� ������?"2:� 4+;8��:� �������� �$$/?">!D48>61��2� ���

� ����������������� �����������������?">!D4�8."E������

58�

58$

*+

2;"

?"2:� 4+;8��:

?">!D4<;--

?">!D4�8."E

8. Function/Function block libraries F_TRIG

8-116

F_TRIGProduct GM1 GM2 GM3 GM4 GM5Drop edge detection(Function block)

Applicable � � � � �

Function Description

F_TRIG

BOOL CLK Q BOOL

Input CLK : Input signal

Output Q : Falling edge detection result

���� Function<4":*F� �������� � ����3���������� �!-D���������� ����� �$���� ����$�� � ����3�����9���9���� �

2���������� ����3�����������$�

���� Time chart

!-D

3

→ ← /������ ��<4":*F��9���� ����1

���� Program example

LD IL

%IX0.0.0CAL F_TRIG INS_FT

CLK:= %IX0.0.0

LD INS_FT.Q

ST FALL_DETECT

8 �� �� ���� ������ �� ���� ��������� 5*$�$�$� ��� ���� �� � � ���� ��������� <>--4 �"�!"� ���� ���

���������5*6$�$�$���������� ����� �$��2����$�� �<>--4 �"�!"�

I_HSC 8. Function/Function block libraries

8-117

I_HSCProduct GM1 GM2 GM3 GM4 GM5Internal high speed counter (Function Block)

Applicable �

Function Description

I_HSC

BOOL REQ DONE BOOL

BOOL RST ERR BOOL

USINT PO S STG USINT

USINT M ASK OUT USINT

UDINT PV_1 CV UDINT

USINT ST_1

UDINT PV_4

USINT ST_4

Input REQ : Counter operation input

RST : Counter reset input

POS : Direct output position selection

MASK : Output contact selection of the module

PV_1 : Stage 1 Preset Value

ST_1 : Stage 1 output (Status)

Stage range is from 1 to 4.

Output DONE : Output '1' when final stage is completed

ERR : Error display

STG : Stage under count

OUT : Preset value of counting stage

CV : Current value of counting stage

���� Function

� ������������ ���������������&������� ��������������������������� ���� ��F8���"���� ���������A���%?!G���

%?!&� ������� �������������"�������������� ���������� ��

# ����� H �$#=�7#

*�������� H �(�>/�7#1��(�'�>/�$#1

8���2<<�� ����� H �#

! ������� H �$D����

� :�3 H :������������� �������������� �������������� ��������� ����������������� ������� ���� ��� ��I$I��

I�I�������� ������ �� ���������:�3����I$I������� �������� ��� ������������ ��������� �� ������

������� ������������ ���� ���������� ��I$I�� �I�I��< ����������������9�����:�?�"����������������:�3

� ���� �

� :?" H :�� ������� ����������� �� I�I����������������������� ����������*��:?"�0� I$I����:�3�0� I$I��� I�I�

��������������������������������������� �������

� .2? H ?����������� ����� ���� �� � ���������� �������������������*������ ��53�$���$��������I�I������������

� ���� ������ ��� �����*������� ����� ��������� ���� ������������������� ������::���������I�I���

<������� �� ��������- ����)�� ��� ����������� ����������������

� 8>?D H ?������������ ����� ������� ��)����������� ��������.2?��"� ���)� ����� �����������������.2?�

���� � ������ ������ 8>?D� �������� I�I�� ��� ���� � �� ������ ���� � ������ < �� �9������� ��� .2?0$� ��

8>?D0�(J$<�������� ����� �������������� ����7�� ��� ��+ ��$�� ����

� �:: H ���������� �������� ��<��

� ?"F H ������������������ ����������

� 2;" H 2����������������� ��������/?"491� ��������� ����������

8. Function/Function block libraries F_TRIG

8-118

*��:�3�� ���� � ��� ����������� ������ ���� � �� �� ��$���� ����?"4������� � �2;"� ���������� ���� ������������ �

.#4���,�������� ����� ��������������������.#4����������A������� ����� ��9�������������/.#4�1���� ���

?"4��������>������9���������������������.#49�������� ����$�� ���� I�I�� � 2+�����I$I� � �2;"���������� �����

��������� ���� �

���� Time chart

���

���

��

��

��� � � � �

����

����

���

����

����

���� ���� ��� ���� ���� ���� ��� ���

���

���� Program example,���.#�0�$$��.#�0)$��.#�0��$����.#70�$��I$I���������� ������������������ ��$�� �.#�� ������&������� ����

I�I���������� ������������������ ��.#��� �.#�� ������&������� �������I�I���������� ������������������ ��.#���

.#7� ������&������� �����"��� ��������������������������� ���������� �� ��������� � ������ ��� ����

������� ������"����� ������9��������������������������� ����� �������������������������� ��

#>-#��H�53�$�$�$ 0C .2?�0�$

#>-#�K$L�H�536$�$�$

#>-#�K�L�H�536$�$��

#>-#�K�L�H�536$�$�� 0C 8>?D�0��(J$<

#>-#�K�L�H�536$�$��

I_HSC 8. Function/Function block libraries

8-119

LD IL

CAL I_HSC INT_HSC

REQ := START

RST := RESET

POS := POS

MASK:= MASK

PV_1:= PV1

ST_1:= 1

PV_2:= PV2

ST_2:= 2

PV_3:= PV3

ST_3:= 4

PV_4:= PV4

ST_4:= 8

LD INT_HSC.DONE

ST END

LD INT_HSC.ERR

ST ERROR

LD INT_HSC.STG

ST STAGE

LD INT_HSC.OUT

ST OUT

LD INT_HSC.CV

ST CUR_VAL

"����������������������� ��

���

���

���

���

� �

��

�����

�����

�� ���

������

����

���

���

8. Function/Function block libraries RS

8-120

RSProduct GM1 GM2 GM3 GM4 GM5Reset Priority Bistable(Function block)

Applicable � � � � �

Function Description

RS

BOOL S Q1 BOOL

BOOL R1

Input R1 : Reset condition

S : Set condition

Output Q1 : Operation result

���� Function

:�� � � � � � � � � � � � � � � � � � � � M� � � � � � � � � � � � � � 3�

� � � � � � � � � �

?� � � � � � � � � � C0�

3�

*��:������������ ����3������������������$������������ ��?�

"��� ����3��� ��������� �������������� ����������:�����$����?������

"���������������� ��3�����$�

���� Time chart

:�

?

3�

���� Program example

LD IL

CAL RS INS_R

S: = SET1

R1: = RESET1

LD INS_R.Q

ST RESULT

"����:�?�"�����:������ ���� ����?�"�����?���� ���� ���� ��������������� �:�?;-"�

< ������ ������ ����������������:�����:�?�"�����?����?�"�����3�����:�?;-"������������������

/�1 ,��������������������?�"�����:�?�"����� �������� ��������� �������������:�?;-"�����������

/�1 ,��������������������:�?�"����� ������ �������������:�?;-"���������$�

/�1 ,��������������������?�"�����:�?�"����� �������� ��������� �������������:�?;-"���������$�

R_TRIG 8. Function/Function block libraries

8-121

R_TRIGProduct GM1 GM2 GM3 GM4 GM5Rising edge detection (Function Block)

Applicable � � � � �

Function Description

R_TRIG

BOOL CLK Q BOOL

Input CLK : Input clock

Output Q : Rising edge detection result

���� Function:4":*F�������� ����3�� ���������������� �!-D������������� ��$�� ����������������� �$�����9���9���� �

���� Time chart

!-D

3

→ ← /������ ��:4":*F��9���� ����1

���� Program example

LD IL

CAL R_TRIG INS_RT

CLK: = IN_SIGNAL

LD INS_RT.Q

ST RISE_DETECT

/�1 2������ � �:*?�4 �"�!"�����*+4?*F+>-������������� ��$� � ������$� � �:*?�4 �"�!"������*+?4:"

�9���� �

8. Function/Function block libraries SEMA

8-122

SEMAProduct GM1 GM2 GM3 GM4 GM5Semaphore for system resource control(Function block)

Applicable � � � � �

Function Description

SEMA

BOOL CLAIM BUSY BOOL

BOOL RELEASE

Input CLAIM : Resource monopoly request signal

RELEASE : Release signal

Output BUSY : Acquisition disable signal of requestedresource(Wait)

���� Function"�������� ��� ����������� ���N���������9�������� �� �������� ���������������� ����

�����9������?�8>����� /!->*8�0��� ��$��:�-�>?��0�$1���;?E�������������� ������� ���������������

��� �����" ���N��������� �� �������� ����� ����� �������?�8>������!->*8�0������:�-�>?��0�$�������������

�;?E���� ����$��,����;?E���� ����$��� �� ������������� ��������9�����?�8>� ��������!->*8�0�$���

:�-�>?��0���������� �� �� ������ �� �������������� �� ��������

/"����������� ��� �� �����������?�8>������!->*8�0�$����:�-�>?��0�������������9�������������� ���������

��������� �� ����������������1

O ?�8>I������������������������������ ���������� �������������� �� ����������� �������N������������ ����

O ������� �������N������������� ���������������������������� �����

O ?����� ����������������F8�������!.;�� �����

O *�������9���� ��������� ��?�8>����� ��� ��

#>:� � 6�H��22-�H�0�$�P� � �+ 4#>:

�;?E�H�0�6�P

*<� � !->*8� � "%�+� � 6�H�0���P

�-?*<� � :�-�>?�� � "%�+� � �;?E�H�0�$P�6�H�0�$�P

�+ 4*<

���� Time chart*������ ���9��������������������� ���������� �������� ������� ���>������ ������� �����

!->*8 > � > �

:�-�>?� > � >

�;?E

! �� ������� ;���> ;���� ;���> ;����

SEMA 8. Function/Function block libraries

8-123

���� Program example

LD IL

CAL SEMA PRINTER

CLAIM:= START

RELEASE:= END

LD PRINTER.BUSY

ST NOT_AVAIL

*� ������ � ����������������� ������� �������������������.-!����������������������������I.:*+"�:I������ ������

� �� ������� �� �������� ������������?�8>����� ��� �����������I.:*+"�:I��������

�;?E�������������������� ������� �+2"4>#>*-���� ������� ������� �����������������������N���� ��� �� ����������

I.:*+"�:I�?�8>�����?">:"����������+ ����$������������� ��������� ����

*�� ������� ���� ��� ����������������;?E���� ����$���������� ������ �� ��������������� ����������������� ��������

>������ ����������������� ������ ���9�����I.:*+"�:I�?�8>������?">:"�0�$�����+ �0���� ������ ������� �����

���������� �� �������� ���������

#>:4�6"�:+>-

.:*+"�:�H�?�8>

�+ 4#>:

?� + !->*84."

"�� ."4>#>*-

?� + .:*+"*+F

"� .:"4�+

?� . :�-4.:"

"� :�4.:"

?� !->*84."P�.������� �� ����������N���

CAL SEMA PRINTER

CLAIM:= 1

RELEASE:= 0

"� ."4>#>*-P�.������� �� ����������N����� ������

LDN PRINTER.BUSY

ST TRANS

?� .:*+"*+F�P�.���� ���

Printer control program

When completing the print, PRINT_DONE:= 1

"�� � � .:"4�+ �P�.����� ������ ������

LD PRINT_DONE

ST TRANS

?� :�-4.:"�P�.������� �� ���������������

CAL SEMA PRINTER

CLAIM:= 0

RELEASE:= 1

"�� � � :�4.:"�P�.��������N��������

LD PRT_REQ

ST TRANS

8. Function/Function block libraries SEMA

8-124

Print output

User FBOrProgram

SR 8. Function/Function block libraries

8-125

SRProduct GM1 GM2 GM3 GM4 GM5Set Priority Bistable

Applicable � � � � �

Function Description

SR

BOOL S1 Q1 BOOL

BOOL R

Input S1 : Set condition

R : Reset condition

Output Q1 : Operation result

���� Function

?�� � � � � � � � � � � � � � � � � � � � � C0�� � � � � � � � � � 3�

:� � � � � � � � � � � � �M

3�

,���?�������� ����3����� ������������������������ ��:�

2����3��� ��������� �������������� ����$�����?�����$����:������

*������������ �� � 3�����$�

���� Time chart

?�

:

3�

���� Program example

LD IL

CAL SR INS_S

S1: = SET1

R: = RESET1

LD INS_S.Q1

ST RESULT

/�1 ,��������������������?�"��2������ �������������:�?;-"�����������

/�1 *���������������?�"�����2<<����:�?;-"�����2�� �������������:�?;-"���������$�

8. Function/Function block libraries TOF

8-126

TOFProduct GM1 GM2 GM3 GM4 GM5OFF delay timer(Function block)

Applicable � � � � �

Function Description

TOF

BOOL IN Q BOOL

TIME PT ET TIME

Input IN : Timer operation condition

PT : Preset Time

Output Q : Timer output

ET : Elapsed Time

���� Function*��*+�������3���� ���������3���� ����$���������������������� ��*+0$�� ����������������."�

2���������������������� ��"�������*+���� ����$�

*��*+���� ��������� ����"������������������������������������������������$�

���� Time chart

*+

3

."

.�����������."

�"

� � � � �

���� Program example

LD IL

INS_TOF

TOFT_OFF

T#10S PT

IN

ET

Q

ET_TIME

TIMER_OK

CAL TOF INS_TOF

IN:= T_OFF

PT:= T#10S

LD INS_TOF.Q

ST TIMER_OK

LD INS_TOF.ET

ST ET_TIME

TOF 8. Function/Function block libraries

8-127

"42<<

"*8�:42D �$�

.������������$�

�"4"*8�

*�� �������������"42<<� ������ � �������������"*8�:42D� ����������"*8�:42D���� ����$� �� ��� ��� ��� �����

"42<<��*��"42<<���� ���������$���� ���������������$����������������������A����"���������������� ����������� �����

�"4"*8��

8. Function/Function block libraries TON

8-128

TONProduct GM1 GM2 GM3 GM4 GM5ON delay timer(Function block)

Applicable � � � � �

Function Description

TON

BOOL IN Q BOOL

TIME PT ET TIME

Input IN : Timer operation condition

PT : Preset Time

Output Q : Timer output

ET : Elapsed Time

���� Function2���������������������� ��"�������*+������

*��*+����$���� ����"���������������������������������������������� ����$�

*��*+����$�������3�������3���������$�

���� Time chart

*+

3

."

.�����������."

�"

� �

���� Program example

LD IL

INS_TON

TONT_TON

T#10S PT

IN

ET

Q

ET_TIME

TIMER_OK

CAL TON INS_TON

IN: = T_ON

PT: = T#10S

LD INS_TON.Q

ST TIMER_OK

LD INS_TON.ET

ST ET_TIME

TON 8. Function/Function block libraries

8-129

"42+

"*8�:42D

�$�

� �.������������$�

�"4"*8�

/�1 *��$���� ����������������������"42+������� � �������������"*8�:42D������

/�1 >������������������"42+��������������������������� ����� � ��������������"&"*8��

/�1 *��"42+���� ����$���� ����"4"*8���������������������������$���� ����������������������"4"*8����������$�

/71 *��"42+���� ����$�������"*8�:42D�������"*8�:42D���� ����$����������������������"4"*8����� ����$�

8. Function/Function block libraries TP

8-130

TPProduct GM1 GM2 GM3 GM4 GM5Pulse timer(Function block)

Applicable � � � � �

Function Description

TP

BOOL IN Q BOOL

TIME PT ET TIME

Input IN : Timer operation condition

PT : Preset Time

Output Q : Timer output

ET : Elapsed Time

���� Function*��*+�������3���� ������������������������������"���������."��3���� ����$��� ����������

��������������"�����������������*+���������� ����������������������������."������� ����$�����*+����$��*�

� ��� �����������������*+����$� �������������������"�

���� Time chart

*+

3

."

.�����������."

�"

� � �

���� Program example

LD IL

INS_TP

TPT_TP

T#10S PT

IN

ET

Q

ET_TIME

TIMER_OK

CAL TP INS_TP

IN: = T_TP

PT: = T#10S

LD INS_TP.Q

ST TIMER_OK

LD INS_TP.ET

ST ET_TIME

TP 8. Function/Function block libraries

8-131

"4".

"*8�:42D� � � � � � �$�� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � .������������$���� ��

�"4"*8�

/�1 >������������������"4".���������� ��$�� ����"*8�:42D�����������������$���� ����>��������������������������

������ ��"4".������������ ����� ���$���� ���

/�1 �"4"*8��������� ������"J�$?�����������������,���"4".����$���"4"*8����� ���