07-06-2016 06:09 PM
Hello,
I am currently writing a script to acquire data using a DAQ deivce. I want my script to acquire voltage data from two different channels, concatenate the arrays, then write them to a binary file. I am running into trouble when I attempt to add an elapsed time stamp to the end of the file for reference of how long the data was acquired for. How do I append this final value to its own line in the file? I have attached my script. please let me know
thanks,
mmoon
07-06-2016 07:17 PM - edited 07-06-2016 07:17 PM
What do you mean by "trouble"? Are you getting an error? What do you mean by "its own line". It's a binary file it doesn't have lines. Maybe you mean a text file?
07-06-2016 08:17 PM
Code-wise, I do not see anything wrong with how you are writing the data. How do you know it is incorrect? I did not see anything in there for reading the data.
Though, a better route would be to write your data to a TDMS file. In fact, DAQmx can do almost all of your file writing by using the DAQmx Configure Logging VI. You can then add your elapsed time to the file by writing it to a property of the group that you wrote your data to.
07-07-2016 11:14 AM
I am also writing a python script that will read in all of the data and i'm not seeing the elapsed time value.
Crossrulz, here is my new version of the code so far. I am pretty confused about how to add the elapsed time to the file. Could you possibly show me an example of how to do so
thanks
Moon
07-07-2016
11:29 AM
- last edited on
05-13-2025
04:46 PM
by
Content Cleaner
I don't use TDMS myself, but here is a very informative NI White Paper on it that (among other things) discusses TDMS logging and DAQmx. Incidentally, I'm very puzzled why you force the output of the DAQmx Read into a pair of Dynamic Wires (note the angry red Coercion dots!) and then combine the two (identical?) signals for the Waveform Chart. Looks very wrong to me ...
Bob Schor
07-07-2016 11:37 AM
Thanks for the reference paper, I will take a look at it.
For the DAQmx read poor arrangement, do you have any suggestions to clean this part of my code up? I want that section to output two separate voltage readings on to 1 waveform chart continusously during reading
07-07-2016 12:34 PM
It's really a piece of cake (un morceau du gateau). I didn't have a DAQ device handy, so I created a Simulated USB-6009, and created a Task to take data from two Analog inputs continuously at 500 Hz, 500 points. Here's the VI:
Note that I could have simply used the "known" number of points/channel, but the Property node means I don't need to worry if the Task changes. Note that the 1D Waveform is exactly the right form for a 2-channel Waveform Chart! No muss, no fuss.
Bob Schor
07-07-2016 08:46 PM - edited 07-07-2016 08:47 PM
@Mmoon wrote:Crossrulz, here is my new version of the code so far. I am pretty confused about how to add the elapsed time to the file. Could you possibly show me an example of how to do so
Something like this. Notice that I did some other simplifications to the code as well, like get rid of the unneeded sequence structure.
