LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting numbers of LEDs

Solved!
Go to solution

hello there,

what i am trying to do is i want to calculate the number of the green LEDs and the red LEDs of an array and display it in the front panel as shown on the file attached. Any one can help please? Another thing, how to write to file from 3d array ? 

0 Kudos
Message 1 of 6
(3,163 Views)

How about this?  Array 2 gives your the total Green LED's for each of the three 5x50 arrays.

 

Just write Array2 to a file.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 6
(3,120 Views)

Use Add Array Elements from the Numeric palette on the output of the Boolean to (0,1) to get the number of True elements.

 

You can put the Write to Spreadsheet File VI inside a for loop and index over the pages. However, you need to know the configuration of the 3D array to read it back.

 

I would probably get Array Size and write that to a header in the file. Then Reshape Array to a 1D array. Append that to the file after the header. When reading the file, first read the header and parse the array size. Then read the remainder of the array as a 1D array. Finally use Reshape Array with the size information to recreate the 3D array.

 

Lynn

0 Kudos
Message 3 of 6
(3,118 Views)

If you don't know the size of the Boolean array then you simply work backwards, keep count and subtract. (parking3)

 

Or use array size add them up and subtract (parking4)

 

You do not even need the inner loop (parking5)

 

 

========================
=== Engineer Ambiguously ===
========================
Download All
0 Kudos
Message 4 of 6
(3,103 Views)

Example of a 3x3x3 Array

3D Parking Lot Array NumCars2.png

Message 5 of 6
(3,084 Views)
Solution
Accepted by topic author Besho

Here is a VI which will save an n-dimensional array to a file and then read it back and restore the array to the original number of dimensions and size. Note that the write to file portion automatically adapts to the number of dimensions and size of the array. The read is only implemented for 1, 2, and 3-dimensional arrays. It can be extended to any size but the indicators and Reshape code must be created manually for the number of dimensions to be used.

 

Also note that for datatypes which are not integers a bit of additional formatting or bookkeeping may be necessary for the array size information.

 

Lynn

0 Kudos
Message 6 of 6
(3,040 Views)