From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

numeric channel turned in novalue??

I have a numeric channel A, channel data is from a collection of other channel values. I used chd() to write these values into channel A.

 

It seemed work fine if I run under debug mode, step by step. However, if I run under regular mode, the channel turned into NUVALUE. Which means channel A data are all NOVALUE.

 

Don't know what happened, Please help, thank you.

 

0 Kudos
Message 1 of 9
(5,371 Views)

Hello IIX,

 

Please can you provide the script and data set so that I can check it?

Which DIAdem version do you use?

 

Greetings

Walter

0 Kudos
Message 2 of 9
(5,352 Views)

script is like this.

example data file is attached.

The logic is very simple, to loop through a group of channels. Get maximum value of each channel write into a new channel A. Then do histogram analysis on this new channel A, report histogram.

 

However, the new channel values are always NOVALUE. If under debug mode, each value is written into the channel A is read.

 

Please help, thank you.

 

 

groupnamestr = "3D Values"

gindex = GroupIndexGet(groupnamestr)

chncount = groupchncount(gindex)

Call Data.Root.ChannelGroups.Add("result", 8).Activate()

Call Data.Root.ChannelGroups(8).Channels.Add("results",DataTypeFloat64,1)

chnlength ("/results") = chncount

Call GroupDefaultSet(gindex)

for iloop = 1 to chncount

a = chnpropvalget(iloop,"Maximum")

 chd(iloop,"result/results") = a

next

 

0 Kudos
Message 3 of 9
(5,331 Views)

By the way,  I have tried DIAdem 2012/2014/2015, same problem.

0 Kudos
Message 4 of 9
(5,329 Views)

Hello IIX,

 

You're mixing the old syntax for data accessing with the new data API. This is in general possible but not very clear and straight forward. Defining it correct by mixing the syntax is more difficult. Here is an example:

 

With the following code you refer to a certain channelgroup:

groupnamestr = "3D Values"
gindex = GroupIndexGet(groupnamestr)

 

In the for loop you read the channel max values of channel 1 up to channel "chncount". But this is just the flat channel number (which you can see in the Dataportal list page) and not the channel index of a certain channel group. So if the "3D Values" channel group is not the first group you read the wrong values.

for iloop = 1 to chncount
  a = chnpropvalget(iloop,"Maximum")
  chd(iloop,"result/results") = a
next

 

A second point:

You add a new channel group with at position 8. If you don't have already at least 7 groups you get an error.

Call Data.Root.ChannelGroups.Add("result",8).Activate()

 

In my tests just the min/max values of the result channel are NV. This can be recalculated with ChnCharacter.

 

I would prefer only using the new data API in new scripts.

Here is an example of how you can define your example in DIAdem 2015:

 

dim iLoop, oSourceGroupChns, oTargetGroup, oTargetChn

set oSourceGroupChns = Data.Root.ChannelGroups("3D Values").Channels
set oTargetGroup     = Data.Root.ChannelGroups.Add("Results")
set oTargetChn       = oTargetGroup.Channels.Add("MaxResults", DataTypeChnFloat64)

call oTargetGroup.Activate

for iLoop = 1 to oSourceGroupChns.Count
  oTargetChn(iLoop) = oSourceGroupChns(iLoop).Maximum
next

call ChnCharacter(oTargetChn)

Greetings

 

Walter

 

By the way, in your attachment I miss the TDX file.

 

0 Kudos
Message 5 of 9
(5,316 Views)

Walter , thank you for your reply.

 

oTargetChn(iLoop) = oSourceGroupChns(iLoop).Maximum

works for DIAdem 2015 only. Any way to make the code works for older version of DIAdem?

 

0 Kudos
Message 6 of 9
(5,279 Views)

For older DIAdem versions you can use:

 

  oTargetChn(iLoop) = oSourceGroupChns(iLoop).Properties("maximum").Value

 

Greetings

Walter

0 Kudos
Message 7 of 9
(5,267 Views)

Hi Walter,thank you for the help.

 

I am using the method you provided. For some data files it worked, some of still not working (works under debug mode, however, it didn't work under regular run mode).

 

I noticed if I finish wrting the channel value and drag the channel to view tab. Channel values changed from NOVALUE to correct values. It is like refresh channel values.

Not sure if it is related to computer memory usage? Since for my work, I did lots of channels sort, channels deplication remove before this step.

 

Thank you.

 

 

 

0 Kudos
Message 8 of 9
(5,221 Views)

Hi IIx,

 

In my example script I used the command

 

call ChnCharacter(oTargetChn)

to calculate the channel characteristics. Depending on your script this can be necessary. Do you use also this command?

 

Greetings

Walter

Message 9 of 9
(5,164 Views)