basic course 22

2
VOL. Example Top Back Contact Us High-speed interrupt input function 22 Measure the time during which the target passes two points A and B and calculate the passing speed. The FS-M1H high-speed response photoelectric sensor is used as the sensor. The passing time is measured with the internal clock of the high-speed counter in the unit of µs. Applications: Measurement of the swing speed of a golf club head. Programming Technique Point 1: Measure the passing time with the internal clock of the KV. Use the KV’s internal clock (1-µs cycle) and the high-speed counter to measure the passing time. (Passing time) = (Cycle of internal clock: 1 µs) x (No. of clock counts) Point 2 The interrupt (INT) instruction is the best for the program. When the sensor detects the target, the interrupt is executed. Store the current value of the high-speed counter in the data memory. When the interrupt is executed, the current value of the high-speed counter is automatically stored in the data memory (Input capture function). By using this function, the passing time is obtained as the difference between the stored counter values of sensor 1 and sensor 2. (Passing time) = [yyyyy (DM1934) - xxxxx (DM1932)] x (Cycle of internal clock: 1 µs) ON OFF ON OFF Sensor 2 INPUT 0003 Sensor 1 INPUT 0002 Sensor 1 Sensor 2 Sensor 1 Sensor 2 Internal clock (1 µs) No. of clock counts Passing time DM1934 DM1932 No. of clock counts Sensor 1 (Interrupt 0002) Passing time Sensor 2 (Interrupt 0003) Internal clock (1 µs) No. of pulses = xxxxx No. of pulses = yyyyy (Value stored by the input capture of 0003) (Value stored by the input capture of 0002) Measurement of passing time between two points using high-speed interrupt input Outline Visual KV Series Passing time (µs)

Upload: jns1606

Post on 09-Nov-2015

5 views

Category:

Documents


3 download

DESCRIPTION

hhh

TRANSCRIPT

  • VOL.Example

    Top Back Contact Us

    High-speed interrupt input function22

    Measure the time during which the target passes two points A and B and calculate the passing speed.The FS-M1H high-speed response photoelectric sensor is used as the sensor. The passing time is measured withthe internal clock of the high-speed counter in the unit of s.

    Applications: Measurement of the swing speed of a golf club head.

    Programming TechniquePoint 1: Measure the passing time with the internal clock of the KV. Use the KVs internal clock (1-s cycle) and the high-speed counter to measure the passing time.

    (Passing time) = (Cycle of internal clock: 1 s) x (No. of clock counts)

    Point 2 The interrupt (INT) instruction is the best for the program. When the sensor detects the target, the interrupt is executed. Store the current value of the high-speed counter

    in the data memory.When the interrupt is executed, the current value of the high-speed counter is automatically stored in the datamemory (Input capture function).By using this function, the passing time is obtained as the difference between the stored counter values ofsensor 1 and sensor 2.

    (Passing time) = [yyyyy (DM1934) - xxxxx (DM1932)] x (Cycle of internal clock: 1 s)

    ONOFF

    ONOFF

    Sensor 2INPUT 0003

    Sensor 1INPUT 0002

    Sensor 1

    Sensor 2

    Sensor 1

    Sensor 2

    Internal clock(1 s) No. of clock

    counts

    Passingtime

    DM1934DM1932

    No. of clockcounts

    Sensor 1(Interrupt 0002)

    Passingtime

    Sensor 2(Interrupt 0003)

    Internal clock(1 s)

    No. of pulses = xxxxx No. of pulses = yyyyy

    (Value stored by the input capture of 0003)(Value stored by the input capture of 0002)

    Measurement of passing time between two points using high-speed interrupt input

    Outline

    Visual KV Series

    Passing time (s)

  • Top Back Contact Us

    VOL. 22 High-speed interrupt input function

    Programming Example Measures the time from when input relay 0002 turns ON until input relay 0003 turn ON. The measured value is written to data memory DM0000 (Unit: s). Writes the calculated speed into DM0010 (unit: m/ms).

    (This program sets the distance between sensor 1 and sensor 2 to 1 m.)2008

    2002

    2002

    2412RES

    2413RES

    2410RES

    2411RES

    HSP0002

    CTH12200

    END

    0002

    RETI

    RETI

    ENDH

    HSP0003

    2002 DM0000STA

    DM1932SUB

    DM1934LDA

    DM0010STA

    DM0000DIV

    #01000MUL

    #00001LDA(1) (2)

    EI

    INT

    0003INT

    #00100MUL

    #00100LDA

    DM0000DIV

    DM0010STA

    #01000MUL

    When power is turned on, an EL instruction enablesinterrupts. Sets the interrupt polarity of inputs 0002 and0003 to the rising edge.

    Sets the input time constant of inputs 0002 and 0003 to10 s.

    CTH1 counts the pulses using a 1-s internal clock.

    When INT0002 is executed, the current value of CTH1 isautomatically transferred to DM1932 and DM1933 (Inputcapture).

    When INT0003 is executed, the current value of CTH1 isautomatically transferred to DM1934 and DM1935 (Inputcapture).Subtracts the input capture value of INT0002 from thatof INT0003 to obtain the time it takes for the target topass between two points and then writes it to DM0000.(Unit: 1s)The passing speed is obtained through calculating (2)the passing time and (1) the distance between the twopoints (unit: m/ms). It is stored in DM0010.

    Calculation of passing speedThe passing speed is calculated with the following expression:

    Passing speed (m/ms) = ((1) Distance between two points [Unit: m]) / ((2) Passing time [Unit: ms])

    In the program above, the passing time is measured in the unit of s. Therefore, the meas-ured value is multiplied by the factor of 1000 (2) to be converted into the value in the unit ofms. The calculation uses 1 m (1) as the distance between the two points.

    To set the distance between the two points in the unit of cm, multiply it by the factor of 100 asthe underlined section in the following program. The unit of speed is set to cm/ms.

    To convert the unit of time from s to s (second), multiply values by the factor of 1,000,000(execute 1,000x twice in a program).

    Tips