Skip to main content

Controlling Relays and Dry Contacts

The AT1000 provides 8 dry contact relays per device, which can be controlled individually or all at once. Each relay is addressed by its number (0-7).

Closing and Opening Relays​

the code snippets below demonstrate how to control the relays using the AT1000 API. The tester.relay() function is used to select a relay. The close() and open() methods are used to activate and deactivate the relay, respectively.

import AT1000 from '@ikalogic/at1000';
let testers = await AT1000.findDevices(500); // Find the device with serial number 12345
let tester = testers[0]; // Pick the first detected device
let relay4 = tester.relays.relay(4); // Select relay number 4

await relay4.close(); // Close relay 4 (activate)
await relay4.open(); // Open relay 4 (deactivate)

Reading Relay Status

To check whether a relay is open or closed, use the read() function in a similar manner. This function returns 1 if the relay is closed and 0 if it is open.

let relay_status = await relay4.read(); // Read the status of relay 4
console.log("Relay 4 status:" + relay_status );
Relays / Dry contacts are not synchronized

Please note that relays operation are always sequential, and cannot be synchronized using the hold and release mechanisms described here.

API Reference​

Accessing Relays​

const relays = tester.relays;

Relays Module Methods​

reset()​

Resets all relays to their default state (open).

await tester.relays.reset();

Returns: Promise<void> / Awaitable[None]


relay(id)​

Access a specific relay by ID.

const relay0 = tester.relays.relay(0);

Parameters:

  • id (number / int): Relay identifier (0-7)

Returns: Relay instance


read()​

Reads the state of all relays at once.

const states = await tester.relays.read();
console.log("All relay states:", states);
// ["open", "closed", "open", "open", "open", "open", "open", "open"]

Returns: Promise<States> / Awaitable[States] - Array of states for all relays


open()​

Opens all relays simultaneously.

await tester.relays.open();

Returns: Promise<States> / Awaitable[States] - Array of updated states (all "open")


close()​

Closes all relays simultaneously.

await tester.relays.close();

Returns: Promise<States> / Awaitable[States] - Array of updated states (all "closed")


Relay Class​

Individual relay control.

id (Property)​

The relay identifier (read-only).

console.log("Relay ID:", relay.id);  // 0-7

Type: number / int


read()​

Reads the current state of the relay.

const state = await relay.read();
console.log("Relay is", state); // "open" or "closed"

Returns: Promise<State> / Awaitable[State] - Either "open" or "closed"


is_open()​

Checks if the relay is open.

const open = await relay.is_open();
if (open) {
console.log("Relay is open (circuit disconnected)");
}

Returns: Promise<boolean> / Awaitable[bool] - true if open, false if closed


is_closed()​

Checks if the relay is closed.

const closed = await relay.is_closed();
if (closed) {
console.log("Relay is closed (circuit connected)");
}

Returns: Promise<boolean> / Awaitable[bool] - true if closed, false if open


open()​

Opens the relay (disconnects the circuit).

await relay.open();

Returns: Promise<State> / Awaitable[State] - The new state ("open")


close()​

Closes the relay (connects the circuit).

await relay.close();

Returns: Promise<State> / Awaitable[State] - The new state ("closed")


Types​

State​

"open" | "closed"

States​

Array<"open" | "closed">  // Length: 8 (one per relay)

Notes​

  • Relays are dry contact type (no voltage provided by relay itself)
  • 8 relays total (indexed 0-7)
  • States: "open" = circuit disconnected, "closed" = circuit connected
  • Relay 4 has special current measurement capability (see Power API)
  • Default state after reset: all open
  • Use appropriate delays between operations for mechanical relays