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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Distint no of changes in real time data

Solved!
Go to solution

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;
0 Kudos
Message 1 of 6
(3,039 Views)
Solution
Accepted by topic author zain1612

Hi zain,

 

problems: use of the formula node in conjunction with array inputs…

 

Why don't you use simple LabVIEW functions?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,022 Views)

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:

JumpDrop.png

 

 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>   ---'


0 Kudos
Message 3 of 6
(2,992 Views)

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 

0 Kudos
Message 4 of 6
(2,977 Views)

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

0 Kudos
Message 5 of 6
(2,968 Views)

Hi zain,

 

it's a Feedback Node…

 

I am a complete beginner

NI offers a lot of beginner courses to learn LabVIEW…

Best regards,
GerdW


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