Try Embedded

Time a 5 s on-delay with a timer relay

Power a multi-function timer relay through an interface relay, and have the Arduino measure how long its contact takes to close through an optocoupler.

Industrial · Intermediate

In a real product: Motor star-delta starter (Industrial): A timer relay sequences the motor's start.

A timer relay switches a contact a set time after it is powered, with no program at all. It is how star-delta starters, stair lights and "run the fan a bit longer" circuits were built long before PLCs. This project powers one from the Arduino and measures it from the other side.

What you'll learn

  • The on-delay function: power on, wait the set time, then 15 switches from 16 to 18
  • An interface relay as the isolated stage between a controller and a 24 V circuit
  • Switching a 24 V coil from a pin with a solid-state relay
  • Measuring a time with millis() and an optocoupler input

How it works

Pin 8 drives the solid-state relay's input. The SSR connects 24 V to the interface relay's coil (A1-A2), and that relay's contact (11-14) powers the timer relay's supply. The timer is set to on-delay and 5 seconds: when it is powered it counts, then closes 15-18.

Contact 18 lights the pilot lamp and also goes to the optocoupler's IN1. The module's OUT1 is HIGH with no input and goes LOW when the timer's contact closes, so the sketch can time it: it stamps millis() when it switches the supply on and stamps again when pin 2 goes LOW. The difference should be close to 5000 ms.

Try this

  • Change the timer relay's mode to interval: the contact closes at power-on and opens after the time.
  • Choose off-delay and use the B1 input: the contact holds on for the time after B1 opens.
  • Set the time to 1 s and compare the measured time with the setting.

sketch.ino

// Powers a timer relay (on-delay, 5 s) and measures how long its contact takes to close.
const int SUPPLY = 8;   // SSR input: HIGH energises the interface relay, which powers the timer relay
const int CONTACT = 2;  // optocoupler OUT1: LOW while the timer's contact 15-18 is closed

unsigned long startedAt = 0;
bool measured = false;

void setup() {
  Serial.begin(9600);
  pinMode(SUPPLY, OUTPUT);
  pinMode(CONTACT, INPUT);
  delay(500);
  digitalWrite(SUPPLY, HIGH);
  startedAt = millis();
  Serial.println("Timer relay powered");
}

void loop() {
  if (!measured && digitalRead(CONTACT) == LOW) {
    measured = true;
    Serial.print("Contact closed after ");
    Serial.print(millis() - startedAt);
    Serial.println(" ms");
  }
}

Lessons behind it