LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak Detector works wrong.

Solved!
Go to solution

Hello,

I am working on a project in which I want to calculate the rate of some signal. I have used the peak detector to detect the peak of the waveform.

The peak detector works accurately but after sometime like 40 seconds it starts counting the noise ( which is less than the value of Amplitude, and which it was previously not counting), I don't know the reason for this.

Can any one pls help me out to solve this problem

Thanks v.much

0 Kudos
Message 1 of 8
(2,757 Views)

In my experience, the peak detector function works fine. Are you setting reasonable input parameters, or are you just sending in your input and reading the output, going with the defaults?

 

We can't possibly help without more information (your program, some data, etc.).

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 8
(2,749 Views)

@Abuzar wrote:

Hello,

I am working on a project in which I want to calculate the rate of some signal. I have used the peak detector to detect the peak of the waveform.

The peak detector works accurately but after sometime like 40 seconds it starts counting the noise ( which is less than the value of Amplitude, and which it was previously not counting), I don't know the reason for this.

Can any one pls help me out to solve this problem

Thanks v.much


Does your signal actually end and then you are detecting noise only?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 8
(2,729 Views)

Hello everyone,

Thanks for replying, Actually i found a reason which i want to share with you to get a better solution.

I was previously building the program using multiple producer consumer loops in which one was generting the data, the second was plotting, and the third was analyzing and calcualting the threshold voltage.

As in this pic

 

block diagram1.PNG

 

Latter i formed a new vi, in which i made all these things happen in a single while loop like this

 

modification.PNG

 

From here what i came to know that when the reading gets fluctuate (the calculation value) i actually gets error in the vi(New bits arrived earlier error of VISA).

I removed the connection between the visa read and the build array function and then there wasnt any error in the vi(New bits arrived error of VISA).

I think that the time required to do the calculation produces error in the output. Because whenever the error occurs (in calculation) and i stop the vi, it gives an error output (of VISA) of new bits arrived earlier.

So, now can anyone pls give me the solution for it.

As i already deployed the producer and consumer loop to sepreate the production and calcuation and the same error comes when i combine all the operations in a single while loop.

I shall be very thankfull to all who replied.

Regards

0 Kudos
Message 4 of 8
(2,697 Views)

@Abuzar wrote:

Hello everyone,@camerond

Thanks for replying, Actually i found a reason which i want to share with you to get a better solution.

I was previously building the program using multiple producer consumer loops in which one was generting the data, the second was plotting, and the third was analyzing and calcualting the threshold voltage.

As in this pic

 

block diagram1.PNG

 

Latter i formed a new vi, in which i made all these things happen in a single while loop like this

 

modification.PNG

 

From here what i came to know that when the reading gets fluctuate (the calculation value) i actually gets error in the vi(New bits arrived earlier error of VISA).

I removed the connection between the visa read and the build array function and then there wasnt any error in the vi(New bits arrived error of VISA).

I think that the time required to do the calculation produces error in the output. Because whenever the error occurs (in calculation) and i stop the vi, it gives an error output (of VISA) of new bits arrived earlier.

So, now can anyone pls give me the solution for it.

As i already deployed the producer and consumer loop to sepreate the production and calcuation and the same error comes when i combine all the operations in a single while loop.

I shall be very thankfull to all who replied.

Regards


A more fundamental question then:

Why did you change it?  Why did you fix something that wasn't broken?  It would seem to me that the first way was superior.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 8
(2,672 Views)

Dear billko

As I wrote in my first post that I was working on Peak Detection in an incoming signal to find out the frequency of it.

The problem occurring in my first vi was that it was detecting some points as the peaks while they were not.

Also mention here that it always occur after some time. I.e.. It works perfectly for a certain time but then start counting some points as peaks which are not the peaks.

In order to get resolve the problem I made the vi in a single vi and concluded that what I think that the time is taken in calculating the peaks creates delay in getting the serial data and then it start counting the areas which are not peaks as peaks.

How do I concluded this was because, I disconnect the incoming data from the Build array (which you can see in the second vi) and then the vi runs accurately (i.e.. A new data arrives before the previous) in the VISA communication.

Also when inaccurate points are detected as peaks I stop my vi immediately and gets the error of VISA communication.

So some problem I think lies in the time of calculation that remains present in the producer consumer technique too.

Thanks a lot.

Regards

0 Kudos
Message 6 of 8
(2,666 Views)

I still stand by my post that the original architecture isn't what was wrong.  I think your "extra bytes" at the port are actually leftover data that wasn't read from the time before!  Here is an excerpt from VISA read:

 

VISA Read Details

This function might return less than the number of bytes requested if the function reaches the end of the buffer, reaches a termination character, or if a timeout occurs. The output error cluster indicates if a timeout has occurred.

 

[edit]

I believe that sometimes you are reading before all the data is in the buffer.

[/edit]

 

What you need is to figure out a method to wait until there are the necessary bytes at the port before placing it in the queue.  There are various examples here and in LabVIEW itself that show you how you might do this, depending on how the data is formatted.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8
(2,652 Views)
Solution
Accepted by topic author Abuzar

Hello,

Finally working on the first vi I found the solution of my problem

The reason I got for the changing value of the rate was that filled array, i.e. with time the array gets more and more values in it and it took time to work on it and as a result the vi giving wrong results of the rate.

I finally limited the value of array and then passed that limited array to the producer consumer section for calculation and then it worked correctly.

I request all to reply me whether i took the right way to the solution.

Thanks to all who helped me in getting a solution.

Regards

0 Kudos
Message 8 of 8
(2,583 Views)