04-23-2008 03:21 AM
04-23-2008 03:47 AM
03-02-2009 02:49 PM
I'm having the same problem ... sort of. I want to convert a 1-D array of length N to a double... or I guess to better phrase this, pass each value of the 1-D array into a VI where only one value can be input at a time. To put in context, I'm trying to do a voltage sweep from -2 to 2 volts. I made a for loop that will have N voltage steps between -2V and 2V. The error I get when I wire the output of the loop directly to the scalar input is (I knew I would have an error before doing this)...
"You have connected an array data type to
its element data type. This type conflict may be resolved by indexing
the array to access individual elements of the array. Check for a
tunnel on a loop that has indexing incorrectly enabled.
The type of the source is 1-D array of
double [64-bit real (~15 digit precision)] [numFlags=0x0].
The type of the sink is double [64-bit real (~15 digit precision)] [numFlags=0x0]. "
Does anyone know how to index the array to accomplish this? I think this would be easy, but I couldn't find anything to do it. I could upload a picture of the block diagram if that would help. Any help would be greatly appreciated.
03-02-2009 02:55 PM
03-02-2009 03:41 PM
GerdW,
Thanks for the fast reply. I've included a picture of the block diagram because I want to be certain about what you were saying... So I interpret that as putting the for loop (the subVI) in another for loop? Or are you talking about the 'vsource control' block?
03-02-2009 04:22 PM - edited 03-02-2009 04:24 PM
Hi nano,
"So I interpret that as putting the for loop (the subVI) in another for loop?" - Yes, correct.
See example! (Also on better using LV primitives.)
Where is this "vsource control block"?
03-02-2009 08:38 PM - edited 03-02-2009 08:41 PM
GerdW,
Thank you. That example was extremely helpful!! If I wanted to save this data as it was being processed, would I also include the write to text subVI inside that loop with the other subVI?
Sorry, I think I am using wrong labview vocabulary... in the PNG file I attached, 'VSOURCE CONTROL' is within the case structure. It is where the output of the original for loop I made was connected to
03-03-2009 02:50 AM
Hi nano,
"would I also include the write to text subVI inside that loop with the other subVI?"
Well, in general you could.
BUT: writing single values to a textfile would create a lot of overhead (file open, seek, write, close) in each iteration.
When your arrays are rather small (less than ~10 million values on a modern PC) you could go with arrays and the spreadsheet functions (either string palette "array to spreadsheet string" or file palette "write to spreadsheet file").
Ok, now I spotted the "vsource control" - it's your subvi. Usually I don't refer to text in the icon of a subvi, so I didn't notice it...
03-03-2009 01:27 PM
Thanks for all the replies!
I tried using the 'write to speadsheet' function last night but I the output it always an empty file. This is puzzling. When I try wiring anything to 'build array' and then to 'write to speadsheet', there are no errors, but there's no output. I tried with and without 'build array'. I build the array in the for loop. I'm just trying to see if I can build an array of input values for now. Why wouldn't this work? I've attached a snapspot of the block diagram: 'Write to speasheet' on the upper right corner with delimiter controls and a path indicator.
03-03-2009 01:51 PM