One of our most frequently asked questions is about the expansion port on the Otii Arc, specifically about the GPIO pins and how they can be used. We thought we’d give you a simple example of their use!
A typical use case would be to control the start and stop of the power consumption recordings by a trigger from a device under test (DUT).
For that case, connect the DUT´s GPIO output to GPI1 and ground it to DGND, in the expansion port of the Otii Arc as shown in Fig. 1. Connect the USB cable from the PC to the Otii Arc, and power cables from it to the DUT.
The query of the GPI status can be done from a Lua script. Down below you can find the Lua script that demonstrates this. To run the script you should first make sure that your Premium license is reserved. Then open gpi_example.lua in the scripting window on the Otii software and press run to start it.
When started, the Lua script configures the Otii Arc and prints a short header. Main voltage, maximal current, enabled channels and other important settings are specified in the params section of the script. It’s always a good idea to check these before starting.
A new project is created in the Otii document folder each time the script runs. After printing the header, the script powers on the DUT and enters a loop to wait for GPI1 to go high. When the GPI pulse is detected, the recording is started and the script enters another loop to wait for the second pulse to stop the recording. This is what the main part of the script looks like:
arc:enable_exp_port(true) project:enable_main_power(true) otii.writeln("Waiting for GPI...") while not arc:get_gpi(1) do end project:start() otii.writeln("Recording...") otii.msleep(gpi_pulse_ms) while not arc:get_gpi(1) do end otii.msleep(gpi_pulse_ms) project:enable_main_power(false) otii.msleep(offdelay_ms) project:stop() otii.writeln("Recording stopped.") arc:enable_exp_port(false)
Consult the technical specification and make sure that you supply enough voltage and keep the DUT GPO high and long enough for the GPI pulse to be detected. The GPI is sampled at 1 ksps.
Now, to make it more interesting, let’s say that we want to control an external device – a buzzer, that will warn us when the measurement has started and when it is done. A Lua script is provided below, and demonstrates how to configure the output voltage for GPO and enable toggle of the GPO pin for the control of the buzzer.
Connect the buzzer to GPO2 and ground it at DGND, as in Fig. 2.
Open the gpo_example.lua into the scripting window and click run.
The script runs in a similar manner as in the previous example, but the main part is different. After printing the header, a short pulse is generated on GPO2 which makes the buzzer beep. The recording is started and the main power is enabled. After waiting for a short time, the script turns the main power off, stops recording and beeps again. The main loop looks like this:
arc:enable_exp_port(true) otii.writeln("Will run for " .. tostring(duration) .. " msec") arc:set_gpo(2, true) otii.msleep(beepdelay) arc:set_gpo(2, false) project:start() otii.msleep(onoffdelay) project:enable_main_power(true) otii.msleep(duration) project:enable_main_power(false) otii.msleep(onoffdelay) project:stop() arc:set_gpo(2, true) otii.msleep(beepdelay) arc:set_gpo(2, false) arc:enable_exp_port(false)
Consult the technical specification and make sure not to overload GPO outputs. Use a relay or low power semiconductor switch if your external device consumes too much power.
The scripts provided here can be used as a base to be modified for your own use, and there is more information to be found in the help section of the Otii software, and in discussions on our forum.
The Qoitech Team
Watch our newest Q&A on what can be done with the GPI pins in the expansion connector of the Otii Arc: