LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two equal consecutive integers

Solved!
Go to solution

In this vi if 2 consecutive numbers are equal the boolean remains true while it should turn off then on.

 

If there a way without using local variables to do that?

 

0 Kudos
Message 1 of 32
(3,051 Views)

You use shift registers to avoid using local variables.

 

Since you are dealing with integers, all of your wires should be blue rather than orange.  You can run into problems trying to compare whether floating point numbers (orange) are equal to each other.

 

You can also use the Quotion remainder function instead of division and rounding down.  That will guarantee you have an integer and is also fewer operations.

0 Kudos
Message 2 of 32
(3,046 Views)
Solution
Accepted by topic author A.A.A.

After writing each boolean, you need to clear it before going to the next iteration. This is most easily done with an inner FOR loop containing two iterations.

 

Here's a quick draft. See if it works for you.

 

(I also simplified the rest of your code, wich was exceedingly convoluted. I am sure it could be simplified further. Note that I used a transparent cluster for the LEDs, eliminating all these comparisons)

 

Download All
Message 3 of 32
(3,033 Views)

altenbach! very nice idea !Ill do my own vi and posted later.

0 Kudos
Message 4 of 32
(3,001 Views)

I have tried do it but I am getting an error :connected a cluster of 9 contents and a cluster Cluster of 10 elements.

0 Kudos
Message 5 of 32
(2,974 Views)

@A.A.A. wrote:
I have tried do it but I am getting an error :connected a cluster of 9 contents and a cluster Cluster of 10 elements.

 

Did you try a search? This question has been asked before many times. Did you try the LabVIEW Help? Be honest here. The LabVIEW Help would have told you that the Array to Cluster function defaults to 9. You have to right-click on it and set to the number of elements you want.

0 Kudos
Message 6 of 32
(2,964 Views)
0 Kudos
Message 7 of 32
(2,956 Views)

I used the help but not on the Array to cluster function but on the Cluster 😕

I'm fixing the vi now.

thanks

0 Kudos
Message 8 of 32
(2,952 Views)

The first element of the constant array missed a zero.

 

This is the final VI.

0 Kudos
Message 9 of 32
(2,945 Views)

In addition to Saverio's advice, here are a few more comments:

 

  • Don't wire N if you are autoindexing. The loop count is fully determined by the array size of the autoindexing array, so don't over-determine the code. If you do, you need to do multiple modifications to change the program.
  • Since the ID input has 9 digits, use a format of %09d to display all leading zeroes. (if the possibility exists that longer numbers are entered, you should also set input limits)
  • For small array diagram constant, I would always show the first out of range element so it is clear how big the array really is. If you don't, it could be much longer than the display. (For large array diagram constants, simply show the scrollbar).
  • Your case structure has a wait primitive in each case, thus the wait belongs outside the case structure. Don't duplicate code! (I would avoid the case structure and autoindex over an array of waits.)
  • The first two numbers in your array constant are identical. Probably a mistake (Ah, you fixed that!). (It might be better to calculate the values from first principles based on the iteration terminal. Won't be that hard (not shown).
  • You could also use a feedback node.
  • ...

 

 

0 Kudos
Message 10 of 32
(2,942 Views)