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

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculations using selected values within channels

Solved!
Go to solution

Is there a way to make simple calculations (addition/subtraction) of selected single values within channels?   Very new DIAdem user, so I'm not familiar with scripts at all.  Seems like it should be an easy command, and I'm just overlooking it.

 

Thank You,

 

Shannon

0 Kudos
Message 1 of 12
(5,715 Views)

Hey Shannon,

 

You can do something like this:

 

     Set oMyChannel1 = Data.Root.ActiveChannelGroup.Channels(1)

     Set oMyChannel2 = Data.Root.ActiveChannelGroup.Channels(2)

     

     oMyAddition = oMyChannel1.Values(1) + oMyChannel2.Values(1)

 

You could also replace the last line with:

 

     oMyAddition = oMyChannel1(1) + oMyChannel2(1)

Britton C.
Senior Software Engineer
National Instruments
0 Kudos
Message 2 of 12
(5,695 Views)
Solution
Accepted by topic author Shorne

Hello Shannon,

 

It sounds to me like you would like to add two or more "cells" (to use Excel lingo) together.

 

DIAdem manages data as channels, not individual cells. So the approach to add two cells in DIAdem works like this:

 

The ChD variable allows you to access a single "cell" in a channel, using the following sequence or parameters:

 

ChD(X,Y)

 

where X is the row number of the channel table, and Y is the channel (column) name or number of the cell you wish to access.

 

So, this expression here calculates the result of adding the 2nd row value of the channel called "Temperature_1" and the channel called "Temperature_2" from the example data set that loads when DIAdem is started. R1 in this case is an internal DIAdem real variable that stores a single value.

 

R1 = ChD(2,Ch("[4]/Temperature_1")) + ChD(2,Ch("[4]/Temperature_2"))

 

The calculation above can be entered in the "Calculator" which is available in DIAdem VIEW and in DIAdem ANALYSIS in the toolbar.

 

VIEW CALC.png

 

I hope this is helpful, please let us know if you have additional questions,

 

     Otmar

Otmar D. Foehner
Message 3 of 12
(5,687 Views)

Thank you Otmar...this is most helpful!!

 

Now, my question is... how do I get my 'R' values onto my reports?  I'm having trouble figuring out how to do that.

 

Thank you!

 

 

0 Kudos
Message 4 of 12
(5,685 Views)

Thank you Britton C!  Your reply was very helpful.  Smiley Happy

 

 

0 Kudos
Message 5 of 12
(5,684 Views)
Solution
Accepted by topic author Shorne

Hello Shannon,

 

There are multiple ways to do that, including putting the results of your calculations into a new channel (for a table for instance), or simply by putting the calculation or the variable reference into a text, see these two attached examples (they are both in the same text window):

 

REPORT CALC.png

As you can see, you can even do the calculation right inside the text, or just reference the variable containing your results.

 

The @@ tells DIAdem that you are referencing a variable (or variables in the first case) and want to see the contents of these variable(s).

 

If you have an example of what your final goal is for a report (i.e. a table of values, a constant line in an axis system at a specific value, etc.) I can create a more specific example, but this is the general way how you can include calculated values and variables inside a report.

 

     Otmar

Otmar D. Foehner
Message 6 of 12
(5,680 Views)

Otmar,

 

This is so helpful!  I know how to do what I need now.  If I have any further questions, I'll be sure to reply!

 

Thank you SO MUCH!

 

Shannon H.

0 Kudos
Message 7 of 12
(5,672 Views)

how would i do this same thing, but within a graph? I want to pick specific values out of channels, and not just graph an entire channel. 

0 Kudos
Message 8 of 12
(3,927 Views)

Hi Derek,

 

I do'nt understand your question, or at least it seems to me that picking values out of channels is exactly what is described in this topic. Can you be more specific please ? Maybe with a screenshot explaining what you want to achieve ?

 

Thanks,

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 9 of 12
(3,923 Views)

the examples above only seem to work when doing calculations, or if you do it in a text box. If you try to use this method within a graph (as seen in attached picture), it doesn't work. 

0 Kudos
Message 10 of 12
(3,920 Views)