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.

Timestamp max


Makada Oct 12, 2016 04:59 PM

Hi all,

id like to have the time displayed when the ''Public WS_10_max'' reach a maximum.

i can set to show the time the max happened, but thats updated only every 10 minutes from the 10 minutes table. (Maximum (1,WindSpd,FP2,False,True)

when a max is reached in the Public WS_10_max field, the time is shown after 10 minutes instead of immediately...

below is my program:

 

'CR1000 Series Datalogger
'Wind gust programming example using the mierij meteo wind monitor
'Date: August 2014   
'Program author: Campbell Scientific Canada
'Declare Public Variables for mierij meteo Wind Speed / Direction sensor
Public WindSpd
Public WindDir
Public WS_10_max
Public WS_Gust
Public WS_Gust_dir


'Declare Variable Units
Units WindSpd = km/u
Units WindDir = degrees
Units WS_Gust = km/u
Units WS_Gust_dir = degrees
'Define Output Data Tables


DataTable (TenMinute,1,1000)
  DataInterval (0,10,Min,10)
  WindVector (1,WindSpd,WindDir,FP2,False,0,0,0)
  FieldNames ("WindSpd_AVG:Deg,WindDir_AVG:Deg,WindDir_STDEV:Deg")
  Minimum (1,WindSpd,FP2,False,False)
  Maximum (1,WindSpd,FP2,False,True)
  SampleMaxMin (1,WindDir,FP2,False)
  Maximum (1,WS_Gust,FP2,False,True)
  SampleMaxMin (1,WS_Gust_dir,FP2,False)
  EndTable
 
'Main Program
BeginProg  
  Scan (1,Sec,0,0)
    '----------- Measure 05103-10 Wind Speed & Direction Sensor ----------
   
'Generic 4-20 mA Input measurement WindSpd
VoltDiff(WindSpd,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic 4-20 mA Input measurement WindDir
VoltDiff(WindDir,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
    If WindDir>=360 Then WindDir=0
   
    'Program code for outputting wind gust data as per EC MSC guidelines
   
            If  TimeIntoInterval(0,10,Min) Then
            WS_10_max = 0
            WS_Gust = 0
            WS_Gust_dir = 0
           
    EndIf
   
              
    'Call Output Data Table
        CallTable TenMinute
        NextScan
        EndProg


smile Oct 13, 2016 08:17 PM

Hello

This is a logic:

1) creates two new public loc "ws_gust_inst" and "time_ws_gust_inst"

2) after measure, every scan:

if ws> ws_gust then

ws_gust=ws

time_ws_gust=timestamp

endif

if iftime (0,10,min) then

ws_gust=0

time_ws_gust=0

endif

.............

could you fix it so

Smile


Makada Oct 14, 2016 07:06 PM

Sorry no, i got an error saying: undeclared variable timestamp

'CR1000 Series Datalogger
'Wind gust programming example using the RM Young 05013-10 wind monitor
'Date: August 2014   
'Program author: Campbell Scientific Canada
'Declare Public Variables for 05103-10-L Wind Speed / Direction sensor
Public WindSpd
Public WindDir
Public WS_10_max
Public WS_Gust
Public WS_Gust_dir
Public ws_gust_inst
Public time_ws_gust_inst
'Declare Variable Units
Units WindSpd = km/u
Units WindDir = degrees
Units WS_Gust = km/u
Units WS_Gust_dir = degrees
'Define Output Data Tables
DataTable (TenMinute,1,1000)
  DataInterval (0,10,Min,10)
  WindVector (1,WindSpd,WindDir,FP2,False,0,0,0)
  FieldNames ("WindSpd_AVG:Deg,WindDir_AVG:Deg,WindDir_STDEV:Deg")
  Minimum (1,WindSpd,FP2,False,False)
  Maximum (1,WindSpd,FP2,False,True)
  SampleMaxMin (1,WindDir,FP2,False)
  Maximum (1,WS_Gust,FP2,False,True)
  SampleMaxMin (1,WS_Gust_dir,FP2,False)
 
  EndTable
 
'Main Program
BeginProg  
  Scan (1,Sec,0,0)
    '----------- Measure 05103-10 Wind Speed & Direction Sensor ----------
   
'Generic 4-20 mA Input measurement WindSpd
VoltDiff(WindSpd,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic 4-20 mA Input measurement WindDir
VoltDiff(WindDir,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
    If WindDir>=360 Then WindDir=0
   
    'Program code for outputting wind gust data as per EC MSC guidelines
   
            If  TimeIntoInterval(0,10,Min) Then
            WS_10_max = 0
            WS_Gust = 0
            WS_Gust_dir = 0
           
    EndIf
   
If WindSpd> WS_Gust Then
WS_Gust=WindSpd
time_ws_gust_inst=timestamp
EndIf
If IfTime (0,10,min) Then
ws_gust=0
time_ws_gust_inst=0
endif
              
    'Call Output Data Table
        CallTable TenMinute
        NextScan
        EndProg
              


smile Oct 15, 2016 06:26 AM

Hello

Sorry, Review so

Public time_ws_gust_inst as string *100

and

time_ws_gust_inst=status.timestamp

Sorry again but in a hurry I just described an idea, so sounds about right.

Let me know

Smile


Makada Oct 15, 2016 09:08 AM

Ok thanks, Will have a look tonight. 


Makada Oct 15, 2016 05:45 PM

Sorry no, 2 errors:

Variable illegal in Parameter: Public time_ws_gust_inst=status.timestamp

Variable initialization of: Public time_ws_gust_inst=status.timestamp

or did i use it the wrong way in my program below?

'CR1000 Series Datalogger
'Wind gust programming example using the RM Young 05013-10 wind monitor
'Date: August 2014   
'Program author: Campbell Scientific Canada
'Declare Public Variables for 05103-10-L Wind Speed / Direction sensor
Public WindSpd
Public WindDir
Public WS_10_max
Public WS_Gust
Public WS_Gust_dir
Public ws_gust_inst
Public time_ws_gust_inst As String *100
Public time_ws_gust_inst=status.timestamp
'Declare Variable Units
Units WindSpd = km/u
Units WindDir = degrees
Units WS_Gust = km/u
Units WS_Gust_dir = degrees
'Define Output Data Tables
DataTable (TenMinute,1,1000)
  DataInterval (0,10,Min,10)
  WindVector (1,WindSpd,WindDir,FP2,False,0,0,0)
  FieldNames ("WindSpd_AVG:Deg,WindDir_AVG:Deg,WindDir_STDEV:Deg")
  Minimum (1,WindSpd,FP2,False,False)
  Maximum (1,WindSpd,FP2,False,True)
  SampleMaxMin (1,WindDir,FP2,False)
  Maximum (1,WS_Gust,FP2,False,True)
  SampleMaxMin (1,WS_Gust_dir,FP2,False)
 
  EndTable
 
'Main Program
BeginProg  
  Scan (1,Sec,0,0)
    '----------- Measure 05103-10 Wind Speed & Direction Sensor ----------
   
'Generic 4-20 mA Input measurement WindSpd
VoltDiff(WindSpd,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic 4-20 mA Input measurement WindDir
VoltDiff(WindDir,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
    If WindDir>=360 Then WindDir=0
   
    'Program code for outputting wind gust data as per EC MSC guidelines
   
            If  TimeIntoInterval(0,10,Min) Then
            WS_10_max = 0
            WS_Gust = 0
            WS_Gust_dir = 0
           
    EndIf
   
If WindSpd> WS_Gust Then
WS_Gust=WindSpd
time_ws_gust_inst=timestamp
EndIf
If IfTime (0,10,min) Then
ws_gust=0
time_ws_gust_inst=0
endif
              
    'Call Output Data Table
        CallTable TenMinute
        NextScan
        EndProg


smile Oct 15, 2016 08:26 PM

Hi

so maybe I'll be more clear

Regards

Smile

'CR1000 Series Datalogger
'Wind gust programming example using the RM Young 05013-10 wind monitor
'Date: August 2014
'Program author: Campbell Scientific Canada
'Declare Public Variables for 05103-10-L Wind Speed / Direction sensor
Public WindSpd
Public WindDir
Public WS_10_max
Public WS_Gust
Public WS_Gust_dir
Public ws_gust_inst
Public time_ws_gust_inst As String *100

'Declare Variable Units
Units WindSpd = km/u
Units WindDir = degrees
Units WS_Gust = km/u
Units WS_Gust_dir = degrees
'Define Output Data Tables
DataTable (TenMinute,1,1000)
DataInterval (0,10,Min,10)
WindVector (1,WindSpd,WindDir,FP2,False,0,0,0)
FieldNames ("WindSpd_AVG:Deg,WindDir_AVG:Deg,WindDir_STDEV:Deg")
Minimum (1,WindSpd,FP2,False,False)
Maximum (1,WindSpd,FP2,False,True)
SampleMaxMin (1,WindDir,FP2,False)
Maximum (1,WS_Gust,FP2,False,True)
SampleMaxMin (1,WS_Gust_dir,FP2,False)

EndTable

'Main Program
BeginProg
Scan (1,Sec,0,0)
'----------- Measure 05103-10 Wind Speed & Direction Sensor ----------

'Generic 4-20 mA Input measurement WindSpd
VoltDiff(WindSpd,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic 4-20 mA Input measurement WindDir
VoltDiff(WindDir,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
If WindDir>=360 Then WindDir=0

'Program code for outputting wind gust data as per EC MSC guidelines

If TimeIntoInterval(0,10,Min) Then
WS_10_max = 0
WS_Gust = 0
WS_Gust_dir = 0

EndIf

If WindSpd> WS_Gust Then
WS_Gust=WindSpd
time_ws_gust_inst=status.timestamp
EndIf
If IfTime (0,10,min) Then
WS_Gust=0
time_ws_gust_inst=0
EndIf

'Call Output Data Table
CallTable TenMinute
NextScan
EndProg


Makada Oct 15, 2016 08:37 PM

Thanks.

now i get a warning saying ''ws_gust_inst'' is declared but not used...


Makada Oct 18, 2016 10:32 AM

Hi Smile and others,

Do you have an idea whats causing this?


rlwoell Oct 19, 2016 03:57 PM

It is just what the warning says.  You have defined a variable "ws_gust_inst" but have not used it anywhere.  You have defined and used variables with similar names such as "time_ws_gust_inst" but not the one that generates the warning. 

And that is the purpose of the warning, to let you know that you may not have used a variable that you intended to when you defined it. 

I think this is a relatively new compiler feature.  I like it not only because it is a reality check on my code but it points to code that can be cleaned up and eliminated.


Makada Oct 22, 2016 05:57 PM

Hi all,

i have a one minute table running, ive managed to get the max windspeed from the last 10 minutes in rtmc pro, shown below:

StartRelativeToNewest(nsecPerMin, OrderCollected);
MaxRunOverTime("Server:CR1000.Table1.Windskm",Timestamp("Server:CR1000.Table1.MaxWindskm"),10*nSecPerMin)

But how do i get the direction from that gust from the last 10 minutes using the one minute table in rtmc pro?

Maybe someone has got an example?

Samplemaxmin is in use so i know how to get the one minute direction from the gust...


Makada Oct 25, 2016 02:36 PM

And the timestamp that comes with the 10 minute data mentioned above...?

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