08-27-2018 10:12 AM - edited 08-27-2018 10:16 AM
Hello All,
Looking to bounce some ideas around for logging from multiple data sources. Almost all of my LabVIEW development so far has only been working with DAQmx. It's been fairly straightforward, but now there's been a push for us to start using MODBUS over serial to log data that we are currently using analog input with a cDAQ. My DQMH app uses the recommended structure of a Data Acquisition module that acquires using DAQmx, and requests the Log Data module to, well, log data to a csv file. Pretty straightforward since the data is coming from a single source currently.
Working on a Serial/MODBUS Data Acquisition module that will read from the input registers of our instrument. The end goal is to log the cDAQ data with the data from the input registers to a single csv file. The sample rate for the two acquisitions would be at the same sample rate.
Two ideas that I have had while planning this out are:
I appreciate any advice or tips, I am open to ideas. Searching the forums I saw that there was people who are acquiring from multiple sources, but not much detail on the handling of the data.
Edit: If you think both of my approaches would be poor way to handle this, please let me know.
08-28-2018 01:33 AM
Hello Ryan,
please take a look at the diagramm I wrote. This is the way I handle the "multiple Sources to one LogFile" problem.
Saving the newest data from every Source to the MessageHandling Loop Shift Register. And when the Helper Loop sends the command to Log to File, Logging the newest data from every Source to file.
The Helper Loop is necessary. So the new Data Cases in the Message Handling Loop can run and dont pile up.
I am also thankfull for critics on my approach.
08-28-2018 03:10 AM
I like your approach, Marco. Just to speak put the obvious: The helper loop takes care of timing, right?
As to Ryan‘s question, I think there are many things to take into account. One single solution might not be able to cater to everybody‘s needs. Is it ok to miss out on samples (as only the newest ones are being logged)? What if sources have different sample counts (rates)? What if they need to be aligned by timestamp? How to deal with errors, gaps, delays, timeouts? One combined buffer or single buffers for each source?
I‘ve encountered various scenarios, so I‘d also be very much interested in others‘ opinions!
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
08-28-2018 08:07 AM
As Yoerg says, there are a lot of variables, but I tend to do what lichtenfield suggested. It seems pretty multipurpose and covers a lot of cases.
Sometime I would do an aggregator that collects data from multiple places and then coordinates and timestamps it before sending it on to be logged.
08-28-2018 11:30 AM - edited 08-28-2018 11:44 AM
Lichtenheld,
Appreciate the response. I like the idea of adding the helper loop to my logging module.
Some thoughts about that I had are:
Edit: Took a second look at the diagram. I see you have a request to log data which would route us through the EHL. A better solution would be to share the queue ref with the helper loop and direct the message straight to the MHL?
Once I plan out the module some more, I will update on how this solution works. I think it should work great for my application though.
08-29-2018 01:24 AM
08-29-2018
08:54 AM
- last edited on
03-27-2025
07:12 PM
by
Content Cleaner
I believe all the proposed solutions are good, I didn't see anything bad.
I would throw yet another option, that would be to have the helper loop do the save to file directly, this would ensure that the logging to data happens as soon as the timeout case executes and you don't have to worry about missing data. This means you need to figure out how to share the data to be logged between the MHL and the helper loop. One option would be to use the Current Value Table toolkit or a similar approach where all the data from the different sources are saved in an FGV table (this can be an array of clusters or a variant look-up table) and the helper loop just logs to file the current value for all the variables the logger receives.
Other considerations for Logging modules:
I hope that helps, regards,
Fab
08-29-2018 09:56 AM
Instead of a Helper Loop for timing, one can also use one of the data sources to trigger the logging. I often find I have one data source that is the "primary measurement", with other sources being "ancillary". Every primary measurement is saved, with the latest available ancillary data.
08-29-2018 10:12 AM - edited 08-29-2018 10:13 AM
@M.Lichtenheld wrote:
Hello Ryan,
you are right. To "miss" data is a intendet behaviour to separate acquisition rate and the logging rate. But, as Sam mentioned, there are surely ways to dont miss on data.
In my case the Log Data message is a priority message. At this point I dont really know why I set it to a priority message. But I dont think this is necessary when you use a helper loop(and you must use a helper loop!).
I also use the queue ref in the helper loop. Thats why the arrow goes from helper loop direct to the message handling loop. The "Request" on it is misleading.
As a tipp: I ran into several issues with memmory with this structure (see other post in DQMH forum from me). At the end it was due to a failure in the "Stop Module" Event from the helper loop. But it was hell to find that failure.
While you develop it is also a good idea to use a counter in EHL and MHL.
The combined number of Broadcasts from all sources shouldnt be higher then something arround 300 per second(less is better of course).
I don't think I will see anywhere near 300 broadcast per second, but I will make sure that I keep an eye on it.