LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with queues

Solved!
Go to solution

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 

Download All
0 Kudos
Message 1 of 11
(3,066 Views)
here is an example of how to read from a file to a graph I hope it helps you:
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Download All
Message 2 of 11
(3,059 Views)

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. 

0 Kudos
Message 3 of 11
(3,018 Views)
I think you may not have uploaded the version that you intended to provide.  Running Compare VIs on your two VIs shows only two minor differences.  Could you check that you've uploaded the right version, and explain more clearly the problem you're having?
Message 4 of 11
(3,002 Views)
You are correct.  Sorry about that.  Here is the correct version of the 2 source vi.
0 Kudos
Message 5 of 11
(2,984 Views)

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.

0 Kudos
Message 6 of 11
(2,982 Views)

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."

0 Kudos
Message 7 of 11
(2,977 Views)
The data output is what I want.  Basically my inputs are data frames of 78 bytes.  I'm storing them as ASCII characters so that its easier to look at the data files and see whats going on.  I convert from byte arrays to strings right before I print to the text file.  The idea is to have the stored data file look exactly like the data coming from the DAQ.  The values I'm saving aren't floating point values, they are unsigned 8 bit integers.  The data is later converted to floating point data in the consumer part of my VI.
0 Kudos
Message 8 of 11
(2,971 Views)

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. 

0 Kudos
Message 9 of 11
(2,966 Views)
Solution
Accepted by was1984

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.

Message Edited by nathand on 10-15-2009 05:19 PM
Message 10 of 11
(2,962 Views)