LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array not resetting in program between runs

Solved!
Go to solution

Hello all, I am attempting to write a program to pragmatically assign physical channels to a DAQ task that will be used to record data. For the sake of understanding, the program is going to be used to record thermocouple data and I would like versatility with my VI's. The goal is the get rid of the DAQ assistants we currently use so there is no need to rewrite the channels in the DAQ assistant every time they need to be changed (which is quite often).

 

On to the problem. The issue I am having is that the array being used to store the list of physical channels is not resetting between executing the program. This results in an error of conflicting channel names (simply using the physical channel name as the channel name). My current guess as a way to fix this is to initialize the array in the beginning of the program. Problem with that is I need the array to be type DAQmx Physical Channel and I have not been able to initialize an array like that. I attached my VI below. Any help would be greatly appreciated and thank you in advance for any help you can give.

 

0 Kudos
Message 1 of 6
(2,939 Views)
Solution
Accepted by wkernan

Your shift register on the For loop is unitilized which means it will retain it's value. You should explicitly initialize teh shift register. You would also be better off auto building the array rather than using the Insert into array.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 6
(2,932 Views)

Thanks for reply Mark. You were right and initilizing the array fixed the problem. Though could you explain why you would use build array instead of insert into array? i played around ith build array a little bit and ran into issues with the dimensions of the arrays argreeing. Is there a specific reason you say that builind is better than inserting?

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

Build Array should be used about 99% of the time.  Only in special situations is Insert into Array the right thing to use.  The problem with Insert into Array is that if you aren't careful with your indexing, you could be trying to insert stuff into a part of the array that doesn't exist and thus lose data.

 

If you are having problems with Build Array, then right click on it and check to see what is set for the Concatenate Inputs option.

0 Kudos
Message 4 of 6
(2,889 Views)

In your specific case I was referring to the automatic build array on the For loop itself. You simply wire your element to the right side of the For loop and let the loop build the array for you. In most cases (unless you are dealing with very large arrays) this is the fastest way to build an array in a loop.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 6
(2,886 Views)

Okay that makes sense. Thanks for explaing it a bit more in depth and specifically. Everything seems to be in working order and ill be implementing this on some VI's this after noon. Thank you gain for the help!

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