LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To start count from place where it stop before application has stoped

Hi,
I am making my first real application in labview8.2. Day by day this application is better and better. Last problem that I have is next:
My application is datalogging of 30 flow from flowmeters which give pulse output.
 
How can I use that application continue to count from last counter value that was before application has been stopped. (Clearly : if I start my vi it start to count from zero. I want that start from value which was before application was stooped before new start. In PLC world there are retentive counter which keep variable values in case of power off - I want to find something like that. I make my counter vi but can not to solve this problem . )
 
 
Thanks to anybody who help me
 
 
Emir
0 Kudos
Message 1 of 9
(2,551 Views)
Hi Emir,

when you stop your vi you should save it's actual state to a file (maybe by using config file functions from file palette?).
When you start your vi again you can load the data back from the file...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(2,538 Views)

Thanks, but I also must find last row in this file. This is so complicated. I think there is command like retentive flip flops or counter in PLC. Is there any example which show something similar and that can help me?

 

Thanks to anybody who answer me and help

 

Emir

0 Kudos
Message 3 of 9
(2,531 Views)


mujo wrote:
In PLC world there are retentive counter which keep variable values in case of power off - I want to find something like that. I make my counter vi but can not to solve this problem . )

In LabVIEW, there are Functional Globals that can be setup to retain count, but since you've mentionned "power off", then I would recommend writing that value to a file after every iteration.  You could have a special vi that has one input, the count value and writes it to file. 

Actually, how time-critical is this software?  A better implementation would be using the Producer Consumer loops, where the consumer loop could take care of logging the count value to file.  It would open the file and just update the value in parallel to the rest of the process.  Of course, you could do more with it, but that's beyond the scope of this question..  🙂

EDIT PORTION:
 
Just read your last post. 
So if I understand correctly, you want the count to be stored with the other data in the same file.  Then, you can still use the same approach using Producer/Consumer loops.  Now, as far as keeping track of the count, you can use Shift Registers.  If you do implement the Prod/Cons loops, then the shift register can keep track of the count value.  You could also use the Functional Global (do a search on it). 


Message Edited by JoeLabView on 11-14-2007 07:38 AM
0 Kudos
Message 4 of 9
(2,530 Views)
Hi Emir,

a PLC is a piece of hardware using some static RAM to keep values.
LabView is software - you have to save values in files and read them back when starting your application the next time.

Question: when you start excel, does it show the values from last work immediately or do you have to load the worksheet again?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 9
(2,523 Views)
Hi.
a PLC is a piece of hardware using some static RAM to keep values.
LabView is software - you have to save values in files and read them back when starting your application the next time.
 
I know that but they (PLC makers) make a command which automaticaly do that in PLC.
I think it is not so complicated (for people who develop Labview) and it could be also one block in Labview and my question was about that.
For me in phase of knowledge of Labview in which I am now it is complicated to fins last row in this file. Can anobody help me how to find the last row in txt file with actual state of counter?
Is there any file (example) which do that??
 
Emir
0 Kudos
Message 6 of 9
(2,511 Views)
Hi mujo,

when you use LV8+ "read text file" in "read lines" mode you get an array of strings with as many elements as you have lines in your file. Just use "array size" to get the number of lines and "index array" to get the last one...

For PLC:
It's not just hardware, it's a well defined fixed set of hardware! So when the PLC maker gives a command to store values permanently he knows the RAM size and address in advance.  There should be some static RAM built in and maybe a small battery powering this device in case of main power shut-off. You don't have all this in a standard PC! So your "command" to store values is "Write File" Smiley Wink (or config file functions, also in file palette).


Message Edited by GerdW on 11-14-2007 02:39 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(2,505 Views)

Hi Emir,

I have encountered your request before to preserve values through a power fail like  PLC. That feature is not in LabVIEW (yet Smiley Wink ).

Please post an example of of how you are writing the file and what you have tried so far.

One method to find the last "record" written to a file is to to repeatedly read records from the file, storing the read records in a shift register and monitoring the file read for an error code of "4" End of File. When the code sees the error 4, the previous record was the last value.

If that doesn't help, post your code and files so someone can help.

have fun!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 9
(2,504 Views)
Thanks to everybody who tried to help me. This forum was very useful for me. Thanks to National Instruments for this great forum.
I think I am close to solution of my problem.
 
My suggestion for developers of next generation of lab view:
 
Try to make block which automatically write data to some file on hard disk and also read last row of this file as initial setup (for example for counter or something similar).
 
Thanks
 
Emir
0 Kudos
Message 9 of 9
(2,481 Views)