07-18-2007 02:24 AM
'-------------------------------------------------------------------------------
'-- VBS script file
'-- Created on 18.07.2007 08:32:37
'-- Author: National Instruments, Ingo Schumacher
'-- Comment: mathematic channel filter:
'-- remaining values : cDat < 1000 on rising slope while cTrig = 1
'-------------------------------------------------------------------------------
Option Explicit 'Forces the explicit declaration of all the variables in a script.
dim cTr : cTr = 2 ' trigger channel
dim cDat : cDat = 3 ' data channel
dim cRes : cRes = cNo(chnalloc(cn(cDat)&"_filtered",cl(cDat))(0)) ' result channel
dim trStart, trStop, SigStart, SigStop
dim trig, i
'initialise result channel
for i = 1 to cl(cDat)
chdx(i,cRes) = NoValue
next
cl(cRes) = cl(cDat)
TrStart = 1
SigStart = 1
do
' find area wher cTrig = 1
TrStart = chnfind("ch("&cTr&")>0",TrStart)
if TrStart > 0 then 'Starttrigger found?
TrStop = chnfind("ch("&cTr&")<=0",TrStart) : if TrStop = 0 then TrStop = cl(cTr)
trig = chnfind("ch("&cDat&")<0.01",SigStart) 'Find Signal Start (Signal is almost 0)
if trig < TrStop then ' test if there is a valid signal in cDat
SigStart = trig
SigStop = chnfind("ch("&cDat&")>1000",SigStart) : if SigStop = 0 then SigStop = cl(cDat)
datablcopy cDat, TrStart, SigStop-TrStart, cRes, TrStart
SigStart = SigStop ' Prepare for next search
end if
TrStart = TrStop ' Prepare for next search
end if
loop while TrStart > 0 and TrStop < cl(cTr)