LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

increment values in array by comparing with an another array

Solved!
Go to solution

Here's my solution for the original problem. The second problem can be solved similarly.

 

0 Kudos
Message 31 of 39
(1,625 Views)
Solution
Accepted by Rcano_1982

And here's what you would do for the second problem. All you need to do is change the 2D array diagram constant to a control with however many rows you need, one per iteration. Of course the 2D array output can be left out in the final code if only the final 1D array is needed.

 

 

Message 32 of 39
(1,617 Views)

Hi Altenbach,

 

Many thanks for your help, very appreciated.

 

Unfortunately I did not managed to get your code to work in my state machine. When I connect it to my data array, the final array does not accumulate the values every time the state is executed. It gets stuck. I can send you a screenshot

 

So based on your example I replace the shift registers by tunnels and -Please see the picture attached- and added an extra gate and to feed a register that should accumulate the result from the previous operation. So the first adder does give me the elements that match the value "in 1s", that is okay, the problem is to add that to the overall count and feed it through the nex iteration. Using shift registers would be in theory the solution but I cannot get it to work. The register with the overall result does not seem to accumulating the data, seems empty.

 

I do not know what to do to be honest. It must be a simple solution but dont find it, Is it understandable what I am trying to do?

Thanks for your time

 

enquiry_1.png

0 Kudos
Message 33 of 39
(1,584 Views)

Hi Rcano,

 

you have been given a lot of solutions and hints to your problem, but you fail to integrate them in your code.

 

Either integrate the solutions as they are provided (without altering them in the process) or attach your VI so someone else may do that for you…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 34 of 39
(1,582 Views)

Hi GerdW

 

Please see attached.

 

Thanks for your time.

 

Regards

0 Kudos
Message 35 of 39
(1,575 Views)

Hi Rcano,

 

AutoCleanup didn't like your VI.

 

I hope I got the right position for your register value checking/counting…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 36 of 39
(1,569 Views)

@Rcano_1982 wrote:

Hi Altenbach,

 

Many thanks for your help, very appreciated.

 

Unfortunately I did not managed to get your code to work in my state machine.


The code picture you posted has no resemblance whatsover to my suggestions and examples.

0 Kudos
Message 37 of 39
(1,564 Views)

Hello there,

 

Thanks to both GerdW and Altenbach.

Altenbach your solution worked in my design, sorry for modifying it, I was trying anyting to make it work.

All what was going on was very silly, One of the wires on one of the states was not wired accross, so data was lost when executing that state.. A newie mistake I suppose. Thanks for the support it has helped to improve my skills in LV

0 Kudos
Message 38 of 39
(1,541 Views)

Rcano_1982 wrote:

All what was going on was very silly, One of the wires on one of the states was not wired accross, so data was lost when executing that state.. A newie mistake I suppose. Thanks for the support it has helped to improve my skills in LV


That's why we highly prefer to always see the entire VI. A truncated picture of a code segment cannot be used for troubleshooting. 😄

0 Kudos
Message 39 of 39
(1,528 Views)