The SC2-C series PLC has 16 inputs and 16 outputs.
16-point input, DC24V, supports NPN/PNP type; the first 8 inputs are high-speed inputs with a frequency of 200K, which can be multiplexed as 4 high-frequency counters and support 4 comparator interrupts; they can also be multiplexed as 8 external input interrupts.
The SC2-C series PLC supports interrupts as shown in the table below:
The following is an application example of PLC external input interrupt.
Hardware connection
Connect the common input terminal S/S0 of the PLC body to 24V, the common output terminal COM to 0V, and the output port OUT02 to IN02, as shown in the figure below:
IN02 is the external input interrupt trigger port, which is triggered through OUT02.
Interrupt enable instruction introduction
01. Function block LS_EnableInterrupt
This function block is used to enable external input interrupts and high-speed comparison interrupts; when an interrupt occurs, it executes the associated interrupt task.
The function block LS_EnableInterrupt is shown in the following figure:
The parameters of the function block LS_EnableInterrupt are defined in the following table:
02. Introduction to the instruction error code LS_ERROR
Operating steps
PC IP address: 192.168.1.132 (same network segment as PLC)
The IP address of SC2-C is 192.168.1.3.
New construction projects
Open Lead Studio software and create a new project named "Example_SC2C_Interrupt", as shown in the following image:
Interrupt task settings
Right-click on the device tree's "Task Configuration," select "New Task," double-click to open the new task "Interrupt0," configure the task priority and task type, and call the written interrupt routine "Interrupt_POU," as shown in the following figure:
Interrupt program writing
1) The program executed when an external input interrupt is triggered;
2) The variable definitions for the external input interrupt demonstration program are shown in the following figure:
3) External input interrupt demonstration program: The program is shown in the figure below:
External input interrupt function test
1) Open Lead Studio software, open the project "Example_SC2C_Interrupt", compile it without errors, download the project to SC2-C, and click run, as shown in the following figure:
2) Double-click to open the external input interrupt demo program 【Interrupt_Demo】, set the “iState” value to 1, and start executing the “External Input Interrupt Demo Program”. After a 1-second delay, turn the output port OUT02 ON to trigger the input interrupt signal IN02 and execute the interrupt task Interrupt0 once, as shown in the figure below:
3) Wait for the program to complete. The monitoring shows that the "iState" value is 3, indicating that the external input interrupt demonstration program has completed execution. IN02 is triggered once on the rising edge, and the interrupt task Interrupt0 is executed once, as shown in the figure below:
Note: This example program is a simple test of the PLC's external input interrupt function. When input interrupt IN02 occurs, the associated interrupt task is executed.
END