r/LabVIEW • • Jan 23 '23

I need help with this program

Hi, LabVIEW Subreddit. i am currently working on my bachelors degree and need to write a LabVIEW programm for my project. i want to analyze the values of a force sensor over a set duration multiple times and then write minimum and maximum force, the standard deviation and the median with timestamps in an excel file. additionally i want an electrical input signal to trigger a recording of the force in real time (like 20 samples a second over a few seconds). i managed to write the part that calculates the min, max, median and standard deviation. My problem lies in the measurement duration part. i want to calculate said values over a certain time, lets say 30 seconds. then write only these values in the excel. i dont know how to output a value after calculating it for a set amount of time. after writing the values into the excel file, i want the current values of the program to reset, in order to calculate new min, max, median and standard deviation values.

i would really appreciate it, if someone knowledgeable in this sub would help me out. here again the requirements:

-sensor input from daqmx

-analyze the signal regarding min, max, median, standard deviation

-write min, max, median, standard deviation into excel file after the end of the measurement duration

-recieve input from daqmx to trigger the recording of force over a set time to plot a graph later. (if possible, recieve signal and then record two seconds before input and after input of the signal, maybe that works by constantly writing and rewriting an array)

i did not learn LabVIEW during the regular curriculum of my engineering degree, which is a shame, the program is incredibly powerful, sadly i dont know enough to fully take advantage of the software provided. if someone is willing to help me out i would be incredibly greatful. please just write me a pm or comment under this post. any advice would be appreciated.

0 Upvotes

12 comments sorted by

6

u/Electronic-Share-416 Jan 23 '23

Hopefully you didn't spend too much time writing the code to calculate the min, max, st dev, median because there are premade subVIs that do that for you. If you're looking to get a running average over a specified duration of time/samples there's a VI for that too. Navigating the pallets to find these can take some getting used to, so try quick drop (Ctrl+space) and type in "mean" to see a couple different options. Also, I highly suggest going to Help > Find Examples to check out some shipping examples demonstrating how to acquire and log data.

2

u/Durin_The_Deathless Jan 23 '23

no, i used the subVIs to generate these values. additionally thank you for pointing out the examples. i will take a look at them as soon as i am able to. i will try the things you and osiris suggested and comment again later tomorrow. hopefully i am able to finish this this week, because that is the last thing needed for my bachelors degree. i am like 90% done with the project. just the programm is missing.

2

u/Electronic-Share-416 Jan 23 '23

Ah sounds like you're really close to the finish line!!

I usually have to refer to this white paper on triggering whenever I have to implement something that deals with pre-trigger data:

https://www.ni.com/en-us/support/documentation/supplemental/21/ni-daqmx-data-acquisition-triggering-techniques-using-labview.html

Hopefully that helps with implementing what u/Osiris62 was mentioning

1

u/Durin_The_Deathless Jan 24 '23

hi there. i got the timed stuff basically done. now i "only" need the pretriggered stuff. i just wanted to thank you for your help so far.

2

u/Electronic-Share-416 Jan 24 '23

You're welcome! If I remember correctly, there should be a property node where you can set the number of pre-trigger samples. If you haven't checked out the property node yet, put one on your DAQmx task and explore your available properties to set/get.

1

u/Durin_The_Deathless Jan 24 '23

will do, thank you.

1

u/Durin_The_Deathless Jan 24 '23

regarding my for example 30 second analysis loop. is there a way to reinitialize the default values of the min, max, ... after each pass of the while loop? i currently have two while loops. one inside of the other and the most inner one has a duration of 30 seconds, then it writes all the values in my excel sheet. however when the loop then restarts, it just continues with the values currently stored in memory. i need to reset these to start the next measurement cycle.

2

u/Electronic-Share-416 Jan 24 '23

that's going to be a big 'it depends' from me...

I'm assuming yes it can be done but I'm also having trouble picturing how you're doing this so a screenshot of the relevant part of your block diagram would be helpful. If you're using a shift register, you can initialize that to a default value by wiring it on the left side of the loop instead of leaving the shift register uninitialized which will then carry the values over in memory from iteration to iteration.

1

u/DinklebergDamnYou Jan 24 '23

Same person, different account. Imo it’s kinda stupid that the reset to default block dies not work with a tf input.

2

u/Electronic-Share-416 Jan 23 '23

In example finder, I would start with 'Voltage - Finite Input .vi' since it includes triggering. You can browse to it by going to Hardware Input and Output > DAQmx > Analog Input > Voltage - Finite Input.

0

u/[deleted] Jan 23 '23

[deleted]

2

u/Durin_The_Deathless Jan 23 '23

thank you for the recommendation, i will get right to it. regarding the while loop. i could just use something like a timer to generate a true / false signal and then use this to stop the while loop. i already tried this once. however the entire programm then stops as well. i tried a switch case hoping it would only output when it switches the blocks of code, however this did not work. i thank you for your recommendations so far and will comment here again in case i run into problems.

0

u/[deleted] Jan 23 '23

[deleted]

1

u/Durin_The_Deathless Jan 24 '23

yep, i have that part finished. now only the pretrigger stuff is missing. currently i have my daq assistant inside the two while loops. one of them resets every x seconds. (btw. how do i reinitialize to default values each time the inner loop restarts?) anyway, i need to get the data from the daq assistant to use it in the next part of the programm. can i just put another daq assistant into the outer while loop and use this for the pretriggering stuff? well, essentially i would need two more. one fore the "hey save these values" signal and another for the signal that then needs to be recorded.

another question. when i use the merge signals block to merge multiple signals into one to then use a write measurement file block to create the excel, the columns of the excel file have default names. is there a way to name them in labview?