Remember (or Learn for the First Time) the Principle of Data Flow. When you have a Loop, every function inside the loop needs to run before the Loop can "loop". I don't know what you mean by "the sample timer", but suppose you have a Wait function with some time T (seconds) wired to it, and you also have a DAQmx Read Function that reads N samples at a rate of S Samples/sec. The two run independently. The Wait takes T seconds, the DAQmx Read Function requires N/S sec. Which determines the loop speed? It takes at least T and N/S sec, so it will be dominated by the slower of the two. For this reason, you should (almost never) have a Wait statement inside a DAQ loop (it just "wastes time" and potentially cause you to miss samples).
Usually you grab a bunch of samples at once, e.g. 100, that way it can loop 100 times slower than the sample rate. You should as mentioned not try to match this speed with a Wait, but simple wire '100' to the number of samples to grab.
I'd like to run in continuous mode and collect samples at a user defined rate. Although i define the sample rate using the SampleClock.vi the loop is not controlled by this function.
How i thought this would work is that i'd set the sample rate with SampleClock.vi and that would control the capture rate of the DAQmx Read.vi. The overall loop time would be controlled based on the READ vi finishing it's action. I'm running these functions in a state machine, where the data is a 1D array, i use the BUILD array function to create a "time" column, where it is the value of the summed loop times from a shift register.
It all works except it doesn't seem to matter what i put in for the sample rate, it all runs at the same time.
Can you post your code, preferably saved back to an older version so more people can open it? (Offhand, I'd recommend 2014 or so).
Note: you should definitely *NOT* generate your time array by measuring loop iteration times in software! Take advantage of your super-regular hardware acquisition clock. Either use the waveform out version of DAQmx Read and extract the "dt" field or query the "sample rate" property using a DAQmx Timing property node. These are a much better measure of the actual time between samples.
Ok, i found and am using the 'Get Waveform Components' function to see the t0 timestamp, the dt sampling rate and the Y data. This is great however...I cant get the timestamp (t0) data converted to a DBL to save it to a spreadsheet. The thought being i can just format the column for MM/DD/YYYY hh:mm:ss.00
I have searched this all over the net, there is a ton of information however none that explains this, or at least i couldn't find it. Can any of you point me to an example that will convert the (t0) timestamp to a usable format for excel?
I have done this with TDMS before, that will require significant re-coding...hopefully there is a better way out there.
simple as this:
I'd like to run in continuous mode and collect samples at a user defined rate.
Go to Find Examples, open the Voltage (with Events) - Continuous Input example. Look at the code.
The event structure runs at the Sample per Loop Interval exactly, no polling, not timers, etc. Easy to implement into an event based state machine, like the JKI.
converting to a string is ok but i would then like to build it into the 2D data array to write to spreadsheet. Converting to a DBL doesn't seem to work, is there a better way?
you can convert the LabVIEW timestamp to an Excel timestamp entity and append that to your 2D array. Then you just need to format the corresponding column in Excel to display timestamps…
There are several threads on this topic, like this. (Keep in mind possible problems due to timezones, DST, …)