Programming the Main Type

Overview

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

NOTE: At build time, a detected error code is given if the HSCMain 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 Controller > M218 > M218 HSC > Counter > HSCMain in the list, drag-and-drop the item onto the POU window.

2

Type the Main type instance name (defined in configuration) or select the function block instance by clicking:

G-SE-0005277.1.gif-high.gif

Using the input assistant, the HSC instance can be selected at the following path: Global Variables > <MyController> > Embedded Functions > HSC.

G-SE-0008014.1.gif-high.gif

 

 

I/O Variables Usage

The tables below describe how the different pins of the function block are used in One-shot mode.

This table describes the input variables:

Input

Type

Description

EN_Enable

BOOL

When EN input is configured: if TRUE, authorizes enabling of the counter with the Enable input.

EN_Sync

BOOL

When SYNC input is configured: if TRUE, authorizes the counter synchronization and start via the Sync input.

EN_Cap

BOOL

When CAP input is configured: if TRUE, enables the Capture input.

EN_Compare

BOOL

TRUE = enables the comparator operation (using Thresholds 0, 1):

obasic comparison (TH0, TH1 output bits)

oreflex (Reflex0, Reflex1 output bits)

oevents (to trigger external tasks on threshold crossing)

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

EN_Out0

BOOL

TRUE = enables physical output Output0 to echo the Reflex0 value (if configured).

EN_Out1

BOOL

TRUE = enables physical output Output1 to echo the Reflex1 value (if configured).

F_Enable

BOOL

Forces the Enable condition. Takes priority over EN_Enable input.

F_Sync

BOOL

Forces the Sync condition.

F_Out0

BOOL

TRUE = forces Output0 to 1 (if Reflex0 is configured in HSC Embedded Function. Takes priority over EN_Out0.

F_Out1

BOOL

TRUE = forces Output1 to 1 (if Reflex1 is configured in HSC Embedded Function. Takes priority over EN_Out1.

ACK_Modulo

BOOL

On rising edge, resets modulo-flag.

ACK_Sync

BOOL

On rising edge, resets Sync_Flag.

ACK_Cap

BOOL

On rising edge, resets Cap_Flag.

SuspendCompare

BOOL

TRUE = compare results are suspended:

oTH0, TH1, Reflex0, Reflex1, Out0, Out1 output bits of the block maintain their last value.

oPhysical Outputs Output0 and Output1 maintain their last value.

oEvents are masked.

NOTE: EN_Compare, EN_Out0,EN_Out1,F_Out0, F_Out1 remain operational while SuspendCompare is set.

This table describes the output variables:

Output

Type

Comment

HSC_REF

HSC_REF

Reference to the HSC.

To be used with the HSC_REF_IN input pin of the Administrative function blocks.

Validity

BOOL

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

Error

BOOL

TRUE = indicates that an error was detected.

Use the HSCGetDiag function block to get more information about this detected error.

CurrentValue

DINT

Current value of the counter.

Run

BOOL

TRUE = counter is running.

Switches to 0 when CurrentValue reaches 0. A rising edge on Sync is needed to restart the counter.

TH0

BOOL

Set to 1 when CurrentValue > Threshold 0.

TH1

BOOL

Set to 1 when CurrentValue > Threshold 1.

Modulo_Flag

BOOL

Set to TRUE when counter reaches 0.

Sync_Flag

BOOL

Set to 1 by the synchronization of the counter.

Cap_Flag

BOOL

Set to 1 when a new capture value is stored in the Capture register.

This flag must be reset before a new capture can occur.

Reflex0

BOOL

State of Reflex0.

Reflex1

BOOL

State of Reflex1.

Out0

BOOL

State of physical output Output0 to 1 (if Reflex0 is configured in HSC Embedded Function, otherwise FALSE if not configured).

Out1

BOOL

State of physical output Output1 to 1 (if Reflex1 is configured in HSC Embedded Function, otherwise FALSE if not configured).