LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read input values in real time

I am new to labview. I am using Lab view 2015.

I need to compare values (check whether equal to) I am getting from a detector, with a constant in real time. Each time my input matches with the constant I have to increment a counter variable by one.

I should be able to read the value of counter variable and use it for further calculation when my VI is still running.

 

For trial purpose, I simulated a sine wave and used convert from dynamic data to convert the values to an array and then plotted it with waveform chart. But how can I read what is the current value my array is getting from the simulated input so that I can compare it with the constant and proceed as discussed above. I can write the signal value to a file, but that is post processing. I want to be able the to check the input (whether from detector or simulated one) in real time and then do what I said.

 

Please help me out!

 

This is my first question of a huge anticipated sequence of queries I will keep on posting.

Thanks.

0 Kudos
Message 1 of 15
(5,429 Views)

Can you show us what you have so far? Doing an equal comparison on floating point values is dangerous. What is the native resolution of your actual signal?

 

Typically you waoud keep the count in a shift register initialized with zero.

 

If you you get many values at once, you can usin an inner loop over them for the comparison and increment the couter for each match or you can do the comparison on the array and sum the output of boolean "array to 0,1" and then add it to the corrent sum.

Message 2 of 15
(5,409 Views)

First of all: Welcome to the forum.

Next time, i recommend you to post your VI right away as it shows what you already tried to perform.

 

My assumption (so please post the VI that this is no assumption anymore!) is that you get an array of values in your simulation. That means that you cannot compare it with a scalar value as you intend/expect to do.

You can use the comparison functions on array/scalar combinations which will result in an array of booleans which represent the result of each array value compared to the scalar.

That being said you can use array analysis functions (e.g. Search 1D Array) to identify values matching your comparison.

 

However one final note: NEVER COMPARE FLOATING POINT NUMBERS WITH "EQUAL"!

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 3 of 15
(5,407 Views)

Thanks to altenbach and Norbert_B for their suggestions and advice for future programs.

 

I am attaching a screenshot of the block diagram and my VI. Now I am giving my signal to the Trigger Level Detection VI. If My Signal crosses the set value of 0.7 on the rising edge I want to increase the counter value by 1. For this I am using the location terminal of the Trigger VI as the number of trigerred location will give how many times my sinal crossed 0.7 on rising edge. I am using feedback node to transfer values between iterations.

Please comment .

I think the counting is slow. I set the frequency to 20.2 Hz. I donot understand what that .2 means in frequency parameter. But In 10 seconds it should give me 200 counts but it gives only about 100.

 

Thanks.

Download All
0 Kudos
Message 4 of 15
(5,357 Views)

You configured the simulate signal to generate two periods in a single package. That means that each waveform you pass to Basic Level Trigger Detection.vi contains two rising edges. The Basic Level Trigger Detection.vi only returns the first edge it detects, so this cuts your counted edged by half.

 

Please note that you should not build an array for counting the edges. Simply take a single numeric value and increment it in case you find an edge.

 

Norbert

 

PS: What is it you don't understand with 20.2 Hz. A frequency is not an integer, so you can have a .x part in the Hz statement.....

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 5 of 15
(5,335 Views)

I donot know how to do that. Can I do like this : add 2 in place of 1 to get correct count.

 

Now for frequency,  If I change the frequency from 20.2 to 20.4 then the cycles become twice closer in waveform chart display.  So I doubted it has some special meaning.

Also 20.2, 40.2, 80.2 all look alike. they should have doubling number of cycles as we go from 20.2 to 80.2 in the waveform chart display.

 

Thanks.

0 Kudos
Message 6 of 15
(5,324 Views)

Somehow i got the feeling that you missing some very basic information in digital signal processing and sampling.

 

Please note that in the ExpressVI Simulate Signal, you can configure (using sampling rate and number of samples) how many periods in the signal is. The vi you attached some posts ago is configured to generate a signal which is 100ms in time. So depending on the signal frequency, you will get 1, 2, 4 or 8 periods (when you double the signal frequency that is) periods in the package.

Multiplying your counter with some *arbitrary* value is not good.

 

Regarding the number of cycles in the graph, you might want to check the timebase of the graph to see if it is changing.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 15
(5,317 Views)

Sorry if I made a silly mistake. I think to pass one perod in a signal the ratio of samples per second to number of samples should be greater than or equal to the frequency of signal. Anyway your advice is helping me to learn.

Thanks.

I am trying to modify my VI and will post a new version of it soon.

0 Kudos
Message 8 of 15
(5,278 Views)

I am in serious trouble now. I thought that the count would be fine if signal frequency equals or exceeds the ratio of  sampling rate to the number of samples  (equals is better). This works fine at low frequency (till 1000 Hz) but at 10^5 Hz, it fails with a large error.

In actual experiment, I will be getiing signal at 10^6 Hz  or Higher. Then my VI will make huge mistakes which I cannot afford. I can atmost afford one count mistake in 10^8 counts with signal frequency 10^6 Hz.

 

At 10^3 Hz my VI is making mistakes of  2 or 3 counts when I let it run for 10 seconds. Is it because of my computer limitations or VI demerits?

 

Can anyone help please!

 

Thanks.

0 Kudos
Message 9 of 15
(5,250 Views)

Then you need to be able to process more peaks in a single acquisition simply because Windows will not be able to keep up at the rates you want.  Just use the Waveform Peak Detection.vi since it actually returns the number of peaks found in that acquisition.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 15
(5,234 Views)