LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring travel time of hammer

Solved!
Go to solution

Hi, 

 

I am trying to find the travel time between the start of the movement a hammer to impact. An accelerometer is attached to a hammer to obtain the signal. I use the trigger and gate function to obtain a block of samples when the trigger is detected (sensing the hammer started moving) . However, I am currently stuck on how to obtain the travel time using the block of data obtained. I tried using transition measurements.vi and other functions to no avail. 

 

0 Kudos
Message 1 of 16
(4,329 Views)

Attach your code, and attach a file containing data from the accelerometer (be sure we know the time base).  If you don't tell us what you did nor what you found, we can't be much help to you.

 

Bob Schor

0 Kudos
Message 2 of 16
(4,309 Views)

Hi Bob,

 

Attached is my VI. I am currently using bno055 to obtain the data through an arduino. Hope it helps you understand the problem. 

0 Kudos
Message 3 of 16
(4,290 Views)

Thanks.  I made a small modification to your code (attached as Hammer Data) that takes the data you get from Arduino and writes it to a Text File (Hammer.txt).  Could you please run this and use it to "capture" a data run from the time the hammer drops until it hits?  This will show us something about the data, including the number of channels, number of points in a sample, and we can "look for ourselves" and try to understand the signals you are trying to analyze.  I used a small "trick" that (I hope) gives nice tabular lines from the VISA data -- each VISA read gives a line of text, and by turning this into a 1D array (with only one row, of course), the Write to Text File automatically adds the EOL to the file.  Here's a Snippet, and I'll attach the VI, as well --

Hammer Data.png

Bob Schor

0 Kudos
Message 4 of 16
(4,268 Views)

Hi!

 

Thanks for the reply. I ran your code and logged the data in the txt file and is attached. A very clean code to log the data in .txt :). I am still learning LabView but I think maybe because the signal from visa does not read sampling rate from the sensor, labview only reads what is given to it as a raw string without timestamp and the sampling rate in this case is the loop speed?

0 Kudos
Message 5 of 16
(4,250 Views)

Hi Baj,

 

I think maybe because the signal from visa does not read sampling rate from the sensor, labview only reads what is given to it as a raw string without timestamp and the sampling rate in this case is the loop speed?

The sampling rate is defined by your DAQ device - your Arduino! The Arduino reads the samples at a certain rate and sends the converted data to your computer…

 

On your data:

check.png

These are columns gX, gY and gZ: there is a change at index 18, followed by an event at index 41-45. If one would know the samplerate then one could calculate time from index (differences)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 16
(4,247 Views)

Thank you for attaching the actual data file.  I notice two things about this data file:

  • There is an "extra" <CR><LF> after every line.  This is really my fault -- my "clever trick" of changing the VISA string into an "array" forced the extra <CR><LF> to appear.  Oops!  But this is why you "do an experiment and look at what comes out" (so you can fix your errors).
  • I noticed your original code had some interesting "parsing" issues.  But looking at the data (see previous point!), I see that all of the multi-column data are separated by <tab> characters, the default character that LabVIEW uses for "Delimited Spreadsheet" File formats.  This means that you not only can, but probably should, write the data just as it comes from Arduino.  When you want to read the file, you would strip off the first 5 lines (Header and spacer lines) and read the rest of the data as a Delimited Spreadsheet File (with the default <tab> delimiter left alone).  
  • Another thing you could do is to pre-format this file by removing the even-numbered columns (which start "X(Yaw): ", "Y(Pitch): ", and make a single "Header" row out of them (be sure to keep the <tabs> as separators).  This will make your Data File much more compact and more "Spreadsheet-like".

Bob Schor

 

P.S. -- I completely agree with GerdW (I almost always agree with him!) that the timing resides in Arduino.  There's a lot of data being sent for each sample (lines contain >360 characters, which at a serial rate of 115200, or about 11520 characters/sec, seems to be around 30 Hz, or a measurement every 33 msec.  I would think you'd want a more precise time measurement ...

0 Kudos
Message 7 of 16
(4,230 Views)

Hi,

I understand that we can calculate the transition time manually if we know the sample rate. But I am trying to extract it automatically because impact will be performed multiple times per run and logged into a file. The RHS picture below shows the triggered signal (linyacc in my txt file) block of 30 samples and I aligned it with the waveform chart on the left, so sample rate as Bob said, is around 30Hz. Therefore if we take the end to end of the transition signal it will be approximately 16 samples which corresponds to 0.53s.

However I am still stunted on how to extract this automatically.

Right now what I am trying to do is using trigger and gate function to obtain a block of samples after it detects the trigger ( rising above a specified level) and trying to  somehow use the data block to obtain the transition time from this time block (or samples which can be later converted.)

impact.png

0 Kudos
Message 8 of 16
(4,221 Views)

Hi, 

Thanks for the clean up advice :). 

The sampling rate is approximately 30Hz as you said (see my reply to GerdW)  and we can calculate time manually but is there any communication between arduino and labview regarding the sampling rate?. and Is there a way to measure the time (or samples) automatically since the impact will be done multiple times.

0 Kudos
Message 9 of 16
(4,211 Views)
Solution
Accepted by topic author BAJ19

Hi BAJ,

 

but is there any communication between arduino and labview regarding the sampling rate?

Not yet. You would need to program that in LabVIEW and your Arduino sketch…

I agree with Bob on that rather larger message you send from your Arduino: I would try to send those data in a more compact format (like binary with scaling done by your VI). This will improve the time needed for data transfer and may help to increase sample rate.

 

and Is there a way to measure the time (or samples) automatically since the impact will be done multiple times.

Sure: detect the start and end of your impact and get the difference of time (or sample count)…
 
 
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 16
(4,192 Views)