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: 

ChnFind- another subchannel

Hello all,

 

I have a channel like follow

Content     Time           Value

1               0.1            15

2               0.2            20

3               0.3            30

4               0.4            40

 

I used formula t1= chnfind("Ch(""I"")>20") and return me value "3" from Content area. How can I use chnfind function, or another function to return Time value ? In this example to return me "0.3"?

 

Thank you!

 

PS. I`m using DIadem 2021

0 Kudos
Message 1 of 4
(679 Views)

Hi Alex_SI,

 

ChnFind returns the row where the condition is true for the first time. This can be used to get channel content of other channels. Here is a more formalized example for this request.

dim oSourceChn, oSearchChn, iIndex

set oSourceChn = Data.GetChannel("[1]/Speed")
set oSearchChn = Data.GetChannel("[1]/Time")

dim sFormula, aSymbol(2), aValues(2)
sFormula = "A >= B"
aSymbol(1) = "A"
aSymbol(2) = "B"
Set aValues(1) = oSourceChn
aValues(2) = 30

iIndex = ChnFind(sFormula, 1, aSymbol, aValues)
if iIndex > 0 then
  msgbox oSearchChn(iIndex)
end if

Greetings

Walter

0 Kudos
Message 2 of 4
(663 Views)

Thank you, if I will formula "divede by 10" (10 is samplerate) to get Time Value it will be OK? What do you think?

0 Kudos
Message 3 of 4
(653 Views)

I am not sure what exactly mean, but you can of course extend the formula:

dim sFormula, aSymbol(3), aValues(3)
sFormula = "A >= B / C"
aSymbol(1) = "A"
aSymbol(2) = "B"
aSymbol(3) = "C"
Set aValues(1) = oSourceChn
aValues(2) = 30
aValues(3) = 10

 Greetings

Walter

0 Kudos
Message 4 of 4
(644 Views)