LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Data Logging to new .txt file after every 30mins

Solved!
Go to solution

Hi,

 

I have written a program that serial reads from arduino the Dallas DS18B20 two sensors data as well as the stepper motor position data. I ran my setup for 24 hours but end up having a 70GB .txt file which I cannot open easily. What i ask help here that if possible someone can help me with how can I generate a new .txt file after every 30mins. So my log files are still able to open easily by any test editor. 

Please find my .VI attached. 

Thanks.

 

0 Kudos
Message 1 of 16
(4,254 Views)

The simple way is to use the Elapsed Time express VI in the Timing palette.  When the time has passed, close your current file and create a new one.  If you dig into the File IO->Advanced File Functions, you will find a VI in there called Create File With Incrementing Suffix.  That will help keep unique file names.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 16
(4,239 Views)

thank for the reply.

 

I able to get new files but they are empty , i want my serial data captured it to be in it as well. is there any example to use this feature. Thanks. 

0 Kudos
Message 3 of 16
(4,237 Views)

Are you storing your file reference in a shift register?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 16
(4,235 Views)

First question, do you need to save that much data? Second thought would be if you do, you should be using a database and not files.

 

If you must use files that you need to open/close/create your file within your loop. In your current code you are opening the file outside your loop so you end up with  a single file. I would recommend that you look at using a state machine or a producer/consumer pattern for your application.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 16
(4,213 Views)

Hi,

 

No I guess, I am not familiar with this technique. please find in attachment the .VI i did, its incomplete coz i am not getting any idea how to use it in line with my codes. It runs but goes to False.

0 Kudos
Message 6 of 16
(4,189 Views)
Solution
Accepted by topic author awaisfarooqi

Hi awaisfarooqi,

 

I ran my setup for 24 hours but end up having a 70GB .txt file which I cannot open easily.

This is because you are constantly duplicating data (!) with that FeedbackNode inside the case structure.

And then you write that duplicated data to your file.

 

Stop duplicating the data to reduce the filesize!

 

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(4,186 Views)

I tried it but it only runs once, time stamp appears and other all in block diagram simulation i see error and data from serial port is not being read. 

0 Kudos
Message 8 of 16
(4,182 Views)

@awaisfarooqi wrote:

I tried it but it only runs once, time stamp appears and other all in block diagram simulation i see error and data from serial port is not being read. 


And what error are you seeing?

 

EDIT: Just looked at your last posted VI.  The FALSE case is completely empty.  So when your "Start Reading" control is FALSE, you a losing your reference to the serial port.  My recommendation is to just get rid of that control and case structure.  If data is coming in, you really need to be reading data from the port or you will get errors.

 

Additionally, you do not need any of those waits.  Even if you leave the case structure, just put the wait in the FALSE case.  The VISA Read waiting for data will limit your loop rate.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 16
(4,174 Views)

Hi awais,

 

time stamp appears and other all in block diagram simulation i see error and data from serial port is not being read. 

Which error did you receive?

Is there a problem with your serial port?

Can't you handle the serial port problems?

Do you need to wait for your device to send data (as I deleted the "Read" button and the case structure)?

Why does it only "run once"? The only stop condition is that stop button in the loop!

 

All I did was simplifying your VI to a reasonable state. Only YOU have the hardware connected to let your VI run and debug!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 16
(4,163 Views)