Skip to main content

Digital I/O Operations

AT1000 device has 32 Inputs/outputs (which may be further extended by daisy-chaining multiple devices). Any of those I/Os can be configured as Analog or Digital, independently from the other I/Os. This chapter focuses on the digital mode of operation.

Configuring Digital I/O​

The following code snipped shows how to declare I/Os as digital, and use them as inputs or outputs.

import AT1000 from '@ikalogic/at1000';
let devices = await AT1000.findDevices(500);
const tester = devices[0];
const test_pin5 = tester.gpio.digital(5);
const test_pin6 = tester.gpio.digital(6);

test_pin5.configure_input({vil: 0.8, vih: 1.5});
test_pin6.configure_output({voh: 5.0, vol: 0.0 value: false});

Let's break the code into detailed steps:

tester.gpio.digital(5) initializes GPIO 5 on the AT1000 device as a digital I/O pin.

The function digital(gpio_number) allows selecting a specific GPIO pin on a specific device: 5 refers to GPIO 5.

Then, the function config_input({vil: 0.8, vih: 3.3}) configures a digital I/O as an input by giving two thresholds :

  • VIH (Voltage Input High) = 3.3V (any voltage above this is read as HIGH).
  • VIL (Voltage Input Low) = 0.8V (any voltage below this is read as LOW).

This setup ensures the AT1000 correctly interprets the input signals based on expected voltage levels.

digital_io(6) initializes GPIO 6 on the AT1000 device as a digital I/O pin.

The function config_output(5.1, 0, false) This configures GPIO 6 as an output. The parameters define the output voltage characteristics:

  • VOH (Voltage Output High) = 5.1V (when the output is set to HIGH, it will output 5.1V).
  • VOL (Voltage Output Low) = 0V (when the output is set to LOW, it will output 0V).
  • Value (Default state) = false (LOW) (when the AT1000 program starts, this pin will be LOW by default). This ensures that GPIO 6 is properly set as a digital output pin with controlled voltage levels.
Tip

The last parameter of config_output(5.1, 0, false) (false) is a logic level.

Reading digital inputs​

To read the digital value of an input that was properly configured simply use the function read() which will return 0 or 1 depending on the logic level that is calculated according to the VIH and VIL thresholds.

let test_pin5 = tester.gpio.digital(5); // GPIO 5
test_pin5.config_input({vil: 0.8, vih: 3.3}); // VIH = 3.3V, VIL = 0.8V
let value = test_pin5.read(); // Read the current value of GPIO 5

Writing to Digital Outputs​

To control the output state of a GPIO pin that has been properly configured as an output, use the write(value) function. The function takes a single argument (0 or 1), which determines whether the pin outputs a low voltage (VOL) or a high voltage (VOH) as previously defined during configuration.

let test_pin6 = tester.gpio.digital(6); // GPIO 6
test_pin6.config_output({voh: 5, vol: 0, value: false}); // VOH = 5V, VOL = 0V, Default = false = 0V (LOW)
test_pin6.write(1); // Set GPIO 6 to HIGH (5V)