LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data logging time stamp and the delay in stopping of the operation

Solved!
Go to solution

Hello everyone

 

I am using Labview 2012 for my master thesis. I am supposed to develop a SCADA simulation model of a wastewater treatment plant. As one part of my task, I should log every single measured values from the sensors in the plant and saving them to an excel sheet.

 

For this purpose, I used my own codes to save the measured values to an excel sheet. I used “wait until next ms” block with a 3000 constant value connected to it, in order to create a 3 seconds time stamps for the logged data. So, I used a separated While loop for data logging which gets updated every 3 seconds and a separated While loop for the main application which gets updated every 700ms.

 

However, the problem is that I use just one Start/Stop button for the whole operation and when I want to stop the application, it takes about 3 seconds to be stopped. It definitely gets worse when I want to have a longer time stamps for the data logging.

I would like to make the stopping operation faster. Could you please tell me how can I use the delay blocks in the way that doesn’t have any influences on stopping operation?

 

I could use one Stop button for stopping every while loop, but I really would like to have one Stop button for the whole operation. I should mention this point that it is not possible to use DSC module’s data logging feature as we do not have any shared variables connected to OPC server.    

 

Thank you very much for your help in advance. 🙂

0 Kudos
Message 1 of 9
(3,305 Views)
Solution
Accepted by topic author Iman1988

Hi Iman1988.

 

It sounds like your overall structure is pretty good.

What you can do in the logging loop is to let it run just as fast as the other loops, it could be every 100ms.

Then add some logic, that in every iteration asks if 3 seconds has passed => if so, log data - if not, skip data.

 

You can use the function called Elapsed Time. This function return a boolean when the preset time has passed.

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
0 Kudos
Message 2 of 9
(3,293 Views)

You should learn about State Machines. In a properly programmed state machine it is easy to stop/abort and ongoing operation.

 

However there is another simple solution: in your Data logging while loop, set the “wait until next ms” to for example 200 msec.

3000/200=15, so what you only need to keep tracking is the iteration number, and using a modulo devision you can set a CASE structure to False or True. And put your data logging in your True case.

0 Kudos
Message 3 of 9
(3,284 Views)

@Blokk wrote:

 

However there is another simple solution: in your Data logging while loop, set the “wait until next ms” to for example 200 msec.

3000/200=15, so what you only need to keep tracking is the iteration number, and using a modulo devision you can set a CASE structure to False or True. And put your data logging in your True case.


You have to be a little careful with using the iteration terminal - it's an I32 and when it reaches the maximum, it will just stop counting rather than roll over. This means after running for an extended duration that your code will stop running properly. The solution is to use an incrementing U32 on a shift register and correctly handle the roll over.

 

I'm sure it's probably fine in this case (you can calculate how long it will run correctly for) but something to be aware of if you're using the iteration terminal in a fast running loop!


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 4 of 9
(3,279 Views)

Good point! Or it is often handy to use the "Increment PtByPt.vi" from the Signal Processing palette. Also using an U32 shift register, and the main block diagram stays clean 🙂

Message 5 of 9
(3,270 Views)

hmm, if a loop has one iteration per 1 second, then the problem with I32 type will start to happen after:

2^31/3600/24 = 24 855.13 Days? Is this calculation correct??

 

Actually as I remembered, in ANSI C for example when a I32 overflows, it will just start to count from the "minus end", -2^31. Why is it different in LV?

0 Kudos
Message 6 of 9
(3,260 Views)

Like I said - it's not a problem if you're running your loops on the order of seconds - but if you're doing fast running loops on an FPGA then it can definitely be a problem! (Particularly if you're program is being used for extended operation)

 

Yes, LabVIEW will roll over if you increment an I32 past it's maximum value BUT specifically the iteration terminal on loops does not rollover, it just stops on the maximum value.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 9
(3,251 Views)
ok, clear!
0 Kudos
Message 8 of 9
(3,245 Views)

@A.E.P

Thank you very much for your suggestion.

 

Vey good to know Elapsed time function. 🙂

I´changed my application accordingly and now it works as fast and as well as how I wanted. 

 

 

@others:

 

I also appreciate you guys for your helps and comments. 🙂 

0 Kudos
Message 9 of 9
(3,224 Views)