1. Example of subroutine call

ในหน้านี้4 หัวข้อ

Below is a simple example of calling a subroutine using its parameters and local variables.

1.1. Example#

Below is a simple example of calling a subroutine using its parameters and local variables.

1.2. Case study explanation#

Implement a program that adds two single characters and returns a double character result.

The subroutine 'addition' implements this logic.

 Subroutine parameter filling

图1 Subroutine parameter filling

1.3. Logic realise#

Implement an input bit parameter as an execution enable.

Implement two input single character parameters as operands for addition.

Implement a dual word parameter output as the result.

 logic realise

图2 logic realise

1.4. External call#

The ladder diagram below implements the call logic.

When M0=ON, D2=D0+D1. When M10=ON, D12=D10+D11.

 External call

图3 External call

The parameters for two CALL instructions are filled in as follows.

Parameter filling for the first CALL instruction

图4 Parameter filling for the first CALL instruction

 Parameter filling for the second CALL instruction

图5 Parameter filling for the second CALL instruction

อุปกรณ์ที่ใช้กับคู่มือนี้
2 รายการ
FAT-16MT-DC-E
FAT-16MT-DC-E

PLC 16 I/O 24V DC Transistor Output รองรับ Modbus RTU/RS485 TCP/IP

฿2,590

FAs-32MR-AC-E
FAs-32MR-AC-E

PLC 32 I/O 220V AC Relay Output รองรับ Modbus RTU/RS485 TCP/IP

฿3,690