DOCA0275EN-00

Counter Logic Commands

Overview

The custom logic editor uses the following counter logic commands:

  • COUNTER

  • COUNTER_NV

COUNTER

The COUNTER command:

  • Increments or decrements a count value

  • Provides a method for setting the count value to a preset value

  • Indicates when the count value equals 0

  • Indicates the relationship between the count value and the preset value - equal to, greater than or less than

  • Saves the increment, decrement and set status from the previous scan

Arguments

Representation

3

COUNTER TmpReg1 KValue TmpReg2

Input Argument

Type

Range/Bit

Description

KValue

UINT

0–65,535

Counter preset value

TmpReg2

UINT

Bit4

Increments the counter current value on a rising edge. Counter current value shall roll over from 0 to 65,535.

Bit5

Decrements the counter current value on a falling edge. Counter current value shall roll over from 65,535 to 0.

Bit6

Sets the current counter value to the preset value on a rising edge

Output Argument

Type

Range/Bit

Description

TmpReg1

UINT

0–65,535

Counter current value

TmpReg2

UINT

Bit0

The counter current value is 0: TmpReg1=0

Bit1

The counter current value is lower than the preset value: TmpReg1<KValue

Bit2

The counter current value is equal to the preset value: TmpReg1=KValue

Bit3

The counter current value is greater than the preset value: TmpReg1>KValue

Bit7

TmpReg2.Bit4 history bit

Bit8

TmpReg2.Bit5 history bit

Bit9

TmpReg2.Bit6 history bit

COUNTER_NV

The COUNTER_NV command:

  • Increments or decrements a count value

  • Provides a method for setting the count value to a preset value

  • Indicates when the count value equals 0

  • Indicates the relationship between the count value and the preset value - equal to, greater than or less than

  • Saves the increment, decrement and set status from the previous scan

Use the COUNTER_NV command, instead of the COUNTER command, to retain the count during a power cycle.

Arguments

Representation

3

COUNTER NVReg1 KValue NVReg2

Input Argument

Type

Range/Bit

Description

KValue

UINT

0–65,535

Counter preset value

NVReg2

UINT

Bit4

Increments the counter current value on a rising edge. Counter current value shall roll over from 0 to 65,535.

Bit5

Decrements the counter current value on a falling edge. Counter current value shall roll over from 65,535 to 0.

Bit6

Sets the current counter value to the preset value on a rising edge

Output Argument

Type

Range/Bit

Description

NVReg1

UINT

0–65,535

Counter current value

NVReg2

UINT

Bit0

The counter current value is 0: NVReg1=0

Bit1

The counter current value is lower than the preset value: NVReg1<KValue

Bit2

The counter current value is equal to the preset value: NVReg1=KValue

Bit3

The counter current value is greater than the preset value: NVReg1>KValue

Bit7

NVReg2.Bit4 history bit

Bit8

NVReg2.Bit5 history bit

Bit9

NVReg2.Bit6 history bit

QR Code is a registered trademark of DENSO WAVE INCORPORATED in Japan and other countries.

Was this helpful?