LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating an output file with several data streams

I first apologize for bad practices and inexperience, I'm not an engineer and everything I've learned is via YouTube, but there’s an issue I have with generating a file with timestamps and different input streams that I haven’t solved, and I’d appreciate any feedback.

 

Hardware:

  • PXIe-1071
  • PXIe-6341
  • BNC-2110

VI:

The VI is used to do two things:

  • To generate and control a stimulation train that moves a set of piezo actuators in front of a rodent and to record the order of the stimulation, i.e., which piezo was activated.
  • To record the speed at which a rodent is moving on a running disk connected to a rotary encoder.

To do this, used a flat sequence structure, in which I first stablish the order of the stimulation and then the rest of the code executes.

 

The aim:

To generate a single .lvm file which has a timestamp, the value of the TTL pulse and the instantaneous speed of the disk rotating.

 

The issues:

I can’t figure out how to generate a single file, since the sampling rates of the two are different; furthermore, I can’t get the timestamps to work, since the first column of the output file (which is supposed to have the time in the unit of seconds) is completely empty and the only way I can record time is adding comments, which is something I can convert, but I’d rather learn how to program better. Example of the output files are in liked as images (header excluded).

 

Output Speed.lvmOutput Speed.lvmOutput Synch.lvmOutput Synch.lvm

 

Ideas:

I had the suggestion of using a producer/consumer architecture, so that I would constantly be generating an updated file, but I’m still learning how to use those, but this is what I’m doing now.

 

At the moment, this VI works well enough to do what I want to do; but I want to solve these issues, since I will be recording more variables in the future, and while doable, I’d rather not generate nine different file and write custom scripts to take all of them, when I’m sure there’s a better alternative.

 

Any comments are greatly appreciated. 

 

0 Kudos
Message 1 of 5
(292 Views)

Good morning, @Fer2401.

 

     Thank you for attaching your LabVIEW code (as opposed to a "picture" of your code).  Hoever, as you are a fairly new member of the LabVIEW Community, you might not realize that many of the "old-timers" are not running the latest version of LabVIEW, and cannot open a VI saved in LabVIEW 2023 (or 2024, or 2022, for that matter).  However, doing a "Save for Previous Version" and specifying LabVIEW 2019 or 2021 will reach many more of us who would be more than willing to help.

 

     Some comments (since I can't see the code).

  • You mentioned a "flat sequence structure".  This is a Big Alarm Bell, as it suggests someone who does not understand the central idea behind LabVIEW, that of a "Data Flow" language, which (among other things) gives LabVIEW the ability to run tasks in parallel.  At the present time, I'm working on a routine to train small rodents to learn a "whisker discrimination task" -- if the texture they detect with their whiskers is "rough sandpaper", they can get a drop of water from a spout to the right, but if it is "smooth sandpaper", they need to "lick left".  I have a State Machine that runs this Training exercise, and calls on several other routines, running in their own loops (in parallel), to handle such tasks as detecting licks and telling the Main routine if it was the "correct", "wrong", or "no" lick (meaning that "time had run out" for the subject to make a choice), another loop that handled the selection of the rough or smooth target (a stepper motor was involved), and routines for generating separate data files (because the data were from asynchronous events).
  • For this task, I'm recording two data files.  One is the progression of the Training -- each time the State Machine goes from one State (say "Start Trial") to another ("Present Target"), I write the Time and the State to a file (so I know when something happens).  A second file that I call the "Lick" file records any time the Subject licks, and whether it is a "Right Lick", a "Left Lick", or "No Lick" (meaning "Time expired").
  • Each "data stream" goes (via its own Producer/Consumer design) to another parallel loop that simply appends the data to a file.  As the data rates are fairly low, and the amount of data is modest, I use Write Delimited Spreadsheet (which means I can also just look at the file with a Text editor, as well as process it in LabVIEW).

Bob Schor

0 Kudos
Message 2 of 5
(264 Views)

Hi Fer,

 


@Fer2401 wrote:

The aim:

To generate a single .lvm file which has a timestamp, the value of the TTL pulse and the instantaneous speed of the disk rotating.

 

Any comments are greatly appreciated. 


Instead of using LVM I recommend to write your data to a TDMS file. You can write the separate data into separate (channel) groups inside the file. Using waveforms you also write timestamps automatically…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(262 Views)

Thank you for both your recommendation and your comments, I've attached another version that I think it's for LabVIEW 2019. 

 

As for the rest for your comments, I have the impression that we're doing experiments with a few similarities, but mine is simpler. I did forgot to mention that based on comments by other, I'm (slowly) migrating this entire thing as a state machine and, from what I understand, trying to do a similar thing as you are. 

 

 

0 Kudos
Message 4 of 5
(245 Views)

Thanks for the idea about other types of files and using waveforms. I'll explore and see what works best. Thank you!

0 Kudos
Message 5 of 5
(241 Views)