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.

24 Hour Running Max/Min


texagg98 Feb 3, 2017 04:37 PM

I have some environmental chambers running a cyclical temperature routine.  We are recording the output of eight thermocouples once a minute and that portion (as well as daily max and min) is working fine.

Our operations people would like to see the max & min temperatures for each chamber for the last 24 hours, rather than on a daily basis.  I can't seem to find any means to compute a max or min directly, without going to a data table.   

I've been looking at the code posted here and in the blogs on how to address data in tables, but looping through 1440 readings for each of eight sensors seems like a brute force approach to solving what should be a rather simple problem.

Going from some of the examples here, this is the snippet that I'm trying to make work, if I can't find a more elegant and simpler solution to the problem:

 For I=1 To 8
For J = 1 To 1440
If RoomData.Temp_C(I,J)>Tmax(I) Then Tmax(I)=RoomData.Temp_C(I,J)
If RoomData.Temp_C(I,J)<Tmin(I) Then Tmin(I)=RoomData.Temp_C(I,J)
Next J
Next I
<tmin(i) then="" tmin(i)="RoomData.Temp_C(I)(1,J)" next="" j="" i<="" pre="">

 

Any suggestions on how to simplify the solution would be most welcome.

Many Thanks!


nsw Feb 8, 2017 11:53 AM

I am not completely sure what you are after here, but the following may help.

Have a look in CRBasic at "MaxSpa" and "MinSpa" instructions. These will look through an array variable and find the max or min from it, plus its location in the array. If you maintain an array in your program with the last 24 hours of 1min readings, you will have the current max and min of the last 24 hours in this variable.

Alternatively, if you are looking for say at 9am every day the last 24 hours max and min, then all you need to do is have another output table and in the DataInterval instruction  and use the usual Maximum and Minimum instructions in the table :-

DataInterval (9,24,Hr,10)


texagg98 Feb 8, 2017 03:13 PM

I think the second option will work to get us off the ground, but the first option is what they really want.

I hadn't seen MaxSpa or MinSpa mentioned before so I think that will do what I need it to.  I will try to pull data via GetRecord and use Max/MinSpa and see if that works.


nsw Feb 8, 2017 04:24 PM

Understood regarding the second option.

For the first option, its very easy to keep an array of 1440 size with the 1min values over 24 hours.

Make a Public variable with array 1440. In the program, use the Move to shift down the last 1439 values down one element in the array, then write the latest 1min value to the first element of the array. An example as follows :-

Public Min1440(1440)
Public Min1
Public Min1440Max(2), Min1440Min(2)

'Main Program
BeginProg
 Scan (1,Sec,0,0)
  PanelTemp (PTemp,250)
  Battery (batt_volt)
  'Measure or get the value in to variable "Min1"
  Move (Min1440(2),1439,Min1440(1),1439)
  Min1440(1) = Min1
  MaxSpa (Min1440Max,1440,Min1440(1))
  MinSpa (Min1440Min,1440,Min1440(1))


texagg98 Feb 8, 2017 04:29 PM

I think I see how this works, but from what I can tell, this will be the maximum reading among all eight sensors over the last 24 hours.  I need an individual max/min for each sensor.


nsw Feb 9, 2017 09:51 AM

Not quite. This is just for one variable that you want to get the max/min from over the 24 hours. You will need to repeat this for each of the 8 off temperature variables you have.

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