04-08-2009 01:19 PM
Hi, I've been modifying an example and subVI to make it compatible with waveforms and have been battling with this for a while (please see attached). It appears to work to some extent at the moment, but my current problems are that:
1) The data output to the spreadsheet file is only 1 line - this means to me that it is over-writing the data instead of appending the array(?) but I can't see why? The graph of the waveform, which is in the same loop as the build array, looks correct and collects continuously.
2 ) the VI stops by itself after about 10 sec with no errors reported, but I did not (conciously) put a timer into the VI.
Thanks for any help,
Claire.
04-08-2009 01:29 PM
I should also add that while I expected to be saving waveform data to my spreadsheet, it only contains the channel data, and not the timestamp or dt. This baffles me as the data type on the wire going to the spreadsheet is a 1D array of waveform.
Cheers,
Claire.
04-08-2009 02:32 PM - edited 04-08-2009 02:37 PM
Hi CFJ,
some notes:
- many of your case structures use "default if unwired" terminals - is this really wanted?
- Do you spot the red point on the "write to spreadsheet file"? This signals a data conversion - in your case from waveform to 1D DBL array... That's why you only get the waveform and not the timestamp in the spreadsheet!
- why do you use so many locals? There are terminals and wires...
- just a remark: to build formatted string I would use only one "format into string" instead of many many "to text" conversions and "concat string" functions...
Edited:
I just spotted the way you build a string array... Why (the hell) do you put strings into cluster, then unbundle them again to bundle them in a bigger cluster, then convert the cluster into an array and finally reshape the array? Would a simple "build array" node not work here??? Sorry, I have to send this to the RubeGoldberg thread
04-10-2009 02:57 PM
Hi GerdW,
Thanks for your comments. A few answers:
1) I guess not, I've got rid of them now I believe.
2) thanks, have wondered what that red dot is about before. fixed now.
3) i used locals to try and clean up the diagram so there weren't wires going every where. I'm assuming there is some downside to this since you commented on it, so I'm going through and connecting into the original wires.
4) I'm trying on this, not sure if I've achieved the level of efficiency you would, but hopefully closer. Didn't know the build formatted string function existed.
5) i'm assuming the goldberg thread is for labview stupidity. With about 3mths of experience trying to make labview do what i want it to I'm happy when anything works, and nothing looks that ridiculous to me. Always happy to get polite constructive criticism.
New questions:
1) if I'm trying to collect the settings of DAQmx functions into a text file, how do I get it to return the string rather than the code for that string (e.g. for the sample clock, return the words "continuous samples" rather than a 6 digit code).
2) in the final output loop where the data is built into an array, how can I build the array such that it concatentates each buffer read vertically, rather than horizontally? I can do this for a 2D array, but not this 1D array. At the moment my data comes out concatenated horizontally. If I uncheck the "concatenate inputs" on the build array, it turns into a 2D array and stuff up the shift register.
3) I need to run this VI at 50kHz, and I'm having problems with buffer overwrites even at 10kHz with the sample read set anywhere between 1k and 10k per sec, is there something really inefficient about my program that would be causing this, or is it just down to my computer speed?
I'm attaching my code again, which is in the process of being fixed for comments 4 and 5.
Thanks again for the help,
Claire.
04-11-2009 10:43 AM
Hi CFJ,
1) use the "format into string" and wire that enum to an input terminal. You should anyway read the help for that function! Use some proper format strings like "%s" or "%d"! This way you can alose get rid of those new line constants etc - these all belong into the format string... When wiring the formentioned enum to the "format into string" use a "%s" format!
2) For a 1D array there is no vertical or horizontal - it has just one dimension. Concatenating will add new values add the end of the array...
3) I'm not an expert in DAQmx (yet, will change in the next months). But using your approach this will get problematic anyway as you build big arrays in the loop and so stress the memory management of LabView. Also calling this massive "Analog SW Trigger" in the loop will reduce maximum speed. Clean up, cleanup
Do only what is really needed in the 50kHz loop!
04-11-2009 02:15 PM
Hi Gerd,
Thanks for the reply.
Regarding the 1D array concatentation, I want it to place one sample array of 9 columns below the previous sample so that when I open the file in matlab there are only 9 columns (i.e. a vertical concatenation). The way it works at the moment, the array either gets horizontally concatenated (so there are 9 x #of sample collections), or goes becomes a 2D array.
Regarding (3) I really can't see anything that can come out of the while loop -ideas?
After reading some posts about producer/consumer architecture I'm thinking this might solve some problems with the overwriting. But, I can't figure out how to accommodate the waveform into that architecture - the examples all use doubles. Also, I'm not sure whether I should still initialise the storage array in the producer loop, or if this would go into the consumer loop?
Cheers,
Claire.
04-11-2009 03:32 PM
Hi Gerd, I've started a new thread with my latest problem because its deviated from the subject of my original post. I'd still be grateful for input from you. I've put in producer/consumer loops, but its not solving the overwrite problems 😞
Cheers,
Claire.
http://forums.ni.com/ni/board/message?board.id=170&thread.id=401208