LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you compare the result of a formula node to a known value times any integer (n)

I would like to create a case where if the value output from the formula node is equal to any integer times 8 (8n) a line of text is written.  I have the output of a formula node wired to a comparison (equals) and this is attached to a case structure that says "if this is true: write", but I'm not quite sure what I can use to represent "8n".  I will thank you in advance for your guidance.
0 Kudos
Message 1 of 10
(4,419 Views)
Use the "Quotient Remainder" function to divide the formula result by 8. Then wire the Remainder node to an =0 function, wire the output of the equals zero comparison to your case structure.
Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
0 Kudos
Message 2 of 10
(4,414 Views)
Thanks for your help.  I would never have thought of that.  I just have one more question.  Right now I get an error message saying that there is a semi-colon missing in the formula node.  However, I have put the semi-colon where its supposed to be, but continue to get this message.  The VI is attached...any ideas how to make the problem go away?
0 Kudos
Message 3 of 10
(4,396 Views)
You've got a couple of mistakes. If you want to multiply one value by another, you have to use the mulitplication operator (*). You would have to have something like 0.135 * x. The other problem is that you have an array input and you have a scalar output and you will get another syntax error once you fix the mulitply problem. Which element in the input array do you want to mulitply by the constant? If the data returned by the DAQ Assistant is a scalar, you've got to change the resulting data type of the Convert From Dynamic Data.
0 Kudos
Message 4 of 10
(4,392 Views)
There you have the underlying problem...I have no experience whatsoever in this field.  I was initially under the impression that the DAQ was sending me only counts (from a USB6008 DAQ) counter/timer port, however I now believe it sends me a time (in seconds since the start of the run as the x-value) and counts as a comment.  It is the count (comment) that I am trying to isolate and and multiply by the constant.  However eventually I want it written with the output and time.  I changed the convert dynamic data to a scalar rather than a 1D array and that fixed some of my problem.  However, what I am really trying to accomplish now is to only have 1 line written for each unique comment (count), not 1 unique x-value (time).  I created a shift register in another attempt, but that isolated time, not count.  How do you pick whats being looked at?  Additionally, I need to know if there is anyway to add a third line to the data file (i.e. a second comment)?
0 Kudos
Message 5 of 10
(4,373 Views)
The count is not a comment but a value in the dynamic data which is similar to a waveform data type. A waveform data type is a cluster with a timestamp, dt, and a y array of values. By converting to a scalar, you should be getting the count value. Does your 'Counts' indicator reflect this? If this is okay, then in order to write the data to a file with both a timestamp and the count value, wire the dynamic data straight into your Write LabVIEW Measurement File. This function has a comment input that you can wire in a string if you want.
0 Kudos
Message 6 of 10
(4,365 Views)
I don't think I've conveyed correctly what I would like the program to do (and I had it a bit wrong in my head at first).  As it is now, it does ALMOST exactly what I'd like it to do.  The only thing that needs to be fixed is that I only want it to write a line when the cm value changes, not for each time value that it sees the cm value I'm looking for.  See attached VI and attached text file (not that there are several 1.08 (I only need the first one).
Download All
0 Kudos
Message 7 of 10
(4,351 Views)
Well, you have the Write labVIEW Measurement File in both the true and false case so it will be called with every iteration. It looks like you want to save whenever the cm value is a multiple of 8. If you want to save every time it it changes, add a shift register to the while loop and wire the current value to the right side. Then you can do a comparison between the current value and the previous one (the left side of the shift register). 
0 Kudos
Message 8 of 10
(4,343 Views)
I added the shift register and have the case selector value error that I'm unsure how to resolve.  Also, I dont think I've done it correctly because it looks like there are two different files that will be written.  I want one file into which a line is written only if the count value is a multiple of 8 and the current value is different from the last value. I think we're close to solving this 😃
0 Kudos
Message 9 of 10
(4,326 Views)
You need two different case statements if there are two different conditions for saving a file. The problem though is that you are doing a comparison of floating point values and that's never a good idea. Is the count always an integer? If so, you might want to do a conversion to I32 after you do the convert From Dynamic Data.
0 Kudos
Message 10 of 10
(4,322 Views)