LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do to make CVI save datas two times per day (at 07:00 AM and at 07:00 PM) ?

Hello everybody

I use CVI to control a pHmeter. I would like to save the value of the pH two times per day.

I use the function TimeStr and DateStr to plot the time and the date on the user's interface.

How can I use this functions to save my datas two times per day ? Maybe there is an another way. Please tell-me which one. Thanks
0 Kudos
Message 1 of 4
(2,958 Views)
Hi...

Unless there is a CVI or SDK function out there, you could use the GetSystemTime (hours,mins ,secs ); and either log the 24hr time format instead of the TimeStr format, or, use the hours from the GetSystemTime to determine if the time > 12 and add your own PM (or AM) to the timeStr.

There must be a function somewhere within the WinSDK that will allow you to return a string with the format you want. I shall go check,

Regards

Chris
Message 2 of 4
(2,958 Views)
Probably the simplest way to do this involves the use of timers. Do you need to record the value at EXACTLY 7:00:00 a.m. and p.m.?

I would create a timer on your uir and set the interval between 1 and 30 seconds, depending on how close to 7:00:00 you want it. I would choose the 30 seconds to reduce the burden on your system. Make sure it is Enabled. I assume you do not have any loops that your app would be stuck in for more than 30 seconds. Then in your timer callback, if you want to use TimeStr() you can compare the result to 7:00.

Perhaps something like this:

int CVICALLBACK MyTimerCB (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
char szTime[9];
static int nPMSearch = TRUE; // Keep track if betw
een 7am and 7 pm
static int nAMSearch = TRUE; // Keep track if before 7am
int nResult = 0;

szTime = TimeStr() // Get the time
if (nAMSearch == TRUE)
{
// We must be before 7:00 am
nResult = FindPattern (szTime, 0, -1, "7:00:", 0, 0);
if (nResult >=0)
{
// Must have found 7:00 am
nAMSearch = FALSE;
nPMmSearch = TRUE;
// Read the pH Here

// Write the pH to a file here

}
}

if (nPMSearch == TRUE)
{
nResult = FindPattern (szTime, 0, -1, "19:00:", 0, 0);
if (nResult >=0)
{
// Must have found 7:00 pm
nAMSearch = TRUE;
nPMSearch = FALSE;
// Read the pH Here

// Write the pH to a file here

}
return 0;
}

There are several ways to do this, but this is probably one of the simplest using the TimeStr() function. Hope this helps.
0 Kudos
Message 3 of 4
(2,958 Views)
I like the timer control idea, but with perhaps another idea within it. Each tick of the timer could make a call to the TimeStr call, and then after saving that string, you could do possibly a strcmp(timereturned, timewanted); If I remember correctly, this will return a 0 if the strings are equal. So you could put a check in the timer callback to check for a 0 value returned from the string compare, and then save your data if the condition is met.
0 Kudos
Message 4 of 4
(2,958 Views)