05-21-2014 03:54 AM
Hello Everyone,
I am new to DIAdem and I am exploring a method to repeat a standard sequence of operations for 85-90 channel groups. The task goes like this:
Every channel group has a set of three channels, in which some 7 - 8 mathematical operations are to be performed like sum of two channels, average, finding the root mean square value and adding/subtracting the results to the actual channels, finding the arc tan value of the results etc.,
I need to replicate the same task for 85 - 90 channel groups. I tried using the "Enable Recording Mode" in the Script Window and tried to use the script that it generates and use it in a for loop. But since the recording mode, holds the actual name of the channel instead of a reference, it is difficult to edit the names of the channels individually which makes it more cumbersome than the actual work. Hence I need an alternative way of doing the same.
Any help will be much appreciated.
Solved! Go to Solution.
05-21-2014 07:40 AM
Hi Subramanian,
Most of those operations can be accomplished with ANALYSIS functions. I'd recommend you loop over the Groups and in each Group assign object variables for each channel you want to manipulate. Then you can use those object variables in the parameters of the ANALYSIS functions, like this:
iMax = Data.Root.ChannelGroups.Count FOR i = 1 to iMax Set Group = Data.Root.ChannelGroups(i) Set Y1Channel = Group.Channels("AmpHr Charging") Set Y2Channel = Group.Channels("AmpHr Discharging") Set SumChannel = Group.Channels.Add("Sum", DataTypeFloat64) Call ChnAdd(Y1Channel, Y2Channel, SumChannel) NEXT ' i
If you find you need to run the Calculator, we can do something similar.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-21-2014 10:51 PM
Hi Brad,
Thanks for your reply. This seems to be working for simple addition. I want to perform the complex mathematical operations like finding the angle 'Theta = ArcTan(B/A) ' , and complex calculations like Sqrt( A^2+B^2) , cube root of channels etc., keeping in mind that each channel contains 5,000,000 samples.
I want to repeat the same set of operation for 85 - 90 channel groups.
Thanks in advance.
05-22-2014 12:03 PM
Hi Subramanian,
You just asked for the additional Calculator code, here it is:
iMax = Data.Root.ChannelGroups.Count FOR i = 1 to iMax Set Group = Data.Root.ChannelGroups(i) Set AChannel = Group.Channels("AmpHr Charging") Set BChannel = Group.Channels("AmpHr Discharging") Set RChannel = Group.Channels.Add("Result", DataTypeFloat64) Symbols = Array(A, B, R) Channels = Array(AChannel, BChannel, RChannel) Call Calculate("R = ArcTan(B/A)", Symbols, Channels) NEXT ' i
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-27-2014 06:03 AM
Thanks a lot ! That helps . .