LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

replace array subset

Solved!
Go to solution

I have a problem that I can't seem to solve.  I have a array of 6 valves that are a type def.  I want to be able to indicate which ones are on using a for loop.  The for loop count terminal is wired to the number of valves that are being tested.  I expected indicators 1-5 to turn on in the example, but only 5 shows on.  Can you tell me what I am doing wrong?

 

I just figured it out, sorry to bother you.  I changed the input tunnel to a shift register and left the output tunnel as last value still connected to the valve indicator.

 

Thanks.




metzler CLAD
0 Kudos
Message 1 of 6
(3,003 Views)

You need to use a shift register.  Without it, your iteration 1-4 does nothing and the data is disregarded.

0 Kudos
Message 2 of 6
(2,989 Views)

Also is there a reason you want to wait 500ms between each replace?  And did you know you can do this without a for loop?  Attached is an example.

0 Kudos
Message 3 of 6
(2,987 Views)

The delay was inserted just so I could see what was happening a little slower (was originally 1000ms) with highlight execution. 

I don't think your diagram without the for loop will work - the original valves all start with the indicator status off.  This is part of a state machine that tests up to six valves.  The count terminal of the for loop is used to iterate the loop the number of times depending on the number of valves being tested. 

Thanks for the feedback, Hooovahh.




metzler CLAD
0 Kudos
Message 4 of 6
(2,974 Views)
Solution
Accepted by topic author metzler

metzler wrote:  I don't think your diagram without the for loop will work - the original valves all start with the indicator status off.  This is part of a state machine that tests up to six valves.  The count terminal of the for loop is used to iterate the loop the number of times depending on the number of valves being tested.

Then use Initialize Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,958 Views)

@metzler wrote:

I don't think your diagram without the for loop will work - the original valves all start with the indicator status off.  


Oh right, either initalize as mentioned, or what I should have done is set the control to 6 falses then right click Data Operation  >> Make Current Values Default, and saved the VI.

0 Kudos
Message 6 of 6
(2,919 Views)