10-17-2008 12:34 PM
10-20-2008 05:40 PM
hfmvdl,
I see where you are going with this code, but the implementation is very convoluted and I believe you will be missing a LOT of samples.
First, let's start simple. In your pxi vi, there is no point in having that sequence structure. Remove it. You also do not have to individually name each channel. Delete them, the build array, and the flatten vi. Right click on the 'channels' input of create virtual channel.vi, create constant, type 'PXISlot3ai0:7' Your code is looking better already.
Next, the actual data acquisition. Your timed loop is doing NOTHING for you here. I see that you are trying to track missed samples, but this is not the proper way to do it. I would read more than one sample at a time, lets say 100, and send that through the network variable, to be read from the client. You can send arrays over network variables, and there is also buffering(look at the properties of the variable).
On your host side, you shouldn't have to use dynamic data. When you say 'every 5ms show a sample', is this going to a graph? Reading those shared variables will take MUCH longer than 1ms to execute, why are you using shared variables here anyways(I see 4).
The main problem with this host is you have wait until mext ms multiple...so this means if it takes 4.5 seconds to execute(this code will take much longer than 1ms), it will take 5 seconds to read the next value in the buffer. Continue this, and after a while the buffer overflows, and you lose data.
There are a few other points, but try implementing the major changes (read N samples, send 2D arrays instead of single values one at a time, eliminate timed loop) and I can help you out more.
10-20-2008 05:42 PM
In addition, the data type should not matter, dbl is just fine for both the daqmx read and the TDMS write.
Good luck with this, and welcome 🙂
10-21-2008 03:15 PM
(from original poster 'tph', incorrectly logged in as 'hfmvdl' on first post)
Hi Rob, thank you very much for your answer.
On the host side, I used dynamic data because I could not wire an array of DBL to TDMS Write without it writing each set of data to one single channel sequentially. That is, instead of appending 1 value to each of 8 channels, 8 sequential values would be appended to a single channel. Coming from a MATLAB background, I would have expected something like a 'transpose 1D array' command would solve this problem, but converting to dynamic data was the only labview solution I could find. Do you know a better way to solve this?
Where it says 'every 5ms show a sample', the indicator is a graph, yes.
The local shared variables you see in the host vi (DAQ control, tdms file in, Stop Program, DAQ loop running) are used in other parts of the VI (for example, a user input event structure sets 'DAQ control'). This sounds like a really elementary question, but is there a quicker way to read/write to local variables in parallel loops (e.g. writing to a property node)?
Tom H
10-22-2008 04:34 PM
tph,
When you pass 2D arrays through your network variables, it should be easier to plot and save them, since the data will already be in rows and columns.
A faster way or calling variables would be using references. Right click on any control in the block diagram and select create->reference. These go through DMA rather than the stack, and should update faster. But you should still try and avoid using local variables/references as much as possible in your code by focusing on your data flow.
I'd be happy to help you out if you can post some more screenshots of your code. There are so many optimizations to be made from your original post.