3724 Pulse Inputs

Epec 3724 control unit contains 8 pulse input channels.

 

 

To reset/overwrite the pulse counter, use function IO_PULSEIN_RESET.

 

 

 

The table below lists all software channels and related output pins.

 

 

Possible software channels and pairs (draft)

Pin

Min frequency for frequency and pulse width measurement

Max frequency

PI Channel

X3.16

0,1 Hz

20 kHz*

1

X3.17

0,1 Hz

20 kHz*

2

X3.18

0,1 Hz

20 kHz*

3

X3.19

0,1 Hz

20 kHz*

4

X3.20

0,1 Hz

20 kHz*

5

X3.21

0,1 Hz

20 kHz*

6

X3.22

0,1 Hz

20 kHz*

7

X3.23

0,1 Hz

20 kHz*

8

* The frequency sum for all the channels is 40 kHZ

* The maximum frequency value can be reached with 50 % duty cycle.

 

 

 

 

PLC Configuration

 

The following %I variables are provided for each pulse input channel.

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for pulse count.

Frequency/

Pulse width

WORD

0,01 Hz - 1 Hz /

1 us  - 1 ms

Frequency of the input signal. i_GateTime defines the used unit.

Measured pulse width. i_GateTime defines the used unit.

 

All of these variables are not automatically available, for more detailed description see the following chapters.

 

 

Configuration

 

DISABLED mode (1-ch)

Channels 1-8 can be disabled if pulse counting is not needed. PI channels are disabled by default.

 

The DI status can still be read from the pin's %IX address, see section 3724 PLCopen Addresses.

 

i_Mode

IO_MODE_DISABLED

i_ChannelNbr

Configured channel number 1,2,..,8

i_ResetChnNbr

No meaning. Use value 0.

i_ChannelPairNbr

No meaning. Use value 0.

i_EdgeSelect

No meaning. Use value 0.

i_EdgePolarity

No meaning. Use value 0.

i_GateTime

No meaning. Use value 0.

 

 

Example:

 

 (* Pin 3.21 is disabled.  *)

 

 IO_PULSEIN_SET_CONFIG(

     i_Mode:=IO_MODE_DISABLED,

     i_ChannelNbr:=6,

     i_ResetChnNbr:=0,

     i_ChannelPairNbr:=0,

     i_EdgeSelect:=0,

     i_EdgePolarity:=0,

     i_GateTime:=0);

 

 

1-ch mode

In one channel mode, channels 1-8 counts pulses.

 

i_Mode

IO_PULSEIN_MODE_1CH

i_ChannelNbr

Configured channel number 1,2,...,8

i_ResetChnNbr

No meaning. Use value 0.

i_ChannelPairNbr

No meaning. Use value 0.

i_EdgeSelect

Selects if channel counts one edge or both edges.

0 = one edge, 1 = both edges

i_EdgePolarity

Selects if channel counts rising or falling edge. Meaning only if i_EdgeSelect is 0

0 = falling edge, 1 = rising edge

i_GateTime

No meaning. Use value 0.

 

 

Available PI channel values:

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for pulse count.

 

 

Example:

 

 IO_PULSEIN_SET_CONFIG(

     i_Mode:=IO_PULSEIN_MODE_1CH,

     i_ChannelNbr:=1,

     i_ResetChnNbr:=0,

     i_ChannelPairNbr:=0,

     i_EdgeSelect:=0,

     i_EdgePolarity:=0,

     i_GateTime:=0);

 

 

2-ch (quadrature) mode

In two-channel mode, channels 1-8 measure the pulse count for pulse signals which are 90 degrees phase shifted.

 

Channel A is always the channel with the lower channel number. The pairs can be connected freely but the same channel cannot be used twice.

 

 

If the configuration is changed while the application is running, it is recommended to use the initialization function to disable the unused channels:

 

 The following example demonstrates how to configure channels to 2-ch mode.

 

i_Mode

IO_PULSEIN_MODE_2CH

i_ChannelNbr

Configured channel number 1,2,...,8

i_ResetChnNbr

No meaning. Use value 0.

i_ChannelPairNbr

Channel pair number 1,2,...,8

Cannot be the same as i_ChannelNbr

i_EdgeSelect

In 2-ch mode, the channel counts always both edges. In this mode the selection is used to select the counting direction.

In normal operating mode, use value 0 (count upwards if channel A is 90 degrees ahead of channel B).

Use value 1 to change the counting direction.

i_EdgePolarity

In 2-ch mode both edges are counted.

In normal operating mode, use value 1 (count upwards if channel A is 90 degrees ahead of channel B).

Use value 0 to change the counting direction.

i_GateTime

No meaning. Use value 0.

 

Available PI channel values:

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for pulse count.

Falling and rising edges of both channels increases the counter by one. One cycle increases the counter by 4.

 

 

Example:

 

 (* Use pins 3.16 and 3.17 to count pulses in 2-ch mode.

   Pulse count can be read from pins 3.16 and 3.17 PLC configuration values. *)

 

 IO_PULSEIN_SET_CONFIG(

    i_Mode:= IO_PULSEIN_MODE_2CH,

    i_ChannelNbr:=1,

    i_ResetChnNbr:=0,

    i_ChannelPairNbr:=2,

    i_EdgeSelect:=0,

    i_EdgePolarity:=1,   (*counting direction is upwards*)

    i_GateTime:=0);

 

 IO_PULSEIN_SET_CONFIG(

    i_Mode:= IO_PULSEIN_MODE_2CH,

    i_ChannelNbr:=2,

    i_ResetChnNbr:=0,

    i_ChannelPairNbr:=1,

    i_EdgeSelect:=0,     

    i_EdgePolarity:=0,   (*counting direction is downwards*)

    i_GateTime:=0);

 

 

 

 

2-ch (DIR) mode

In two-channel DIR mode, the A channel counts the pulses and channel B defines the counting direction.

 

Channel A is always the channel with the lower channel number. The pairs can be connected freely but the same channel cannot be used twice.

 

If the configuration is changed while the application is running, it is recommended to use the initialization function to disable the unused channels:

 

 The following example demonstrates how to configure channels to 2-ch mode.

 

i_Mode

IO_PULSEIN_MODE_2CH_DIR

i_ChannelNbr

Configured channel number 1,2,..,8

i_ResetChnNbr

No meaning. Use value 0.

i_ChannelPairNbr

Channel pair number 1,2,..,8

Cannot be the same as i_ChannelNbr

i_EdgeSelect

Selects if A channel counts one edge or both edges.

0 = one edge, 1 = both edges

B channel counts always both edges.

i_EdgePolarity

Selects if A channel counts rising or falling edge. Meaning only if i_EdgeSelect is 0

0 = falling edge, 1 = rising edge

i_GateTime

No meaning. Use value 0.

 

Available PI channel values:

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for pulse count.

A channel value depends on A and B channel's  pulse count. It may rise and fall depending on the count direction in the B channel.

When B channel is high, A channel value increases. When B channel is low, A channel value decreases.

B channel value includes only the pulse count of the direction channel. It can only rise.

 

Frequency/

Pulse width/

Digital status

WORD

Boolean

A channel: latest counting direction

B channel: channel's DI status

 

Example:

 

 (* Use pins 3.16 and 3.17 to count pulses in 2-ch DIR mode.

   Pulse count can be read from pins 3.16 and 3.17 PLC configuration values. *)

 

 IO_PULSEIN_SET_CONFIG(

    i_Mode:= IO_PULSEIN_MODE_2CH_DIR,

    i_ChannelNbr:=1,

    i_ResetChnNbr:=0,

    i_ChannelPairNbr:=2,

    i_EdgeSelect:=0,

    i_EdgePolarity:=1,   

    i_GateTime:=0);

 

 IO_PULSEIN_SET_CONFIG(

    i_Mode:= IO_PULSEIN_MODE_2CH_DIR,

    i_ChannelNbr:=2,

    i_ResetChnNbr:=0,

    i_ChannelPairNbr:=1,

    i_EdgeSelect:=0,     

    i_EdgePolarity:=0,   

    i_GateTime:=0);

 

 

 

Reset channel

One of the SW channels (see the table at the beginning of this section) can be configured to reset another channel.

 

The reset channel resets the pulse counter of the channel which has been configured as the target channel.

The reset channel does not reset the target channel's other values such as frequency or pulse width.

 

 

When using 2-ch mode, use the IW variable of channel A in application and reset the A channel.

 

 

i_Mode

IO_PULSEIN_MODE_RESET

i_ChannelNbr

Configured channel number 1,2,..,8

i_ResetChnNbr

Target channel number (the channel to be reset) 1-8

i_ChannelPairNbr

No meaning. Use value 0.

i_EdgeSelect

Selects if the channel counts and triggers a reset on one edge or both edges.

0 = one edge, 1 = both edges

i_EdgePolarity

Selects if the channel counts and triggers a reset on rising or falling edge. Meaning only if i_EdgeSelect is 0

0 = falling edge, 1 = rising edge

i_GateTime

No meaning. Use value 0.

 

Available PI channel values:

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for reset count.

 

Example:

 

 (* Pin 3.18 is used to reset pin 3.16.

   Reset count can be read from pin 3.18 PLC configuration. *)

 

 

 IO_PULSEIN_SET_CONFIG(

    i_Mode:= IO_PULSEIN_MODE_RESET,

    i_ChannelNbr:=3,

    i_ResetChnNbr:=1,

    i_ChannelPairNbr:=0,

    i_EdgeSelect:=0,

    i_EdgePolarity:=0,     (*Triggers reset on falling edge*)

    i_GateTime:=0);

 

 

 

Frequency mode (1-ch)

In frequency mode, channel 1-8 measures frequency and counts pulses.

 

 

i_Mode

IO_PULSEIN_MODE_FREQUENCY

i_ChannelNbr

Configured channel number 1,2,..,8

i_ResetChnNbr

No meaning. Use value 0.

i_ChannelPairNbr

No meaning. Use value 0.

i_EdgeSelect

Selects if channel counts one edge or both edges.

0 = one edge, 1 = both edges

i_EdgePolarity

Selects if channel counts rising or falling edge. Meaning only if i_EdgeSelect is 0

0 = falling edge, 1 = rising edge

i_GateTime

Frequency is reset if no new pulse edge is detected in given gate time. Value range: 0 - 10 000 ms.

 

0: frequency is not reset. Frequency unit is 1 Hz.

1 - 99 ms: Frequency unit is 1 Hz. Maximum frequency is 65536 Hz.

100 - 999 ms: Frequency unit is 0,1 Hz. Maximum frequency is 6553,6 Hz.

1000 - 9999 ms: Frequency unit is 0,01 Hz. Maximum frequency is 655,36 Hz.

10000 ms: Frequency unit is 0,001 Hz. Maximum frequency is 65,536 Hz.

 

 

Available PI channel values:

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for pulse count.

Frequency

WORD

1 mHz - 1 Hz

Frequency of the input signal. i_GateTime defines the used unit.

 

 

 

Example:

 

 (* Pin 3.19 is used to measure frequency.

   Pulse count and frequency measurement can be read from pin 3.19 PLC configuration.

   Frequency unit is 1 Hz and the frequency value is reset if there is no new rising pulse edge in 10 ms

 

   This configuration can be used above 100 Hz frequency. *)

 

 

 IO_PULSEIN_SET_CONFIG(

     i_Mode:=IO_PULSEIN_MODE_FREQUENCY,

     i_ChannelNbr:=4,

     i_ResetChnNbr:=0,

     i_ChannelPairNbr:=0,

     i_EdgeSelect:=0,

     i_EdgePolarity:=1,

     i_GateTime:=10);

 

 

 

Pulse width mode (1-ch)

In pulse width mode, channel 1-8 measures pulse width and counts pulses.

 

This mode measures always the pulse width from the rising edge to falling edge.

 

i_Mode

IO_PULSEIN_MODE_PULSEWIDTH

i_ChannelNbr

Configured channel number 1,2,..,8

i_ResetChnNbr

No meaning. Use value 0.

i_ChannelPairNbr

No meaning. Use value 0.

i_EdgeSelect

Selects if channel counts one edge or both edges.

0 = one edge, 1 = both edges

i_EdgePolarity

Selects if channel counts rising or falling edge. Meaning only if i_EdgeSelect is 0

0 = falling edge, 1 = rising edge

i_GateTime

Pulse width is reset if no new pulse edge is detected in given gate time. Value range: 0 - 10 000 ms.

 

0: Pulse width is not reset. Time unit is 1 us.

1 - 99 ms: Time unit is 1 us. Maximum width is 65536 us.

100 - 999 ms: Time unit is 0,01 ms. Maximum width is 655,36 ms.

1000 - 9999 ms: Time unit is 0,1 ms. Maximum width is 6553,6 ms.

10000 ms: Time unit is 1 ms. Maximum width is 65,536 s.

 

 

Available PI channel values:

 

Name

Data type

Unit

Description

Pulse count

WORD

 

16-bit value for pulse count.

Pulse width

WORD

1 us  - 1 ms

 

Measured pulse width. i_GateTime defines the used unit.

 

 

Example:

 

 (* Pin 3.20 is used to measure pulse width.

   Pulse count and pulse width measurement can be read from pin 3.20 PLC configuration.

   The pulse width unit is 1 us and the pulse width value is reset if there is no new rising pulse edge in 10 ms

 

   This configuration can be used above 50 Hz frequency with 50% pulse ratio. *)

 

 

 IO_PULSEIN_SET_CONFIG(

     i_Mode:=IO_PULSEIN_MODE_PULSEWIDTH,

     i_ChannelNbr:=5,

     i_ResetChnNbr:=0,

     i_ChannelPairNbr:=0,

     i_EdgeSelect:=0,

     i_EdgePolarity:=1,

     i_GateTime:=10);

 

 

 

 

Source file Topic000704.htm

Last updated 4-Sep-2025