Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

why does period display NaN? what does "NaN" mean?

Solved!
Go to solution

I have a vi that is supposed to measure 3 period values and 2 voltages using DAQmx.  The vi is attached. 

 

When I run the vi, I get no errors, but, one of the counters is displaying NaN instead of a period value (in seconds).  Why would this counter not show up?  See the .jpg image of the screen capture, which shows the front panel indicators, after running and stopping the vi.  Notice that period 2 shows "NaN" but, period 1 and 3 display a real value.  The "NaN" displays only in "Period 2" during the execution too. "Period 2" never displays a numeric value.  By the way, what does "NaN" actually mean?

 

Appreciate your thoughts.

 

Thanks,

Dave

 

(using 3 counters in the cDAQ 9174 and NI 9401 module plugged into the cDAQ chassis; periods are measured from encoders)

Download All
0 Kudos
Message 1 of 4
(14,017 Views)
Solution
Accepted by topic author dav2010

NaN means "Not A Number".

In your code, Mean.vi will return NaN (with the error -20003) if the input array is empty.

 

What happens if you connect the signal of counter 1 or 3 to counter 2 ? If NaN disappears, then there is a problem with the signal currently connected to the counter 2.

 

 

  1. Your current code, using USRs (unitialized shift registers), will produce NaN when running the first time.
  2. The size of the USRs will increment on each iteration.
  3. If your VI is used as a sub-VI, the means will be wrong for the first 15 iterations because they will be computed with the values in the USRs --> from previous measurement(s).

 

You should use Mean PtByPt.vi which will compute the average of the last X values without above mentioned problems.

Message 2 of 4
(14,007 Views)

Hi,

 

Thanks for the information.  Actually, for testing purposes, I have a single encoder wired in parallel to the three inputs on the 9401, so, the same signal is going to all three counters, which is what makes this even more confusing.  I did this to eliminate any issues with the signal: if there is any problem with the encoder signal, it would show up on all 3 channels. Would faulty wiring to the Period 2 channel result in the NaN?  I can check our wiring to make sure that nothing came loose etc.  Would that give a "NaN" display?

 

Regarding the USR's, yes, your statement is consistent with what I observe.  Initially, I see the NaN display in Period 1 and Period 3, but it quickly becomes a real number, however, the NaN in Period 2 persists permanently, e.g. several minutes of operation.  I am aware of the situation you are raising with your point #3, but, I am just trying to get the hardware working right first, and then, I'll edit the vi to accommodate these other issues, but, thanks for reminding me about that.

 

The function meanptbypt.vi is available in the Full Development System, but, I am using the Base Development System,and do not have access to it.

 

Thanks,

Dave

0 Kudos
Message 3 of 4
(13,996 Views)

Ah, I found it.  I checked and found a faulty wire going to that "Period 2" channel.  Replaced the wire, and now all three periods are correctly displaying.  Thanks for explaining "NaN" to me!

Dave

0 Kudos
Message 4 of 4
(13,986 Views)