winIDEA SDK
Loading...
Searching...
No Matches
fnet_ain.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
#
# (c) TASKING Germany GmbH, 2023
"""
This example shows basic FNet AIN controller initialization and usage.
"""
import isystem.connect as ic
winidea_id = ''
try:
# connect to last winIDEA
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
# initialize FNet AIN Controller
SessionCtrl = ic.CSessionCtrl(connMgr)
FNetCtrl = ic.CFNetCtrl(connMgr)
AINCtrl = FNetCtrl.AIN('ADIO.AIN1')
optAINCfg = AINCtrl.cfg()
optAINCfg.reset()
nMyChannel = 0
# configure channel in one call
optAINCfg.set_channel(nChannel = nMyChannel, strName = 'MyAINChannel', bShow = True, dMultiply = 2.0)
# set averager, if the given value is not directly available, winIDEA will use the next bigger one
# if value==0, averager is disabled
optAINCfg.set_averager(8)
# don't use power measurement
optAINCfg.power_measurement_disable()
if False: # here's how to set it, 1 Ohm shunt
optAINCfg.power_measurement_enable(1.0)
# SessionCtrl.end() #end first for cfg to take effect
SessionCtrl.begin_prepare()
# use FNetTrigger 5 in the example
FTrigQ = 5
FTrigGen = 6
optAINOp = AINCtrl.op()
# qualifier - starts on FTrig, not enabled from start
AINCtrl.op_qualifier_enable(FTrigQ)
AINCtrl.op_qualifier_enable_on_start(False)
# qualifier - sampling interval every 10us
optAINOp.set_sampling_interval(0.00001)
# configure channel
optChannel = optAINOp.opt_channel(nMyChannel)
optChannel.set_record(True)
optChannel.set_comparator(nComparator = 0, nFTrig = FTrigGen, bHigherThan = False, dVoltage = 3.0)
# apply new operation settings and restart operation
FNetCtrl.op_apply()
voltage = AINCtrl.ctrl_get_channel(nMyChannel)
except Exception as ex:
print(ex)