LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array values resetting

Solved!
Go to solution

I built a VI that I believe should initialize an 8 element bool array to all FALSE. Then on each iteration of the for loop it's in, should turn each increasing element to TRUE. But in each loop iteration, the previous element is returning to FALSE rather than staying TRUE. Why is this, and what logic is needed to avoid this?

Download All
0 Kudos
Message 1 of 6
(3,380 Views)
Your VI is doing exactly what you programming it to do. With each iteration, you are operating on the same array that is initialized to have all False values. You need to pass the initialized array to a shift register.
0 Kudos
Message 2 of 6
(3,368 Views)

I added the shift register, and if I run it without the DAQ Assist, it works flawlessly, thanks! But when I add it back (8 digital outputs on a USB-6343 controlling a relay board) it stops after the second iteration.

 

The pic should show that the error states:

 

Number of Channels in Task: 8
Number of Channels in Data: 9

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

Como mencionan, tienes qué agregar un shift register y cambiar la función de insertar elemento a reemplazar valor de elemento.

 

Espero esto sea la solución a tu problema.

 

Saludos.

Download All
0 Kudos
Message 4 of 6
(3,347 Views)
Solution
Accepted by topic author dourk

@dourk wrote:

I added the shift register, and if I run it without the DAQ Assist, it works flawlessly, thanks!


You need to use "replace array subset", not "insert into array". You also need to initialize the array with 8 elements.

 

("insert into array" will grow the array by one element whenever you insert one, shifting all higher elements up. After two iterations, the array will have 9 elements. In contrast, "replace array subset" will keep the array at the same size, replacing the value of an existing element with a new value)

Message 5 of 6
(3,330 Views)

Woohoo! Thanks, moving on to the next issue!

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