LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real Time Cycle Counting using Peak Detector

Hello All,

I am relatively new to LabVIEW, and am currently struggling with a small data acquistion project. The goal of the project is to measure the clamping force of a component over many repeated cycles, to determine the loss of clamping force due to wear. This force is being measured using a pair of load cells connected to a NI DAQ system, which seems to be working fine.

 

However, I am struggling with some labview programming. Currently, my best program will record the load cell voltages for a set time period, and then create a graph of the load at the end of the time period. Furthermore, I have used the Peak Detector vi to record the peak loads, and also the cycle count, based on the number of peaks. This was very simple to do using the DAQ assistant, and some simple array manipulations.  

 

The thing I don't like about this method is that there is no realtime feedback; you don't know how many cycles have taken place until the program times out. Would there be any way to make a program that would detect and count peaks in real time? This way an operator could cycle the component until x number of cycles, without having to count on their own. I have tried to accomplish this by using a While Loop around everything, but I end up with gaps in the data, resulting in some load peaks going undetected.

 

Anybody have any sort of game plan for me? Thanks for any help.

 

Tony

0 Kudos
Message 1 of 7
(6,390 Views)

Tony,

 

Could you post the code that you have?

 

It will make it much easier for us to help and I'm interested to see how you've approached the application so far.  

 

Thanks,

 

~Simon

0 Kudos
Message 2 of 7
(6,384 Views)

Hello,

Here is a screenshot of the block diagram I have so far. It's pretty simple, just a peak detector vi wired to the input signal, with a feedback loop that adds 1 to the count everytime a peak is detected. This method does work, my main problem is in it's consitency, some peaks will get missed, and others will register as more than one peak. I can improve this by tweaking the width and threshold, but it is still too inconsistent to use for a proper test. It also seemed like I got the best results with my "Samples Read" set the same or greater than the sampling rate, even though this causes a slight delay.  

 

Is this what you wanted to see? Or is there another way to display the code. 

 

Also, the second screen shot is the VI that simply records all the data, finds the peaks, and then tells me how many there was afterward, without any real time feedback. Ultimately, I was hoping for a way to combine the two, but I'm not sure if that will be possible.

 

Thanks!

 

Tony

 

Labview Screen Shot.png

Labview Screen shot 2.png

0 Kudos
Message 3 of 7
(6,377 Views)

Actually attaching the .vi files is easiest -- that way I can also see how you have your DAQ Assistant configured and I can modify them and repost.

0 Kudos
Message 4 of 7
(6,371 Views)

Ok, bear with me. Here are the two VI's. Thanks.

Download All
0 Kudos
Message 5 of 7
(6,369 Views)

Tony,

 

I managed to take a look at your code and I think I somewhat understand what you want.  In order to get the continuous updates you desire you need to configure the DAQ assistant to acquire continuously rather than N Samples.  I generally set my samples to read to be 1/10 the sampling rate so that the DAQ assistant returns a new chunk of data 10 times a second -- any faster than this is unnecessary since we can't update the screen that fast anyway.

 

I also use shift registers to store the all of the acquired data since now I'm reading the acquired data in chunks and since I'm doing the peak detection every iteration I accumulate the results too (so I don't recalculate peaks in the old data every iteration).

 

Here's a VI Snippet of the code but you'll need a couple of subVIs that I've attached.  I've also included a version which simulates signals that I used to test for all the other readers that don't have your hardware setup.

 

vi_snippet.png

 

Give these a try and let me know how they work.  I'm happy to offer any more advice you need.

 

Also, I'm interested -- you said you were new to LabVIEW, how are you going about learning how to use it?  Are you using any books, resources on ni.com, the LabVIEW help, examples etc?  Which do you find helpful?

 

Anyway, best of luck.

 

~Simon

0 Kudos
Message 6 of 7
(6,303 Views)

Simon,

I gave it a try, and it definitely works well. The only problem I have had at all is the with the peak detector being slightly finicky, and having to adjust the threshold and width regularly to advoid missing or counting multiple peaks, the same as with my VI using the array peak detector. Is there any reason that the waveform peak detector would work better than the array peak detector? I'm not sure if there is going to be any way around that however. One thing I wished I had told you sooner was that I decided to add the two channels into a single waveform, and detect the peaks from that (each channel is a individual load cell measure force on a test block, adding them gives me total force). I tried to add the two waveforms in your program, but I have not been able to figure out how to make the Append All VI work with this.

 

I played around quite a bit more after posting my original, and I think I came up with a VI that does something similiar to your's, but definitely not as nice. Take a look if you are curious, and let me know how they compare. I wasn't familiar with the shift registars, but I used a forloop instead of a while loop to stack the interations into a final array for me. The biggest downside was that as far as I could tell, I had to wait for the VI to time out before I could export the array data.  

 

About learning LabView, I actually had a semester long engineering course with quite a bit of labview programming in it, so I learned quite a few basics, although that was already a couple of years ago. Other than that, I have just been playing around and figuring things out. The Labview help, and contextual help is extremely useful. I have tried looking at some examples and tutorials, but I have had a hard time finding relevant scenarios, even though it sometimes seems like there are too many examples and tutorials to choose from.  

0 Kudos
Message 7 of 7
(6,274 Views)