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.
07-21-2015 08:59 AM
Hi I am taking in data in real time where the value goes from 1009 , 1008 o 1007 to 0. I am trying to count the number of distinct times this occurs , for example the snippet below is should count 2 distinct periods of change.
1008
1009
1008
0
0
0
1008
1007
1008
1008
1009
9
0
0
1009
1008
have written a for loop as below but I cant figure out if the logic is correct as I get multiple increments instead of just the one
if(current != previous && current < 100)
x++;
else
x = x;
Solved! Go to Solution.
07-21-2015 09:14 AM
07-21-2015 09:36 AM - edited 07-21-2015 09:40 AM
Your statement here and your statement in the code is different. Here you say:
if(current != previous && current < 100)
But, the node in the code is:
if(R<100 & R1[ != 0)
I think your problem might be that your "x" value doesn't get fed back in to the node from the previous iteration. So when you put "x++", I think it still just has the initial value of x and adds 1. I'm not an expert on formula nodes, though, so I can't be sure about that.
I ran through a few different options to find the data shifts that you're working with. The top is the fastest, but requires you to have an array of values all ready to go. The bottom is closer to how your node behaves. Take a look:
P.S. This snippet above can be dragged on to a LabVIEW block diagram to import the code.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
07-21-2015 10:02 AM
GerdW
I am a complete beginner , used to text based languages so its easier for me.
What is the name of *---> symbol as I am having trouble finding it
07-21-2015 10:13 AM
I think I just forgot to save it when I made the change. I cant seem to drag it since I am using labview 13
07-21-2015 10:14 AM