DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating channel depending on two channel values

Solved!
Go to solution

Hi,

I have got two channels, for the sake of simplicity lets call them x (1 to 10 with increments of 1) and y(20 to 30 with increments of 1) with the same length.

What I would like to do is to go through channel x, look what at each instant corresponding value of channel y is and depending on that multiply channel x with factor and create new channel with this results. 

I was thinking that the easiest way would be to create table in excel, but then I am lost in how to script it in DIAdem to be able to read the table and get the result. 

Any idea would be very helpful. 

 

Message 1 of 11
(3,860 Views)

Hi JanSantora,

 

It sounds like you have two questions.  First, how to import/create the data channels you want in DIAdem, and the second, how to conditionally multiply them to create a third channel in DIAdem.  The example of the two channels you mentioned would be easy to construct by hand in DIAdem VIEW, just like you would create them in Excel.  But I'm guessing you want to perform this on data that you have stored some place.  What file format is that data in that you want to perform this conditional, row-by-row analysis on?

 

Also, what exactly does each row's multiplication "depend on"?  If you can express the logic you have in mind, I can send you the Channel Calculator syntax that performs that analysis with optimal speed.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 11
(3,801 Views)

Hi Brad,

 

Thank you for your reply.

What I have done was wrote a script which will read arrays and than made a formula for interlpolation. But what I would prefer if it can go through Excel file which would have x axis values, y axis values, and z axis values. Similar to lookup table.

Here is the script I have done using arrays.:

 

Dim formula,symbols,binchannels
Dim TemperatureArray,FactorArray,tempFactor
TemperatureArray = Array(95.6,100,106.7,114.9,123.8,138.1)
FactorArray = Array(0.6,0.8,0.9,1,1.1,1.2)
Dim i
formula = ""
For i = 0 to uBound(TemperatureArray)-1
TempFactor = (FactorArray(i+1) - FactorArray(i))/(TemperatureArray(i+1)-TemperatureArray(i))
formula = formula & "iif(X>=" & TemperatureArray(i) & " and X<=" & TemperatureArray(i+1) & ",Z*(X*" & TempFactor & " - " & Tempfactor * TemperatureArray(i) - FactorArray(i) & "),0) + "
next
Formula = "Y=" & left(formula,len(formula)-3)
'formula = "Y=iif(X>=95.6 and X<=100,Z*(X*0.0455-4.15),null)"
'msgbox formula
Symbols = array("X","Y","Z")
Call Data.Root.ChannelGroups("ExcessFuel").Channels.Add("Prod5",DataTypeChnFloat64)
Redim Binchannels(2)
Set BinChannels(0) = Data.Root.ChannelGroups("ExcessFuel").Channels("OilCmbdSen_tSnsr")
Set BinChannels(1) = Data.Root.ChannelGroups("ExcessFuel").Channels("Prod5")
Set BinChannels(2) = Data.Root.ChannelGroups("ExcessFuel").Channels("massoffuelinoil")
Call Calculate(formula,symbols,binchannels)
end If

 

If you would have any idea about the option to read in the values through excel please let me know.

I appriciate your help.

 

Jan

 

0 Kudos
Message 3 of 11
(3,795 Views)

Hi Jan,

 

The best way to read values from an Excel file is to create a DataPlugin for that type of Excel file.  The other option is to read in values using Excel's ActiveX calls in VBScript.

 

Could you send me a sample Excel file that has those parallel arrays (lookup table) arranged the way you would like it to be in Excel?  I can then send you a DataPlugin and the VBScript code to call it.

 

This will address the first issue I mentioned above.  It looks like from your posted VBScript code that you don't need help with the second issue I mentioned above.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 11
(3,790 Views)

Hi Brad,

 

Thank you for your reply, please find attached sample excel file with the 3d table.

 

Jan

0 Kudos
Message 5 of 11
(3,772 Views)
Solution
Accepted by JanSantora

Hi Jan,

 

Here is a DataPlugin that reads the values from the one Excel file you sent me into DataPortal channels in a structure DIAdem calls "Matrix" orientation, which is ready for 3D display or analysis.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 11
(3,761 Views)
Solution
Accepted by JanSantora

Hi Brad,

 

Thanks for your reply.

Unfortunately after loading the excel file with the DataPluging gives me an error. 

Error attached.

 

Many thanks 

Jan

0 Kudos
Message 7 of 11
(3,755 Views)

Hi Brad,

 

I am sorry I loaded something else. It is working now.

 

Once again, many thanks.

 

Jan

0 Kudos
Message 8 of 11
(3,754 Views)

Hi Brad,

 

Now I can load the excel file with the help of your dataplugin.

What I would like to do now is to go through two channels and depending on the values link it to the table and multiply other channel with the value which the look up table will get (depending on the two values from the two channels).

Is that even possible?

 

Many thanks for your help, highly appreciated.

Jan 

0 Kudos
Message 9 of 11
(3,749 Views)

Hi Jan,

 

I'm struggling with your terminology.  You say you would like to "go through 2 channels".  The DataPlugin I sent you loads from the Excel file you sent me 11 different channels.  Which 2 are you referring to here?

 

You also talk about "other" channel.  Can you please refer to the channels by the name that the DataPlugin loads them with into the Data Portal?  I don't know which "other" channel you mean.

 

Finally, you refer to "the value which the look up table will get".  I thought we loaded the channels from the Excel file in order to have the look up table in DIAdem?  If so, which channels in DIAdem are the look up table?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 11
(3,741 Views)