LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I count 0's and 1's

After converting boolean true/false to (0,1) I'd like to count the number of ones during data acquisition or if better the number of trues before the conversion. Everything I tried accepted a different type of data (string or waveform instead of word)
0 Kudos
Message 1 of 6
(3,238 Views)
How about feed the boolean to a case loop selector and set a counter in the loop?
0 Kudos
Message 2 of 6
(3,238 Views)
Bernd R.;

An option can be to create an array with the boolean results, convert the whole array into 0's and 1's and then sum the array.

See the attached VI.

Regards;
Enrique Vargas
www.vartortech.com
Message 3 of 6
(3,238 Views)
Thank you Enrique, that works good. Just that I need to know the count with every consecutive, incoming value, not after the loop is finished. So a count in real time.
Bernd
0 Kudos
Message 4 of 6
(3,238 Views)
Bernd R. wrote:
> After converting boolean true/false to (0,1) I'd like to count the
> number of ones during data acquisition or if better the number of
> trues before the conversion. Everything I tried accepted a different
> type of data (string or waveform instead of word)

Well, you could use the Add Array Elements primitive on the Numeric
palette on the array of 0 and 1.

Rolf K
0 Kudos
Message 5 of 6
(3,238 Views)
OK, see if the attach VI is of help.
www.vartortech.com
0 Kudos
Message 6 of 6
(3,238 Views)