Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

CTD

Count-down counter. Decrements the counter value CV on each rising edge of CD. Output Q becomes TRUE when CV reaches or falls below zero.

IEC 61131-3

Section 2.5.2.3.4

Support

Not yet supported

Inputs

Name

Type

Description

CD

BOOL

Count-down input (decrements on rising edge)

LD

BOOL

Load input (loads PV into CV)

PV

INT

Preset value

Outputs

Name

Type

Description

Q

BOOL

Counter output (TRUE when CV <= 0)

CV

INT

Current counter value

Behavior

On each rising edge of CD, the counter value CV is decremented by one. When LD is TRUE, the preset value PV is loaded into CV. The output Q is TRUE when CV is less than or equal to zero.

Example

VAR
  counter1 : CTD;
  count_pulse : BOOL;
  load : BOOL;
  done : BOOL;
END_VAR

counter1(CD := count_pulse, LD := load, PV := 10);
done := counter1.Q;

See Also

  • CTU — count-up counter

  • CTUD — count up/down counter