Table of Contents

Ictd()

Ictd() loads the preset value, then decrements the current value at each input rising edge.

Ictd command operation flow

bool Ictd(uint8_t counter_id, bool CD, bool LOAD, int32_t PV)

Commands

Command Arguments Return Value Operation
Ictd(counter_id, CD, LOAD, PV) uint8_t counter_id — Counter number. Supports 0 ~ 255, the uint8_t range
bool CD
bool LOAD
int32_t PV — Preset value
bool Loads the preset value, then decrements the current value at each input rising edge.

Example

This example uses the P0 and P1 inputs and the P32 output on MPINO-8A4R(T)-S.

const uint8_t COUNTER_ID = 1;
const int32_t START_QUANTITY = 50;
 
void setup() {
  Serial.begin(115200);
}
 
void loop() {
  const bool shipped = digitalRead(0) == HIGH;
  const bool loadQuantity = digitalRead(1) == HIGH;
  const bool empty = Ictd(COUNTER_ID, shipped, loadQuantity, START_QUANTITY);  // Load the preset, then decrement the current value on each rising input edge.
  digitalWrite(32, empty ? HIGH : LOW);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List