FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible my FieldPoint's clock is getting extended due to processor load?

I am trying to measure a signal that is around 10 Hz using the cFP-AIO-600.  It is a basic pulse counter .vi that I am uploading into the cFP-2020 that counts all pulses that occur in one second .  The odd thing that I am seeing, is that it is counting more pulses than I expect.  Instead of 10 pulses per second, it is counting 32.  The timestamps of each datapoint "verify" that this occurs in one second.
 
When I add more functionality (by adding a Collector module and a waveform graph), it somehow counts even more pulses for the same frequency signal.  Up to 347 pulses! 
 
How is that possible?  It can only be one of two things:
 
1) The signal actually got faster in between the two measurements (unlikely).
2) Additional .vi code on the cFP causes the clock to get confused, and the 'second' that I am measuring is actually longer than a second by a significant margin.
 
I have verified this several times, running the second scenario right after the first scenario.  The run time of these .vi's take longer than a second (and the .vi with the Collector does seem to take about 10x as long) but this evidence is not as supportive to my theory due to the time introduced by my computer and the cFP communicating with each other and updating graphics.
 
I have attached these two examples.  You will not be able to run them yourself (because of the data access form the cFP-AIO unit) but I have made the results that I got the default values.  You should be able to see both my code and the results I got illustrated above when you open the .vi's.  pulse_problem_1 shows the first scenario, and pulse_problem_2 shows the second, which is the same thing as pulse_problem_1 with only the Collector and waveform display added.
 
What can I do to resolve this?  It's only a 10 Hz wave, and I know cFP can count even faster signals, so something in my .vi must be wrong.  Any help or advice you can give me would be appreciated.
 
Thanks.
Download All
0 Kudos
Message 1 of 9
(4,605 Views)
Hi,
 
Why are using the Timed-Loop?  You seem to be, or are trying to run the loop every millisecond. 
 
Do you see the same behavour if you replace the Timed-loop with the regular While Loop?
 
-Khalid
0 Kudos
Message 2 of 9
(4,584 Views)

Dear Synap,

If you read in your data to a chart in LabVIEW, do you see the correct pulses?

What input range are you setting? Since you are reading in pulses in the mV range, set the range on th cFP-AIO-600 to 0-5V or +/- 5V, depending on your application. I would check the accuracy in the specs to make sure it is accurate enough.

Have a great weekend!

Sincerely,

Marni S.

0 Kudos
Message 3 of 9
(4,578 Views)
"Do you see the same behavour if you replace the Timed-loop with the regular While Loop?"
 
Yes, I do.  Incidentley, when is the proper time to use a timed loop versus a while loop?  In a NI Training class I went to, they urged us to use timed loops on cFP units, and I must admit, I don't remember why.
 

"If you read in your data to a chart in LabVIEW, do you see the correct pulses?"

I'm not sure if you mean I should use a chart instead of a graph.  If so, it would display in real time and I would not be able to see the pulses, would I?  Or did you have something else in mind?

"What input range are you setting? Since you are reading in pulses in the mV range, set the range on th cFP-AIO-600 to 0-5V or +/- 5V, depending on your application. I would check the accuracy in the specs to make sure it is accurate enough. "

In this case, I am acually reading current pulses in the millivolt range (attenuation on the line makes the voltage readings not as uniform as the current).  I will attach a picture of the difference between the voltage waveform and the current waveform.  I have set the Compact FieldPoint to be within the proper threshold: 0 to 0.024 amps.

Regardless of which one I look at, it is still counting pulses much quicker than the actual signals that I am expecting.  I'm going to try to hook up a signal generator and see if I get the same response.

Thank you for your input!

0 Kudos
Message 4 of 9
(4,556 Views)

Dear Synap,

What happened when you tried the function generator? Did you get better results? Do the waveforms look more like pulses? Have a great day!

Sincerely,

Marni S.

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

Okay, I have proof that my FieldPoint is lying to me when I ask it to do 1000 iterations of 1 wait-until-next-ms loops.

I started with the very useful example in the RT package called "NI Timestamp Code Timer" which, I can only assume, calculates the known timestamp discrepancy caused by processor load.  My attached picture (talyor_loop_vs_time_discrepancy2.JPG) shows that right before the cFP-AIO-600 module records a positive voltage, the normally 1 ms loop can take as long as 60 ms.  That's fine, but the FieldPoint then reports that only 1 ms has occurred!  As you can imagine, this has made pulse counting very difficult, for instead of measuring 10 pulses per second, it 'thinks' it is counting ~28-30 per second as each pulse causes a measurement delay that the FieldPoint treats as a regular 1 ms time interval.

I have also attached the Loop Test code, and a picture of the signal through an ocilliscope, proving it is a regular square wave.

Why does this occur with positive voltages only?  Why doesn't it take the same amount of time to read voltages equal to zero?  If the delay was constant on every read, I could compensate for it, but I can't compensate for this delay that only occurs on positive pulses! 

Please help!

0 Kudos
Message 6 of 9
(4,494 Views)

Dear Synap,

I recommend using a Deadband filter set at 80%. Your square wave might have a little noise on it and as it passes 8V, you can get additional pulses. Have your considered using a counter module instead of an analog input module? The counter modules have the filter built into it in addition to other features as well. Have a great day!

Sincerely,

Marni S.

0 Kudos
Message 7 of 9
(4,433 Views)

Hello,

Did you come up with anything to solve this issue?  I am reading around 6Hz on one channel coming into my cFPAI-610 module and am having similar problems  In general, they way I have my while loop counter configured I noticed that the cFP counter slowly looses drift from the actual # of counts that are being inputed into the module.  In general I am have trouble with my counter keeping up with the input.  I can make it do what you were talking about, where it counts more pulse than are actually occuring and believe that I have resolved this issue.  I will attempt an 80Hz deadband filter, but if you have any ideas to get this working without purchasing some other hardware it is appreciated. 

 

 

 

 

 

0 Kudos
Message 8 of 9
(3,988 Views)
I think your clock problem is you are using the OS clock.  The OS clock runs at a lower priority then timed loops
and time-critical threads, so the OS counter (it's not an RTC call) drifts.  Your best bet is to use the left data
node in the time loop for the expected/actual start/ends for i and i-1 to calculate your actual timing information.

I also see you are not using the timestamp output of the FP-read.vi..have you tried using that?

-Jason
0 Kudos
Message 9 of 9
(3,927 Views)