From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-13-2020 08:56 AM
RavensFan,
I've been studying the tutorials and reading up on case structures specifically as well, but I'm having trouble knowing what to input to the case selector for what I'm trying to achieve. If I wanted to have a case structure for the Write to File VI, how would you set up the case selector to only accept data values that are between 10 lbs and the 3 peak values?
Thanks
02-14-2020 09:39 AM
I'm developing a code for data acquisition from 3 load cells simultaneously. I'm trying to set up my code such that it only saves data points that are within a certain range, but nothing I have tried so far has worked as I intended. It seems like the best way to do it is to use a case structure, but I am open to other solutions as well. I am not receiving any Error notifications, but it still saves data outside of the range that I want. See below for the code and a couple snapshots of the case structure in the True and False case so far. I'm still a beginner in LabVIEW so any tips are appreciated.
Thanks!
02-14-2020 10:25 AM
Sorry, I don't have drivers installed, so I cannot tell how your express VIs are configured. What's exactly is inside the various dynamic data wires?
What do you want to write to your file? From all the data inside the dynamic wire, the case structure only cares about the first element. This is probably not what you want. Do you want to keep all the points in a given range or save all current data if the first point is in a given range? How are you planning to keep the timing information (points are no longer spaced equally)?
Mixing scalars and dynamic data like you do here seems like a bad idea. You also have way too much duplicate code.
Can't you operate on array data instead? Most experienced programmers don't use dynamic data and express VIs.
02-14-2020 11:38 AM - edited 02-14-2020 11:39 AM
I second what Altenbach said. Also, writing to a hard disk every loop iteration is not very common because it can really slow things down. You can collect all of your data and then write it after your loop finishes. To see if a value is within the range you need, you can use "in range and coerce". In a for loop indexing terminal you can right click the terminal and select "conditional" which adds a boolean input to let you filter your data.
02-14-2020 11:49 AM
Something like this would get you started:
02-14-2020 12:02 PM - edited 02-14-2020 12:06 PM
I would replace the code in the for loop with min&max (and remove the for loop). Lower sr needs to be initialized with an array of -inf if negative readings are a possibility (and eliminate the first run case structure). I would add an array of three constants, eliminating the build array. Etc...
(Posting by phone, cannot look at code and see what's in the other cases/events, so not all comments might apply)
02-14-2020 02:00 PM
Thank you everyone for your help and suggestions. I have a lot to learn! I will study up on everything you all have offered and see if I can make it work.
02-14-2020 02:51 PM
that's how it could look like with my suggestions added:
Of course there are serious problems with the ever-growing data structures in the history array. It would be better to keep a fixed sized history, of course. You'll run out of memory otherwise.