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);

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

You'll notice that when configuring output, we may also define vil and vih. The reason behind that is that a digital output configured pin can still be read back, so the AT1000 device still needs to know how to interpret the signals on that pin. Reading back an output pin can be useful in several situations, like ensuring the output is not in a short circuit situation.

Also note that you may ignore the vil and vih parameters when configuring a digital output, and they'll be automatically deduced from the given voh and vol parameters.

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 test_pin6.config_output({voh: 5.0, vol: 0.0, vil: 0.8, vih: 1.5, value: 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).
  • VIH (Voltage Input High) = 1.5V (for reading back the output state, any voltage above this is considered HIGH).
  • VIL (Voltage Input Low) = 0.8V (for reading back the output state, any voltage below this is considered LOW).
  • 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.

const test_pin5 = tester.gpio.digital(5);
await test_pin5.configure_input({vil: 0.8, vih: 1.5});
let value = await 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.

const test_pin6 = tester.gpio.digital(6); 
await test_pin6.configure_output({voh: 5.0, vol: 0.0, vil: 0.8, vih: 1.5, value: false});
await test_pin6.write(true); // Set GPIO 6 to HIGH (5V)