Showing results for 
Search instead for 
Did you mean: 

record measurements

here is my problem I realize this program to record measurements on excel file  with 20ms as period of aquisition, at the beginning of the recording it work properly but after a few minutes it starts messing and the period is never the same.

could you help me please

0 Kudos
Message 1 of 5

Welcome back, Christine.  Congratulations on adopting the Consumer/Producer model for saving your Excel data.


If you go back and look at the example I posted on 19 May to your "Record Measurement in an Excel File" query, you will notice that the Excel code has three distinct sections -- opening Excel, a loop where data are written to Excel, and saving/closing Excel when the loop exits.  You have embedded the Save/Close within the writing loop.  Try moving everything inside your inner Case Statement to outside the loop, where it will be executed only once when everything closes.


Oops, I just noticed that you never stop your code!  I seem to recall that strange practice in your earlier post.  You need some condition (a Stop button, some condition on the data, or something) to tell the Producer (the lower loop) to stop putting data on the Queue, end its loop, and Release the Queue (allowing the Consumer to detect the released Queue and error-exit).


Why do you flush the Queue (in the Producer) right after you fill it?  Don't you want to put something into the Queue and let the Consumer take it off and write it to Excel?  Note that whoever gets the data first (the Consumer because it dequeues it or the Producer because it flushes the Queue) will "win", and since the loops are running independently and in parallel, you can't know which that will be.  This means that your data saving is of a "probabalistic" nature -- I don't know about you, but I want my data writing to be certain, not guesswork.


I don't understand the code involved with creating the file name for the Excel output file.  You are clearly trying to "solve a problem", but I cannot tell from looking at your code what that problem could be.  Perhaps if you said what you want to do (in your reply to this message) we could suggest something (else).


Bob Schor

0 Kudos
Message 2 of 5


I changed the code several times and I always still have something that doesn't work :'(

about the stop button, I want that when I run the code it starts the  acquisition and recording process and stops only if I stopped running, i didn't put a stop button because my program  depends on many other VI and other parallel loops if I put a button to stop the loop then I might stop recording while my program is still running, it is the same reason why I integrated recording in the loop because I don't have a stop condition,

you are right about the queue, for the file name I can change the method but I find that this works too 😉

( by the way if I eliminated the recording loop the problem persists ) 

thank you 🙂

0 Kudos
Message 3 of 5

knowing that I am using compact rio as acquisition module , maybe I should use its clock to have more precision?? but how??

 I have another question, may be seems stupid to experts 😛 , is that I should implement my VI under windows or under cRIO for such code??


0 Kudos
Message 4 of 5

BS Says:  There are no Stupid Questions -- there are only Less-than-Insightful People who refuse to Ask Questions when they don't understand something.


I don't have direct experience with cRIO, but I have used LabVIEW RT on other platforms (and have taken an RT class using cRIO).  One generally develops Real-Time Projects using LabVIEW Project, with code running on both the Host and the (RT) Remote.  In the case of data acquisition, you usually do want to run it on the Remote, and hence develop its code (within Project) for the Remote Target.  Remote Targets have much more precise clocks, and operating systems that "stay out of the way" of the Real-Time tasks (very much unlike Windows).  Where possible, you want to let the RT Task control the acquisition timing -- this is why you usually don't see "Time" functions within a DAQmx loop (the timing is done by the DAQ function itself).


I learned a lot by creating for myself the Sample Project "LabVIEW Real-Time Waveform Acquisition and Logging (NI-DAQmx).  I think there may be a version of this for cRIO, as well.  It shows, among other things, how you can use Messages between the Host and (cRIO) Remote to control when processes are started and stopped (you basically send a Stop "Message" and it stops the various parallel loops in an orderly fashion).


Generate an example for yourself and see if it has any techniques you can "borrow".


Bob Schor

0 Kudos
Message 5 of 5