DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Specifying the channel name of function output

I want to be able to change the channel name of the output of a function, such as ChnFFT1()

 

From my script:

FFTIndexChn      = 0
FFTIntervUser    = "NumberStartOverl"
FFTIntervPara(1) = 1
FFTIntervPara(2) = 96000
FFTIntervPara(3) = 1
FFTIntervOverl   = 0
FFTNoV           = 0
FFTWndFct        = "Rectangle"
FFTWndPara       = 10
FFTWndChn        = "[1]/Time"
FFTWndCorrectTyp = "No"
FFTAverageType   = "No"
FFTAmplFirst     = "Amplitude"
FFTAmpl          = 1
FFTAmplType      = "Ampl.Peak"
FFTCalc          = 0
FFTAmplExt       = "No"
FFTPhase         = 0
FFTCepstrum      = 0
Call ChnFFT1("[1]/Time","[1]/AI2")

What do I have to add to be able to control the output channel name?

Thanks!

0 Kudos
Message 1 of 4
(3,291 Views)

Hi nhallberg,

 

The ChnFFT1() command is one that does not have explicit output channel parameters in the function prototype.  In that case your only option is to use the Group.Activate command to set the desired group to receive the FFT channel(s), then count the number of channels in that group before the ChnFFT1() command and find the resulting channel(s) by index after the command.  Once found, you can change the channel name or anything else about the output channels.

 

'Set RawGroup = Data.Root.ChannelGroups("Example")
'Set FFTGroup = Data.Root.ChannelGroups("Noise data")
'Set XChannel = RawGroup.Channels(1)
'Set YChannel = RawGroup.Channels(2)
Set RawGroup = Data.Root.ChannelGroups("Noise data")
Set FFTGroup = Data.Root.ChannelGroups("Noise data")
Set XChannel = ""
Set YChannel = RawGroup.Channels("Noise_1")
Call FFTGroup.Activate
j = FFTGroup.Channels.Count
Call ChnFFT1(XChannel, YChannel)
IF NOT IsObject(XChannel) THEN
  Set AmpChannel = FFTGroup.Channels(j+1)
ELSE
  Set FrqChannel = FFTGroup.Channels(j+1)
  Set AmpChannel = FFTGroup.Channels(j+2)
END IF
AmpChannel.Name = YChannel.Name & " FFT"

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 4
(3,239 Views)

Hi Brad,

 

Thank you for your answer.

That's very unfortunate... To me that's a basic functionality.

Is there any chance this will be added in a future version or patch of DIAdem? If not, can I change the ChnFFT1() script myself?

 

Best regards,

Niklas

0 Kudos
Message 3 of 4
(3,236 Views)

Hi Niklas,

 

It is possible that a future version of DIAdem will add a return value to the ChnFFT1() command.  There has actually been improvement along these lines in DIAdem 2017, updating functions that returned string channel references to optionally return channel objects instead.

 

I would not recommend trying to implement the FFT calculation in your own VBScript.  It will be difficult to implement correctly and completely, and it will run slowly because VBScript is an interpreted language (not compiled).  Your best bet is to learn how to find the channels the ChnFFT1() command creates, as the VBScript snippet I submitted shows.

 

I did have 1 typo in the above VBScript.  It should have been

    XChannel = ""

not

    Set XChannel = ""

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 4
(3,230 Views)