Справочник Пользователя для Mitsubishi Electronics FX5

Скачать
Страница из 306
19  BUILT-IN I/O FUNCTION
19.3  Pulse Width Measurement Function
183
19
Examples of program
An example of a program using the pulse width measurement function is explained below.
Outline of operation
A program for measuring the delay time between the rising edges of input signals X1 and X2 on the CPU module is explained 
below.
Parameter setting
This program assumes that parameters are set as follows.
Input signals X1 and X2 are assigned to CH1 (X1) and CH2 (X2) by parameters. CH3 and CH4 need not be set.
Program
An operation diagram and program are shown below.
Operation diagram
Program
Item
CH to be used
CH1
CH2
Input signal
X1
X2
Input logic switching
Positive logic
Positive logic
Measurement mode
Always measurement mode
Always measurement mode
CH1(X1)
ON
OFF
This duration is measured
CH2(X2)
ON
OFF
HIOEN
H3
H0
K40
FEND
SM400
DHCMOV SD5020
D0
END
The latest rising edge value of CH2 is transferred to D3 and D2
Measurement of the CH1 and CH2 pulse width starts
DHCMOV SD5040
D2
User program
IRET
The latest rising edge value of CH1 is transferred to D1 and D0
Interrupt Return
K0
K0
D-
D2
D0
D8
D/
D8
K2
D10
Signals are converted to units of 1 μs and is stored in D11 and D10
Interrupt 
pointer 
I002
Command 
input
The value "Ring counter value at the rising edge of the input signal 
from CH2 - Ring counter value at the rising edge of the input 
signal from CH1 is stored in D9 and D8