10-14-2009 05:36 PM
Hi,
I'm still very new with Labview, and I'm trying to do something that seems pretty complicated to me. I've already implemented some code that collects data from a DAQ and plots it. Another thing this does is save the data coming off the DAQ. I'm now trying to add functionality to give the user the option of running from the DAQ or from a saved file, and I'm having lots of trouble. My queue still works when I choose to run an acquisition, but it doesn't work when I try to open the saved file. I've attached both the original code and what I'm trying to do.
I'm not attached to the method that I picked to choose between acquiring and playing back data, so if there is a better way (and I'm certain there is) please let me know.
Thanks,
Anthony
Solved! Go to Solution.
10-14-2009 06:06 PM
10-15-2009 12:47 PM
Hi,
Thanks for your assistance. Unfortunately that file is made with a newer version of Labview than I have. Also, I'm not sure, but does that file address the issue of multiple sources (file or DAQ) for inputting data? I already am saving data in the raw 8 bit format that I have coming from the DAQ and I'm pretty happy with that.
10-15-2009 02:50 PM
10-15-2009 03:39 PM
10-15-2009 03:42 PM
The problem I'm having is that this code works when I select "acquisiton" but does not work correctly when I select "playback."
The way I've implemented the choice is by using case blocks and executing the DAQ data gathering when in true (acqusition) mode, and executing the text file read when in false (playback) mode. The text file write is also disabled while in playback mode.
The code works correctly in acqusition mode, but nothing happens when in playback mode. I've determined that no data actually reaches the consumer while in playback mode, but I can't figure out why. Thats what I'm trying to understand.
I'd also be interested in learning a better way to do this selection between two data sources if there is one.
10-15-2009 03:53 PM
Have you looked at your data file at all? You're writing binary data to a text file. Your types mismatch, causing you to lose data - you're implicitly converting floating point values to unsigned 8bit integers. You want to use the "array to spreadsheet string" and "spreadsheet string to array" functions, or the other number-to-string formatting functions, to write and read your data. Take a look at the LabVIEW examples "Write to Text File" and "Read from Text File."
10-15-2009 04:02 PM
10-15-2009 04:06 PM
Also, the hardware includes intrinsic support for this idea of storing the data as ASCII characters. The microcontroller that feeds the data adds 32 to each byte of output to put all the symbols in the ascii character range. Thats why I subtract 32 in my VI. The data coming out of the text files is exactly the same as the data coming out of the DAQ. I've verified this in debugging mode.
My issue seems to have something to do with transmitting between the producer and consumer.
10-15-2009 04:16 PM - edited 10-15-2009 04:19 PM
Thanks for the explanation of your data types. I'd still recommend that you try to be consistent about your data types; if you never use any floating point values, then change your constant representations and eliminate the orange wires. Also, I still think your problem is somewhere in the way you're reading your data. Correct me if I'm wrong, but it looks like when you read the data from the DAQ card it's an I32, but when you read it from your file it's a U8 (implicitly converted to an I32). Then you divide that value by 256, which works fine for the I32 from the DAQ card, but produces only 0s for the U8 values read from the file (the maximum of value of a U8 is 255, so dividing produces a values less than 1, which gets cut off to 0 when you convert to U8 before subtracting 32 and sending it to the queue).
EDIT: also, be careful using the text file functions for binary data, even if you think it's all ASCII. You have the "Convert EOL" option checked, which means that LabVIEW may modify, insert, or delete values that match the ASCII code for an End Of Line character. Consider using the binary file functions instead.