Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Conditional datatable


Makada May 27, 2017 08:34 AM

Hi,

Is it possible to have:

A datatable that shows the min and max temperature and timestamp from a one minute datatable running all Day. 

So lets say there Is a DataTable with one minute data running all Day,  the other table looks into that DataTable every minute to search for max and min temperature or other sensor and Their timestamp and stores it in this table and reset it daily.

So basically there Is only one piece of data in that table, the max Or min with Their timestamp.

Maybe someone can provide an example.

Thanks.


Makada May 27, 2017 01:16 PM

Can i use the code below, but instead of tempc^25 , Probably temp=max Or temp=min?

DataTable (Event,True,1000)
         DataEvent (30,TempC >25,TempC < =25,15) 
         Sample (1,TempC,FP2)
     EndTable


smile May 27, 2017 02:09 PM

Hi,

I do not think I have understood your request well, but I try!
However, you can extract fields from your daily record, save them in variables, and then make a datatable daily by sampling those numeric variables. example

"min_temp= TableName.Record(x,n)" Where x represents how many arrays go back to searching, n is the field to be copied

"time_temp_min=TableName.Record(x,n+1)"  While n + 1 is the field of the minimum time copied before, if the datatable source contains it! The time field in the minimum and maximum is an option.

Otherwise you can made another datatable with only the maximum and minimum with time, that  you need that run all day every minute.

You could also run a couple of IFs every minute with reset every day . Example

" IF temp > temp_ max then

temp_max=temp

time_temp_max=timestamp

endif

Before reset, call a datatale with the sample of those public

Maybe they are trivial suggestions, but I hope to help

Smile


Makada May 27, 2017 02:15 PM

Hi Smile,

Thanks for Your fast reply, will try tonight.

Wkr.

Mark


Makada May 27, 2017 02:50 PM

Hi Smile, You mentioned:

''Otherwise you can made another datatable with only the maximum and minimum with time, that  you need to run all day every minute.''

But with this datatable, that stores data every minute, it overwrites it yes? it stores the min and max from those seperate minutes instead of only when a min or max is recorded from other table?

"min_temp= TableName.Record(x,n)" Where x represents how many arrays go back to searching, n is the field to be copied

"time_temp_min=TableName.Record(x,n+1)"  While n + 1 is the field of the minimum time copied before, if the datatable source contains it! The time field in the minimum and maximum is an option.

you mentioned how many arrays to go back, but it starts at 0:00 and ends after 23:59, so im not sure about the amount of arrays. would that be 1440 arrays and reset with a reset function at 0:00?

this is what im after, you mentioned:

Otherwise you can made another datatable with only the maximum and minimum with time, that  you need that run all day every minute.

A datatable that writes data only when a max or min is recorded (running min and max) from the one minute daily table...idont want to see this data at the end of the day, but as it happens, every minute, running....


Makada May 27, 2017 05:25 PM

ive tried the if statement shown below, the Public Temp_Max is working, the Public Temp_Min isnt...

Public Temp
Public Temp_Max
Public Time_Temp_Max As String *100
Public Temp_Min
Public Time_Temp_Min As String *100

DataTable(TableOneMin,True,-1)
DataInterval(0,1,min,0)
Average(1,Temp,IEEE4,False)
FieldNames ("Temp")
Maximum(1,Temp,IEEE4,False,True)
FieldNames ("MaxTemp")
Minimum(1,Temp,IEEE4,False,True)
FieldNames ("MinTemp")
EndTable

BeginProg
Scan(1,Sec,1,0)
VoltDiff(Temp,1,mV2500,3,True,0,_60Hz,0.05,-65)

If Temp > Temp_Max Then
Temp_Max=Temp
Time_Temp_Max=status.timestamp
EndIf
If Temp < Temp_Min Then
Temp_Min=Temp
Time_Temp_Min=status.timestamp
EndIf

CallTable(TableOneMin)
NextScan
EndProg


smile May 27, 2017 09:59 PM

Hi Makada,

First of all sorry for a distraction I did not complete this line:

time_temp_max=timestamp

That was supposed to be:

time_temp_max=public.timestamp

But I've seen that you've solved anyway, with the status table!

.......

In summary

Suggestion 1

However, you can extract fields from your daily record, save them in variables, and then make a datatable daily by sampling those numeric variables. example

"min_temp= TableName.Record(x,n)" Where x represents how many arrays go back to searching, n is the field to be copied

"time_temp_min=TableName.Record(x,n+1)"  While n + 1 is the field of the minimum time copied before, if the datatable source contains it! The time field in the minimum and maximum is an option.

Clarifications on the first suggestion

"min_temp= TableName.Record(x,n)" Where x represents how many arrays go back to searching, n is the field to be copied

"time_temp_min=TableName.Record(x,n+1)"  While n + 1 is the field of the minimum time copied before, if the datatable source contains it! The time field in the minimum and maximum is an option.

you mentioned how many arrays to go back, but it starts at 0:00 and ends after 23:59, so im not sure about the amount of arrays. would that be 1440 arrays and reset with a reset function at 0:00?

I will be more precise

"min_temp= TableName.Record(x,n)" Where x represents how many arrays (or days) go back to searching, n is the field to be copied

for example 

"2016-09-11 00:00:00" 1 20,4 "2016-09-10 14:09:20" 11,69 "2016-09-10 06:10:20" 15,17 13,11 22,13 "2016-09-10 13:51:20" 
"2016-09-12 00:00:00" 2 20,77 "2016-09-11 12:51:10" 12,02 "2016-09-11 03:06:40" 15,28 13,28 22,7 "2016-09-11 12:50:20" 
"2016-09-13 00:00:00" 3 20,7 "2016-09-12 14:47:40" 12,13 "2016-09-12 05:56:50" 15,39 13,21 22,32 "2016-09-12 14:46:10" 
"2016-09-14 00:00:00" 4 20,6 "2016-09-13 12:36:00" 12,33 "2016-09-13 05:52:40" 15,18 12,7 22,29 "2016-09-13 12:37:00" 
"2016-09-15 00:00:00" 5 20,7 "2016-09-14 13:33:30" 11,99 "2016-09-14 06:05:40" 15,39 14,37 22,63 "2016-09-14 14:11:40" 

Imagine that each row is a day, that you can select with the "x" and each column are the fields you can draw with the value "n"

Suggestion 2

Otherwise you can made another datatable with only the maximum and minimum with time, that  you need that run all day every minute.

From your previous message

''Otherwise you can made another datatable with only the maximum and minimum with time, that  you need to run all day every minute.''

But with this datatable, that stores data every minute, it overwrites it yes? it stores the min and max from those seperate minutes instead of only when a min or max is recorded from other table?

I will be more precise

Otherwise you can made another daily datatable with only the maximum and minimum with time, that  you need to call all day every minute, like temp measurements, this table will produce maximum with time and the minimum with time.

Suggestion 3

You could also run a couple of IFs every minute with reset every day . Example

" IF temp > temp_ max then

temp_max=temp

time_temp_max=timestamp

endif

Before reset, call a datatale with the sample of those public

I modified your text for what I think as my third suggestion.

Public Temp
Public Temp_Max
Public Time_temp_Max As String *100
Public Temp_Min
Public Time_Temp_Min As String *100

DataTable(MaxMin_daily,True,-1)
DataInterval(0,1440,min,0)

Average(1,Temp,IEEE4,False)
FieldNames ("Temp")
Sample (1,Temp_Max,IEEE4,False)
FieldNames ("MaxTemp")
Sample (1,Time_temp_Max,IEEE4,False)
FieldNames ("timeMaxTemp")

Sample (1,Temp_Min,IEEE4,False)
FieldNames ("MinTemp")
Sample (1,Time_Temp_Min,IEEE4,False)
FieldNames ("timeMinTemp")
EndTable

BeginProg
Scan(1,Sec,1,0)
VoltDiff(Temp,1,mV2500,3,True,0,_60Hz,0.05,-65)

If Temp > Temp_Max Then
Temp_Max=Temp
Time_temp_Max=status.timestamp
EndIf
If Temp < Temp_Min Then
Temp_Min=Temp
Time_Temp_Min=status.timestamp
EndIf

CallTable(MaxMin_daily)
If IfTime(0,1440,min) Then '
Temp_Max = -100
Time_temp_Max = "NAN"
Temp_Min = 100
Time_Temp_Min= "NAN"
EndIf
NextScan
EndProg

I did not run it, but in compiling it does not make any error.
Basically every day or how you put the intervals in minutes, it stores average, maximum with time and the minimum with time.

In reality it would be the same of this (which is also my second suggestion):

Public Temp

DataTable(MaxMin_daily,True,-1)
DataInterval(0,1440,min,0)
Average(1,Temp,IEEE4,False)
FieldNames ("Temp_avg")
Maximum(1,Temp,IEEE4,False,True)
FieldNames ("MaxTemp")
FieldNames ("timeMaxTemp")
Minimum(1,Temp,IEEE4,False,True)
FieldNames ("MinTemp")
FieldNames ("timeMinTemp")
EndTable


BeginProg
Scan(1,Sec,1,0)
VoltDiff(Temp,1,mV2500,3,True,0,_60Hz,0.05,-65)

CallTable(MaxMin_daily)

NextScan
EndProg

But in the numeric You will not have the situation that updates, second after second.

You have only the result in datatable at the end of the day.

.........I hope I have not complicated the situation!

Smile


Makada May 27, 2017 10:13 PM

Hi Smile,

thanks for the input.

i still dont understand why the ''Public Temp_Max'' is working fine, but the ''Public Temp_Min'' isnt.

Its showing zero and the ''Public Time_Temp_Min'' field is empty...


smile May 28, 2017 06:05 AM

Probabile at begin temp_min is zero and never temp measure minus zero. So at begin and every reset put temp_min = 100. See my reset example

Smile


Makada May 28, 2017 07:04 AM

Like so?

Temp_Min=100
If Temp < Temp_Min Then
Temp_Min=Temp
Time_Temp_Min=status.timestamp

Now it Just updates every second, doesn 't hold the min temperature. 

Sorry, my crbasic skills are near zero.....:(


smile May 28, 2017 07:31 AM

Every day at midnight

If IfTime(0,1440,min) Then '
Temp_Max = -100
Time_temp_Max = "NAN"
Temp_Min = 100
Time_Temp_Min= "NAN"
EndIf

and at the begin

........

BeginProg

Temp_Max = -100
Time_temp_Max = "NAN"
Temp_Min = 100
Time_Temp_Min= "NAN"

Scan(1,Sec,1,0)

..........

In the area between beginprog and scan, it only goes to the first scan and then it does not pass, never until the next reprogramming or compilation.

Smile


Makada May 28, 2017 08:34 AM

Hi Smile,

Its working now.

The only thing is that the time of min temp and max temp is shown like this:

10:31:50:02

:02 after the seconds.

i probably need to change the ''As String *100'' to another value?


smile May 28, 2017 08:58 AM

If you want to remove some digits you must use the splitstr function and clean the string as desired.

It's not a size problem (ie > 100).

The logger begins scanning at 00 sec but when it comes to the IF statement, it has elapsed some time and then it prints this fraction of second.

Smile

Log in or register to post/reply in the forum.