winIDEA SDK
Loading...
Searching...
No Matches
fnet_mdio.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 mDIO controller initialization and usage.
(c) iSYSTEM Labs, 2023
"""
import isystem.connect as ic
# connect to last winIDEA
winidea_id = ''
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
sessionCtrl = ic.CSessionCtrl(connMgr)
# initialize FNet DIO Controller
FNetCtrl = ic.CFNetCtrl(connMgr)
mDIOCtrl = FNetCtrl.mDIO('ADIO.DIO1')
# configuration
Cfg = mDIOCtrl.cfg()
Cfg.set_voltage(dVoltage=3.3)
Cfg.set_channel_out(nChannel=0, strName='mych0', bShow=True, bInitialHi=True)
Cfg.set_channel_in (nChannel=1, strName='mych1', bShow=True)
print(f"channel 0 name is: {Cfg.get_channel_name(nChannel=0)}")
# apply configuration
sessionCtrl.begin_prepare()
# operation
mDIOCtrl.op_set_qualifier(bEnableFromStart = False, nFTrigEnable=2, nFTrigDisable=3)
Op = mDIOCtrl.op()
Op.set_record(ic.ERecord_ALL)
# comparator index 1
OpCh = Op.opt_comparator(nChannel = 0)
# set mDIO pin states
OpCh.set_FTrig(nFTrig=5)
OpCh.set_channel_state(nChannel = 0, bHi = False)
OpCh.set_channel_ignore(nChannel = 1)
# test action on mDIO pins on trigger event
Op.set_action(nAction = 0, nFTrig = 5, nChannel = 0, bHi = False)
# pattern config
OpPat = Op.opt_pattern(nPattern = 0)
OpPat.set_channels(vChannels = {0,2,1})
OpPat.set_action(nFTrigStart = 1, bStartActive = False, nFTrigStop = 2, bStopImmediately = True)
OpPat.set_continuous(bContinuous = False)
OpPat.set_pattern('001,140; xx0,10; 1xx,50ms; 111,100us')
# apply modified Op settings - takes effect at this call
FNetCtrl.applyOperation()
# control
mDIOCtrl.ctrl_set_channel(nChannel = 0, bHi = True)
bHi = mDIOCtrl.ctrl_get_channel(nChannel = 0)
# Pattern control
mDIOCtrl.ctrl_start_pattern(nPattern = 0)
mDIOCtrl.ctrl_stop_pattern(nPattern = 0)