Programming

Overview

The Main type is always managed by an HSCMain_TM3 function block.

NOTE: At build time, an error is detected if the HSCMain_TM3 function block is used to manage a different HSC type.

Adding the HSCMain Function Block

Step

Description

1

Select the Libraries tab in the Software Catalog and click Libraries.

Select Intern > IODrivers > TM3 HSC > HSC > HSCMain_TM3 in the list.

2

Drag-and-drop the item onto the POU window.

3

Edit the default Main type instance name to match the Instance name of the counter function block defined in the Configuration window.

I/O Variables Usage

For the Period meter type, the outputs are automatically activated in case F_Out is activated, even if Valid = FALSE.

 WARNING
UNINTENDED EQUIPMENT OPERATION
Do not activate F_Out without verifying the consequences of the outputs activation.
Failure to follow these instructions can result in death, serious injury, or equipment damage.

The tables below describe how the different pins of the function block are used in Period meter type.

This table describes the input variables:

Input

Type

Description

HSC_REF_TM3

HSC_REF_TM3

Reference to the HSC instance.

EN_Enable

BOOL

When EN input is configured: if TRUE, authorizes the counter enable via the Enable input.

EN_Preset

BOOL

Not used.

EN_Cap

BOOL

Not used.

EN_Compare

BOOL

TRUE = enables the comparison function (using Thresholds 0, 1, 2, 3):

  • basic comparison (TH0, TH1, TH2, TH3 output bits)

  • reflex (Reflex0, Reflex1 output bits)

  • events (to trigger external tasks on threshold crossing)

    NOTE: This option is only available for TM3XF• expansion modules, which support external events.

EN_Out

BYTE

Set bits to 1 to enable corresponding physical outputs to echo the configured function value (Reflex or Stop) as a result of the comparison function.

Only active when outputs configured in HSC editor:

  • Bit 0: Output 0 enabled.

  • Bit 1: Output 1 enabled.

  • Bit 2: Output 2 enabled.

  • Bit 3: Output 3 enabled.

  • Bits 4...7: Not used.

Association of HSC output Outx with physical output Qy is done by configuration.

F_Enable

BOOL

TRUE = activates counter and takes into account pulses on the counter input.

F_Preset

BOOL

Not used.

F_Out

BYTE

Set bits to 1 to force corresponding physical outputs to 1 if associated with HSC by configuration. Takes priority over EN_Out.

Only active when outputs configured in HSC editor:

  • Bit 0: Output 0 forced.

  • Bit 1: Output 1 forced.

  • Bit 2: Output 2 forced.

  • Bit 3: Output 3 forced.

  • Bits 4...7: Not used.

Association of HSC output Outx with output terminal Qy is done by configuration.

ACK_Modulo

BOOL

Not used.

ACK_Preset

BOOL

Not used.

ACK_Cap

BOOL

Not used.

SuspendCompare

BOOL

TRUE = compare results are suspended:

  • Threshold, Reflex, and Out output bits of the function block maintain their last value.

  • Events are masked.

NOTE: EN_Compare, EN_Reflex, and F_Out remain operational while SuspendCompare is set.

This table describes the output variables:

Outputs

Type

Comment

Run

BOOL

TRUE = Counter is activated.

Edge to Edge: Set to 1 at rising edge detection, and reset to 0 at falling edge.

Edge to Opposite: Set to 1 at first rising edge detection.

It is only reset to 0 if the counter is disabled or an error is detected.

Valid

BOOL

TRUE = indicates that output values on the function block are valid.

Error

BOOL

TRUE = indicates that an error was detected.

ErrorId

HSC_ERROR_TM3

Indicates the value of the error detected. See HSC_ERROR_TM3 enumeration.

Thresholds

BYTE

Bits set to 1 when CurrentValue ≥ Threshold:

  • Bit 0: CurrentValue ≥ Threshold 0

  • Bit 1: CurrentValue ≥ Threshold 1

  • Bit 2: CurrentValue ≥ Threshold 2

  • Bit 3: CurrentValue ≥ Threshold 3

  • Bits 4...7: Not used

Only active when EN_Compare is set.

Modulo_Flag

BOOL

Not used.

Preset_Flag

BOOL

Not used.

Cap_Flag

BOOL

Not used.

Reflex

BYTE

State of the reflex function:

  • Bit 0: Reflex 0

  • Bit 1: Reflex 1

  • Bit 2: Reflex 2

  • Bit 3: Reflex 3

  • Bits 4...7: Not used

Out

BYTE

State of the physical outputs:

  • Bit 0: Out0

  • Bit 1: Out1

  • Bit 2: Out2

  • Bit 3: Out3

  • Bits 4...7: Not used

Association of HSC output Outx with physical output Qy is done by configuration.

CapturedValue

DINT

Not used.

CurrentValue

DINT

The value of the counter.