LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Error with subvi that calculates a count

Highlighted

I have the following vi that I am using as a subvi. The goal of the vi is to calculate the the count on ch A between during a period of the index. The vi works well most of the time, but on occasion the count given is 0. It seems to happen at random intervals as well. You can run the same test and one time it gives the correct count and then the next test it will give a count of 0. Is there anything glaring wrong in the vi that may be causing the error that I am just overlooking?

0 Kudos
Message 1 of 12
(667 Views)

Hi,

 

Can you send the 2015 version of your vi ?

 

Regards,

FRED

0 Kudos
Message 2 of 12
(658 Views)

Here is the 15 version of it

0 Kudos
Message 3 of 12
(651 Views)

Your second loop has a couple of uninitialized shift registers.  So they will use the last value from the previous run.  From what I can gather, that is not desired.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 4 of 12
(636 Views)

I've tried setting those shift registers to 0 and it will still throw out a 0 count every so often.

0 Kudos
Message 5 of 12
(628 Views)

@randomguy77 wrote:

I've tried setting those shift registers to 0 and it will still throw out a 0 count every so often.


Your post is insufficient to tell what you did, what you expect to happen, and what happen instead.

 

  • How did you "set" the shift registers to zero? Attach your code again!
  • I am not familiar with the term "throw out" in the context of code.
  • How often is "every so often"? What is the pattern of occurrence?
  • How is this subVI called in the context of the overall project?

What is the program supposed to do? I seem quite a few questionable code constructs that could be simplified and streamlined.

What are typical input values for the various controls? It would help if you could fill reasonable default values before posting here so we have something that is ready to run.


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 6 of 12
(626 Views)

Here is the VI with them initialized to 0. Just create a constant 0. Pretty much the standard way to set them to 0.

 

I guess output is the better terminology than throw out. Just meaning the "Count Test" output is 0 instead of the correct count.

 

There is no pattern of occurrence, and as far as I can tell it is truly random. It can happen once out of 50 runs, then 4 times in a row, then every other, and a so on.

 

The VI Execution Settings shows the settings for the subVI.

 

The purpose of the subVI is just to count how many rising edges happen during one revolution.

 

0 Kudos
Message 7 of 12
(622 Views)

It still would really help to have some typical default values in the controls.

 

What is the meaning of the data in the "index" array"?

What is he meaning of the data in "Ch A"?

 

(In the first loop you could use a conditional tunnel. Index array is resizeable but if you would take element 1 and 2, you would not need to delete element 0 from array. You only look at two elements from the first loop. What if there are more (or less)? Shouldn't most of the second loop and the output be blue (integer)?)


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 8 of 12
(617 Views)

The index array is the data from a hall effect sensor. It will be 0 expect for when the index on the magnet passes by causing it to be high, which is 5V.

 

Ch A is the data from Ch A of an encoder, so just a square wave from 0-5V.

 

The reason for only getting two elements from the first loop, is that gives you the length of that rotation. The count only needs to be calculated once per test, but it needs to be over an entire revolution. Any farther index pulses can be ignored for the purpose of calculating the count value.

0 Kudos
Message 9 of 12
(613 Views)

I'm with Christian, your VI seems overly complicated.  For instance, move your Greater Than to be before the loop.  This will make things simpler inside of the loops.  And then you can use a Greater Than to compare the current value to the previous.

 

With the same data set, I have yet to see a 0 come through.

 

EDIT: I just noticed that those Boolean constants should be set to TRUE.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 10 of 12
(610 Views)