X10
X10
M9000
M0
M1
M9002
M9002
X11
X11
M9000
M9000
MOVP K0 D9224
MOVP K4 D9224
DHHCMV D9226 D0
DHHCMVP K0 D9226
DHHCMVP K0 D9228
DHHCMV K1000 D9230
DHHCMV K2000 D9232
FEND
MOVP K0 D9225
MOVP K6 D9225
DHHCMV D9228 D2
REF Y0 K8
Y0
Y0
The X10 is the HHSC1's start signal.
When X10 is OFF, the HHSC1 is disabled.
When X10 is ON, the HHSC1's counting mode is AB-Phase×1.
Read the present value from the HHSC1 and store it to the D0.
Set the present value of the HHSC1 to zero.
Set the HHSC1's set value to 1000.
When its present value = set value, the IHHC1's interrupt will occur.
The X11 is the HHSC2's start signal.
When X11 is OFF, the HHSC2 is disabled.
When X11 is ON, the HHSC2's counting mode is AB-Phase×4.
Read the present value from the HHSC2 and store it to the D2.
Set the present value of the HHSC2 to zero.
Set the HHSC2's set value to 2000.
When its present value = set value, the IHHC2's interrupt will occur.
The First End instruction. End of the main program.
The pointer of the interrupt subroutine HHSC1.
Invert the output of the Y0.
Output the statuses of Y0~Y7 immediately.
IRET
The end of interrupt subroutine IHHC1 and return.
The pointer of the interrupt subroutine HHSC2.
IHHC1
IHHC2
Y1
Y1
M9000
END
REF Y0 K8
Invert the output of the Y1.
Output the statuses of Y0~Y7 immediately.
End of the user program.
IRET
The end of interrupt subroutine IHHC2 and return.
60
Program example:
This exemplary program is mainly used to describe the actual usage of the HHSC1 and HHSC2.
To use the HHSC, only need to set the counting mode at the special register, then the HHSC can start to count
obediently. When the PLC is executing the END instruction, the PLC system automatically reads the HHSC present
value from the hardware circuit, and store it in the present value register.
To get the most precise present value during the user program is in executing, can use the DHHCMV instruction to
read that from the hardware circuit immediately. When the DHHCMV instruction is executing, the PLC system rstly
reads out the HHSC hardware circuit's present value and stores it in the CPU's present value register, then transports
this value to the destination register of the DHHCMV instruction. Besides, to reset the present value of the HHSC
instantly, must use the DHHCMV instruction rather than use the RST instruction.
In addition, according to the quick response of the application requirement, can use its hardware comparison function
to immediately generate an interrupt, that could avoid the delay from the PLC's Scan Time.