winIDEA SDK
fnet_ain.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5"""
6This example shows basic FNet AIN controller initialization and usage.
7"""
8
9import isystem.connect as ic
10
11winidea_id = ''
12
13
14try:
15 # connect to last winIDEA
16 connMgr = ic.ConnectionMgr()
17 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
18
19 # initialize FNet AIN Controller
20 SessionCtrl = ic.CSessionCtrl(connMgr)
21 FNetCtrl = ic.CFNetCtrl(connMgr)
22 AINCtrl = FNetCtrl.AIN('ADIO.AIN1')
23
24
25
26 optAINCfg = AINCtrl.cfg()
27 optAINCfg.reset()
28
29 nMyChannel = 0
30 # configure channel in one call
31 optAINCfg.set_channel(nChannel = nMyChannel, strName = 'MyAINChannel', bShow = True, dMultiply = 2.0)
32
33 # set averager, if the given value is not directly available, winIDEA will use the next bigger one
34 # if value==0, averager is disabled
35 optAINCfg.set_averager(8)
36
37 # don't use power measurement
38 optAINCfg.power_measurement_disable()
39 if False: # here's how to set it, 1 Ohm shunt
40 optAINCfg.power_measurement_enable(1.0)
41
42
43
44 # SessionCtrl.end() #end first for cfg to take effect
45 SessionCtrl.begin_prepare()
46
47
48
49 # use FNetTrigger 5 in the example
50 FTrigQ = 5
51 FTrigGen = 6
52
53 optAINOp = AINCtrl.op()
54 # qualifier - starts on FTrig, not enabled from start
55 AINCtrl.op_qualifier_enable(FTrigQ)
56 AINCtrl.op_qualifier_enable_on_start(False)
57
58 # qualifier - sampling interval every 10us
59 optAINOp.set_sampling_interval(0.00001)
60
61 # configure channel
62 optChannel = optAINOp.opt_channel(nMyChannel)
63 optChannel.set_record(True)
64 optChannel.set_comparator(nComparator = 0, nFTrig = FTrigGen, bHigherThan = False, dVoltage = 3.0)
65
66 # apply new operation settings and restart operation
67 FNetCtrl.op_apply()
68
69
71 voltage = AINCtrl.ctrl_get_channel(nMyChannel)
72except Exception as ex:
73 print(ex)