In a TCP server API call, when we create a new project.
We would like to set as like as the GUI of Otii, the main outputs measurement range at auto.
We call set_range() with the ‘low’ parameter with Pyhon client for Otii TCP-server
With WireShark, the correct message was send to the OTII API server, but it nothing is done.
We use the otii 2.8.4 with an arc module and the last version of python tcp client for Otii TCP-server 1.0.4
Currently, we must create manually the project with the GUI to have auto range, but for a long period measurement ( more than a day ) we need to split the project and we must use the API.
This is strange, when I run the code below, it is clearly visible in the UI that Otii Arc switches from auto range (“low”) to high range (“high”)
#!/usr/bin/env python
import time
import sys, os
sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '..')))
from otii_tcp_client import otii_connection, otii_exception, otii
HOST = {
# IP address of the server
"IP":"127.0.0.1",
# Port number the server is listening on
"PORT":1905
}
# Check if there is already an active project otherwise create a new
def check_create_project(otii_object):
proj = otii_object.get_active_project()
if proj:
print("Project already active")
else:
proj = otii_object.create_project()
print("Project created")
return proj
def setup_arc(my_arc, voltage=3.0, overcurrent=1.0, channels=["mc"]):
my_arc.set_main_voltage(voltage)
my_arc.set_max_current(overcurrent) # Set overcurrent limit
for channel in channels:
my_arc.enable_channel(channel, True) # Enable channels, default main current
def measure(proj, my_arc, duration=1):
my_arc.set_range("low")
my_arc.set_main(True) # close output relay
proj.start_recording() # start a recording
time.sleep(1)
my_arc.set_range("high")
time.sleep(1)
proj.stop_recording()
my_arc.set_main(False) # close output relay
my_arc.set_range("low")
connection = otii_connection.OtiiConnection(HOST["IP"], HOST["PORT"])
connect_response = connection.connect_to_server()
if connect_response["type"] == "error":
print("Exit! Error code: " + connect_response["errorcode"] + ", Description: " + connect_response["data"]["message"])
sys.exit()
try:
otii_object = otii.Otii(connection)
devices = otii_object.get_devices()
if len(devices) == 0:
print("No Arc connected!")
sys.exit()
my_arc = devices[0] # All connected Arc are in the list devices, uses the first
setup_arc(my_arc) # Setup the device to be used
proj = check_create_project(otii_object) # Create the measurement project
measure(proj, my_arc) # Measure and get data
except otii_exception.Otii_Exception as e:
print("Error message: " + e.message)
print("Done!")
When your device under test (DUT) consumes more that 19.5mA, then Otii Arc switches automatically to high range and you need to be below 19mA for 25ms for Otii Arc to switch back to low range.
To be clear, “low” range is actuallt auto range and “high” range is locked to high range.