From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

Calculate difference between channels

I have some temperature channels from a sample. I need to calculate the ROA (Rise over Ambient) for each of these channels.

So I want to take each channel and subtract the ambient channel from it. I can do it using the basic mathematics under the analysis tab but I have a lot of channels to compile and I am not sure how to automate this. I would like the new channel to have the original name plus ROA added to it.



0 Kudos
Message 1 of 5

The way to automate this is through a script.  You can get an idea of what the script will look like by going to the script tab and clicking Enable Recording Mode, and then doing the subtract and rename then stop the Script Recording.  You can then see an example of what the script will look like and put that code in a For Each Loop that is iterating through each channel you need to change.

National Instruments
Applications Engineer
0 Kudos
Message 2 of 5

Hi chandler,


If you post the data set you're talking about, we should be able to give you starter code to work with.


Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 5

Ok, I've got my script figured out now I am curious if there is a way to get a total group count and then a total channel count that is in the group.

0 Kudos
Message 4 of 5

Hi chandler,


"GroupCount" will tell you the current number of groups.  "GroupChnCount(GroupIndex)" will tell you the number of channels in each group.  "CNoXGet(GroupIndex, ChannelIndex) will return a channel reference to the particular channel in a group that you're looping over.  This approach will work in all DIAdem versions that have Groups, starting with 9.0.


In DIAdem 11.0 we introduced the "Data" variable, which makes all this much more obvious, if not less complicated:


     Set Group = Data.Root.ChannelGroups(GroupIndex)


     Set Channel = Group.Channels(ChannelIndex)


Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 5 of 5