LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a counter that keeps track of the total number of times a loop has run, even if LabVIEW has been restarted.

Solved!
Go to solution

Hi all,

 

I am writing a VI for measuring data and inserting it into a database. The measurements are controlled by a loop that runs once every minute. I want to give each measurement a unique id number and store this too in the database.

 

To do this, I want to add a counter to this loop so that I can count the number of times the loop has executed in total. This is, even if the VI, LabVIEW or even th PC is restarted, I want the counter to keep track of the number of executions. If say, the loope executes two times and then the VI is stopped and restarted, I want the following number on the counter to be three.

 

Does anyone have an idea about how to do this? I am gratefule for any help!

 

Clara

Message Edited by Clara G on 05-11-2010 08:21 AM
0 Kudos
Message 1 of 5
(3,923 Views)
If you already write that number to a database why not get the last one from the database after starting the program?
Message 2 of 5
(3,911 Views)
Solution
Accepted by topic author Clara G
A suggestion. Can you write the last counter value to a txt file and read it while again running the vi?
Message 3 of 5
(3,905 Views)

Not allowed to give away code but I can describe one of my "Totalizers" used to keep track of how much stuff has passed through a fliter so we know when to change it.

 

THe Total izer is implemented as an Action Engine.

 

It has three actions (methods)

 

1) Init - Opens an ini file and reads the last values read and cahces these in shift registers. It also inits a timer so we now how long since the last file I/O.

 

2) Update - Uses the data passed by the caller to update the totals. It also checks how long since the last save and if more than one minute it writes to the ini file (forced write).

 

3) Read - returns the totals for display and evealuating if a an alarm should be triggered to change the filter.

 

Note:

 

THe pre-LV 8.6 version of the ini file exposed methods to allow writing to the file. The new ini functions do not expose that functionality and require closing the file.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 5
(3,896 Views)

Thanks for all the advice.

 

I decided to go for the easiest solution I could think of: just writing to and reading from a txt file as muks suggested. The text file only contains this single value. It seems to work fine so far at least. Please see the attached VI.

 

I am sure that what ravis and Ben suggests would also work fine, but I went the option of  least effort. 🙂

 

Clara

0 Kudos
Message 5 of 5
(3,858 Views)