I am not very well versed in CRBasic, but I am trying to write an if/then statement to calculate a value. I want to calculate it such that between october 1 and june 30, it is using one equation (y = m1x +b1) and july - september using another (y = m2x + b2). I know there is a function for TimeisBetween for time of the day, but I was wondering if there was a similar function for the months of the year. I am using a CR1000
with realtime instruction you have all this information in public and you can create all desirable filters.
Public rTime(9) 'declare as public and dimension rTime to 9
Alias rTime(1) = Year 'assign the alias Year to rTime(1)
Alias rTime(2) = Month 'assign the alias Month to rTime(2)
Alias rTime(3) = DOM 'assign the alias DOM to rTime(3)
Alias rTime(4) = Hour 'assign the alias Hour to rTime(4)
Alias rTime(5) = Minute 'assign the alias Minute to rTime(5)
Alias rTime(6) = Second 'assign the alias Second to rTime(6)
Alias rTime(7) = uSecond 'assign the alias uSecond to rTime(7)
Alias rTime(8) = WeekDay 'assign the alias WeekDay to rTime(8)
Alias rTime(9) = Day_of_Year 'assign the alias Day_of_Year to rTime(9)
Thanks. I had tried this code before, but didn't realize how to call data into the variables. RealTime( rTime ) is the code I was missing.
It all works now though. Thank you
M903 connected by null modem to RS232 on CR1000. A fan with a ball valve are connected to the SW12.
'Radiance Research RNeph Variables
Public RNeph(2) As String
Alias RNeph(1) = BScat
Alias RNeph(2) = BSCal
Public Flow_Neph
'Neph reset variables
Dim WarmUpWait
Dim NephResetFlag
Public numBytesRet
Dim inString As String * 438
Dim Neph_AZ As Boolean
Public Neph_MZ As Boolean
Public Neph_ManualReset As Boolean
Public Scatter As Float
Public Scat As Float
Public PMEst
Dim rTime(9) 'declare as public and dimension rTime to 9
Alias rTime(1) = Year 'assign the alias Year to rTime(1)
Alias rTime(2) = Month 'assign the alias Month to rTime(2)
Alias rTime(3) = DOM 'assign the alias DOM to rTime(3)
Alias rTime(4) = Hour 'assign the alias Hour to rTime(4)
Alias rTime(5) = Minute 'assign the alias Minute to rTime(5)
Alias rTime(6) = Second 'assign the alias Second to rTime(6)
Alias rTime(7) = uSecond 'assign the alias uSecond to rTime(7)
Alias rTime(8) = WeekDay 'assign the alias WeekDay to rTime(8)
Alias rTime(9) = Day_of_Year 'assign the alias Day_of_Year to rTime(9)
Units PMEst = ug/m3
'5 minute meteorological data table
DataTable(Neph_1_Min,true,-1)
DataInterval(0,1,min,10)
Average(1,BScat,IEEE4,False)
Average(1,BSCal,IEEE4,False)
Average(1,Flow_Neph,FP2,False)
Average(1, PMEst, FP2, False)
EndTable
DataTable(Neph_5_Min,true,-1)
DataInterval(0,5,min,10)
Average(1,BScat,IEEE4,False)
Average(1,BSCal,IEEE4,False)
Average(1,Flow_Neph,FP2,False)
Average(1, PMEst, FP2, False)
EndTable
DataTable(Neph_60_Min,true,-1)
DataInterval(0,60,min,10)
Average(1,BScat,IEEE4,False)
Average(1,BSCal,IEEE4,False)
Average(1,Flow_Neph,FP2,False)
Average(1, PMEst, FP2, False)
EndTable
DataTable(Neph_1440_Min,true,-1)
DataInterval(0,1440,min,10)
Average(1,BScat,IEEE4,False)
Average(1,BSCal,IEEE4,False)
Average(1,Flow_Neph,FP2,False)
Average(1, PMEst, FP2, False)
EndTable
'//////////////////////////////////////////////////////////////////////////////////////////////////
'//////// Main Program //////////
'//////////////////////////////////////////////////////////////////////////////////////////////////
SequentialMode
BeginProg
'Begin main scan
Scan(1,Sec,3,0)
'initialize Neph Reset Flag & Neph warm up counter
NephResetFlag = FALSE
WarmUpWait = 100
SerialOpen(ComRS232,9600,3,0,219)
SerialInRecord(ComRS232,inString,13,109,0,numBytesRet,00) 'Get data from Radiance Research Nephelometer RNeph
SplitStr(RNeph,inString," ",2,6)
'check if the bscat exceeded expected range
'Threshold for bscat filter is set to 20. Adjust as needed.
If (BScat > 20) Then
NephResetFlag = TRUE
Else
NephResetFlag = FALSE
EndIf
'''''''''''''''''''''''''''''''''''''''''''''''
'remove the observation while the Neph warms up
'this is set to 1 min
'''''''''''''''''''''''''''''''''''''''''''''''
If (WarmUpWait < 1) Then
BScat = -99
BSCal = -99
EndIf
'Dwyer MS-621 Digital Magnehelic flow measurement:
VoltSe(Flow_Neph,1,mv5000,13,True,0,_60Hz,0.00004,-0.1)
'Begin M903 "Auto Zero" sequence
If TimeIsBetween(350,365,1440,Min)
Neph_AZ = True
EndIf
If TimeIsBetween(365,350,1440,Min)
Neph_AZ = False
EndIf
If Neph_AZ = True Then
SW12(0)
ElseIf Neph_AZ = True OR Neph_MZ = True Then
SW12(0)
ElseIf Neph_AZ = True AND Neph_MZ = False Then
SW12(0)
ElseIf Neph_AZ = False AND Neph_MZ = True Then
SW12(0)
Else
SW12(1)
EndIf
'Begin slope selection for wildfire season -> July-September
Scatter = RNeph(1)
Scat = 10000 * Scatter
RealTime( rTime )
If Month = 7 AND Scat > 1.58 Then
PMEst = Scat * 13.31 + 2.96
ElseIf Month = 8 AND Scat > 1.58 Then
PMEst = Scat * 13.31 + 2.96
ElseIf Month = 9 AND Scat > 1.58 Then
PMEst = Scat * 13.31 + 2.96
Else
PMEst = Scat * 17.2 - 2.3
EndIf
'Neph Manual Reset
Neph_ManualReset = False
SerialOpen(ComRS232,9600,3,0,219)
If Neph_ManualReset = True Then
'reset the Neph to make sure it is not in the wrong mode
'SerialOut(ComRS232,"S","message.",1,500)
SerialOut(ComRS232,"S","",1,500)
SerialOut(ComRS232,CHR(13),"",1,100)
SerialOut(ComRS232,"Q","",1,300)
SerialOut(ComRS232,CHR(13),"",1,500)
Neph_ManualReset = False
EndIf
'Call Data Tables and Store Data
'CallTable Neph_5_Sec
CallTable Neph_1_Min
CallTable Neph_5_min
CallTable Neph_60_Min
CallTable Neph_1440_min
NextScan
SlowSequence
Scan(20,Sec,3,0)
NextScan
'Slow scan checks if Neph was reset to an unexpected mode
'and sets the Neph back to the expected S mode
SlowSequence
Scan(1, Min, 0 ,0)
If NephResetFlag = True Then
'reset the Neph to make sure it is not in the wrong mode
SerialOut(ComRS232,"S","message.",1,500)
SerialOut(ComRS232,CHR(13),"",1,100)
SerialOut(ComRS232,"Q","",1,300)
SerialOut(ComRS232,CHR(13),"",1,500)
'let the Neph warm up
WarmUpWait = 0
Else
WarmUpWait = WarmUpWait + 1 'add 1 min to the counter
EndIf
NextScan
EndProg