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.

I want to output NAN for a faulty sensor


Darwyn72 Nov 15, 2022 08:02 AM

Hello, we have a program running on a CR1000 that is taking data from a LI-COR 7200 on a profile system of 14 levels for gas and temperature. I know that one gas sampling level has a faulty tubing, so that the data is no use. What is the best approach to label that data in the output table as NAN?I tried an If / Then statement in the scan operation but this doesn't work. I also tried a similar If statement in the CallTable command, but this didn't seem to work.

I suppose the best option is to put an If statement in the scan with limits for CO2 and H2O output, so that beyond or below a certain value it writes NAN.

Anyone have a suggestion, Thanks, Paul

The program is below

'Se-Sva_Profile_007; Lines 424-426 and 442-444 added If Then statement to put IRGA gas values to NAN when on Level 5
'Psmith 2022-11-11
'SE-Sva_Profile_004; Changed parameter agc to Signal_Strength for new firmware in 
'Licor 7200 131009/ In Situ VE
'SE-Sva_Profile_003; 200ms scan for Li, 250us integration for all TC and Pt100 meas.
'Lapses parameter in DataInterval declarations set to 0 to force the logger to time stamp
'all records 
'SE-Sva_Profile_002 changed default settings for seqencestep to 30s and Skip_s to 25s 130510/VE

'SE-Sva_Profile_001
'CR1000 Series Datalogger

'program author: Bengt Noren ,In Situ, 20130120
'Declare Public Variables

Public PTemp
Units PTemp=C
Public batt_volt
Units batt_volt=V

Public ToRestart

'LI-7200
Public irga_fast(10)
Public irga(10) '1s irga data (avg of irga_fast)

Alias irga(1) = CO2_dry
Alias irga(2) = H2O_dry
Alias irga(3) = CO2_dens
Alias irga(4) = H2O_dens
Alias irga(5) = Signal_Strength
'Alias irga(5) = agc
Alias irga(6) = P_fast
Alias irga(7) = T_in
Alias irga(8) = T_out
Alias irga(9) = Tavg_Tin_Tout
Alias irga(10) = Aux1

Units CO2_dry = umol/mol
Units H2O_dry = mmol/mol
Units CO2_dens = mmol/m3
Units H2O_dens = mmol/m3
Units Signal_Strength = arb
'Units agc = arb
Units P_fast = kPa
Units T_in = C
Units T_out = C
Units Tavg_Tin_Tout = C
Units Aux1 = mV

Public CO2_wet_ETC_fast
Public H2O_wet_ETC_fast

Public CO2_wet_ETC
Units CO2_wet_ETC=umol/mol
Public H2O_wet_ETC
Units H2O_wet_ETC=mmol/mol

Dim T_cell_ETC
Dim PRESS_cell_ETC
Units T_cell_ETC=C
Units PRESS_cell_ETC=kPa
Dim Level_ETC

Public Flow_meter_raw_ETC
Units Flow_meter_raw_ETC=mV
Public Flow_meter_ETC
Units Flow_meter_ETC=L/min

Dim NAN_to_full_30min

'Control of two SDMCD16
'used to control magnetic valves and pumps

'M(m,n) = 1 / 0 for 0n / off
'M(m,n)=2 for auto control via logger program algorithms
Public M(2,16) 'On / off / auto select. Normally left in auto mode, but can be
'set by opeator to on or off for system test
Public a(2,16) 'from program logic, used in auto mode!
Public o(2,16) 'actual state


'DO channel assignment for the two SDMCD16
Alias M(1,1) = M_Level_1
Alias M(1,2) = M_Level_2
Alias M(1,3) = M_Level_3
Alias M(1,4) = M_Level_4
Alias M(1,5) = M_Level_5
Alias M(1,6) = M_Level_6
Alias M(1,7) = M_Level_7
Alias M(1,8) = M_Level_8
Alias M(1,9) = M_Level_9
Alias M(1,10) = M_Level_10
Alias M(1,11) = M_Level_11
Alias M(1,12) = M_Level_12
Alias M(1,13) = M_Level_13
Alias M(1,14) = M_Level_14


Alias a(1,1) = a_Level_1
Alias a(1,2) = a_Level_2
Alias a(1,3) = a_Level_3
Alias a(1,4) = a_Level_4
Alias a(1,5) = a_Level_5
Alias a(1,6) = a_Level_6
Alias a(1,7) = a_Level_7
Alias a(1,8) = a_Level_8
Alias a(1,9) = a_Level_9
Alias a(1,10) = a_Level_10
Alias a(1,11) = a_Level_11
Alias a(1,12) = a_Level_12
Alias a(1,13) = a_Level_13
Alias a(1,14) = a_Level_14


Alias o(1,1) = o_Level_1
Alias o(1,2) = o_Level_2
Alias o(1,3) = o_Level_3
Alias o(1,4) = o_Level_4
Alias o(1,5) = o_Level_5
Alias o(1,6) = o_Level_6
Alias o(1,7) = o_Level_7
Alias o(1,8) = o_Level_8
Alias o(1,9) = o_Level_9
Alias o(1,10) = o_Level_10
Alias o(1,11) = o_Level_11
Alias o(1,12) = o_Level_12
Alias o(1,13) = o_Level_13
Alias o(1,14) = o_Level_14

Alias M(2,1) = M_Cal_1
Alias M(2,2) = M_Cal_2
Alias M(2,3) = M_Cal_3
Alias M(2,4) = M_Cal_4
Alias M(2,15) =M_VentPump
Alias M(2,16) =M_SmplPump


Alias a(2,1) = a_Cal_1
Alias a(2,2) = a_Cal_2
Alias a(2,3) = a_Cal_3
Alias a(2,4) = a_Cal_4
Alias a(2,15) =a_VentPump
Alias a(2,16) =a_SmplPump

Alias o(2,1) = o_Cal_1
Alias o(2,2) = o_Cal_2
Alias o(2,3) = o_Cal_3
Alias o(2,4) = o_Cal_4
Alias o(2,15) =o_VentPump
Alias o(2,16) =o_SmplPump


'MAGNETIC VALVE SEQUENCING AND GAS MEAS. CONTROL
Public Level 'Current sample level
Public LevelSequence(33)'default sequence for Svartberget; 1,2,3...15.
'Normally 15 step is enough. 33 steps also accomodates for a up/down sequence;
'1-2-3...15 and then 15-14-13-...1
'so all 33 do not need to be used. The first "0" in the table is interpreted by
'program logic as "end of sequence", and the sequence will restart from level in
'LevelSequence(1)

Public LevelIndex 'Pointer to current selection in LevelSequence()

Public SequenceStep As Long '_s 'second per level in sequence
Public Skip_s As Long 'no of seconds to skip before averaging gas measurement,
'after switching to new level
Public Store_Trig As Boolean'variable evaluated from user entered info on
'SequenceStep_s, triggers the averaging of collected data for one level before the
'next level is activated,
'A record is generated if Store_Trig is true
Public Skip As Boolean 'varable evaluated from user entered info on SequenceStep and
'Skip_s. If true, the current sample is skipped!
Public RUNAUTOSEQ As Boolean
'If true the auto sequence defined by the settings above will be run!

Public n
'iteration counter for program loops.


Public RS_R0 'intermediate storage of raw data from bridge meas. of Pt100 sensor
Public T_Pt_ref 'temp of Pt100 @ ref for TC
Units T_Pt_ref=C
Public TC_ref 'temp of Reference thermocouple @ ref for TC
Units TC_ref=C
Public T(16) 'TC temperature at different levels
Units T()=C
Public I_Fan(17) 'measurement of fan current of up to 16 fans
Units I_Fan()=mA

'formatting timestamp according to ETC
Dim timestamps_IRGA  As String * 22 ' this variable will first receive a timestamp with 22 characters, following this format : yyyy-MM-dd_HH-mm-ss
Dim rtime_IRGA(6)  As String ' rtime is short for real time
Dim timestamps_T  As String * 22 ' this variable will first receive a timestamp with 22 characters, following this format : yyyy-MM-dd_HH-mm-ss
Dim rtime_T(6)  As String ' rtime is short for real time

Dim OutStat
Dim LastFileName As String *39

'Define Data Tables
DataTable (profile-cal,True,1000) 'One record created at each restart of program
  Sample (1,Q_M,IEEE4)
  Sample (1,Q_O,IEEE4)
    CardOut (0,1000)'same size as in logger memory
EndTable

DataTable (profile-raw,1,-1)
  Sample (1,Level,FP2)
  Sample (10,irga(),IEEE4)
  Sample (1,Q,IEEE4)
  Sample (1,Flow_meter_ETC,IEEE4)
  
  CardOut (0 ,2600000)
EndTable

DataTable (profile,Store_Trig,10000)
  Sample (1,Level,FP2)
  Average (10,irga(),IEEE4,Skip)
  Average (1,Q,IEEE4,Skip)
  Average (1,Flow_meter_ETC,IEEE4,Skip)
  
  CardOut (0 ,86400) 'auto-allocation would assume one record every second.
  'this is unrealistic, 250000 will normally last for >one month
EndTable

DataTable (ETC_IRGA,1,-1)
  DataInterval (0,1,Sec,10)
	CardOut (0 ,260000)
  TableFile ("CRD:SE-Svb_IRGA_",11,-1,0,1,Day,OutStat,LastFileName)

  Sample (1,timestamps_IRGA,String)
  FieldNames ("timestamps")
  
  Sample (1,CO2_wet_ETC,IEEE4)
  FieldNames ("CO2")
  Sample (1,H2O_wet_ETC,IEEE4)
  FieldNames ("H2O")
  Sample (1,Level_ETC,FP2)
  FieldNames ("LEVEL")
  Sample (1,T_cell_ETC,IEEE4)
  FieldNames ("T_CELL")
  Sample (1,PRESS_cell_ETC,IEEE4)
  FieldNames ("PRESS_CELL")
  Sample (1,Flow_meter_ETC,IEEE4)
  FieldNames("FLOW_VOLRATE")
  Sample (1,Flow_meter_raw_ETC,IEEE4)
  FieldNames("FLOW_VOLRATE_IU")
 
EndTable

DataTable (ETC_T,1,-1)
  DataInterval (0,5,Sec,10)
	CardOut (0 ,52000)
  TableFile ("CRD:SE-Svb_T_",11,-1,0,1,Day,OutStat,LastFileName)

  Sample (1,timestamps_T,String)
  FieldNames ("timestamps")
  
  Sample (1,T(1),IEEE4)
  FieldNames ("TA_2_16_1")
  Sample (1,T(2),IEEE4)
  FieldNames ("TA_2_15_1")
  Sample (1,T(3),IEEE4)
  FieldNames ("TA_2_14_1")
  Sample (1,T(4),IEEE4)
  FieldNames ("TA_2_13_1")
  Sample (1,T(5),IEEE4)
  FieldNames ("TA_2_12_1")
  Sample (1,T(6),IEEE4)
  FieldNames ("TA_2_11_1")
  Sample (1,T(7),IEEE4)
  FieldNames ("TA_2_10_1")
  Sample (1,T(8),IEEE4)
  FieldNames ("TA_2_9_1")
  Sample (1,T(9),IEEE4)
  FieldNames ("TA_2_8_1")
  Sample (1,T(10),IEEE4)
  FieldNames ("TA_2_7_1")
  Sample (1,T(11),IEEE4)
  FieldNames ("TA_2_6_1")
  Sample (1,T(12),IEEE4)
  FieldNames ("TA_2_5_1")
  Sample (1,T(13),IEEE4)
  FieldNames ("TA_2_4_1")
  Sample (1,T(14),IEEE4)
  FieldNames ("TA_2_3_1")
  Sample (1,T(15),IEEE4)
  FieldNames ("TA_2_2_1")
  Sample (1,T(16),IEEE4)
  FieldNames ("TA_2_1_1")
 
EndTable

DataTable (T-profile-raw,1,-1)
  DataInterval (0,1,Min,0)
  Average (1,T_Pt_ref,FP2,False)
  Average (1,TC_ref,FP2,False)
  Average (16,T(),FP2,False)
  Average (17,I_Fan(),FP2,False)'fan #16 is the fan in the radiation shield for the
  'temp/RH probe in the Meteo system, powered from the profile system!

  'Background info of logger power status and logger temperature
  Minimum (1,batt_volt,FP2,0,False)
  Sample (1,PTemp,FP2)'
  
  CardOut (0 ,43200)
EndTable

DataTable (T-profile,1,-1)
  DataInterval (0,5,Min,0)
  Average (1,T_Pt_ref,FP2,False)
  Average (1,TC_ref,FP2,False)
  Average (16,T(),FP2,False)
  Average (17,I_Fan(),FP2,False)'fan #16 is the fan in the radiation shield for the
  'temp/RH probe in the Meteo system, powered from the profile system!

  'Background info of logger power status and logger temperature
  Minimum (1,batt_volt,FP2,0,False)
  Sample (1,PTemp,FP2)'
  
    CardOut (0 ,8650)
EndTable


'Main Program

BeginProg

  '** System Setup *******************************************************
  Scan(5,sec,0,2)
    '    'execute twice!

    Public Q 'mass flow
    Public Q_raw

    Dim Q_M
    Dim Q_O '
    Units Q = Nl/Min
    Units Q_raw = mV
    Units Q_M = mV
    Units Q_O = Nl//min
    Q_M = 0.002 '5000mV=10 Nl/min
    Q_O = 0 'Offset normally =0, until calibration shows differently

    'Public PA
    'Public PA_Raw
    'Units PA=hPa
    'Dim PA_M
    'PA_M = 0.12
    'Dim PA_O
    'PA_O = 500

    'Default sequence

    Skip=true
     Skip_s=25 '130510/VE
    'Skip_s=11
    SequenceStep = 30 '30 sec between level switching 130510/VE
    'SequenceStep = 15 '15 sec between level switching
'default settigs skip=11 and Sequence Step=15; average of meas from second 12, 13, 
'14 & 15 will be output!
    LevelIndex=1
    RUNAUTOSEQ = true
    LevelSequence(1)=1
    LevelSequence(2)=2
    LevelSequence(3)=3
    LevelSequence(4)=4
    LevelSequence(5)=5 'Faulty level - blocked or cut tubing
    LevelSequence(6)=6
    LevelSequence(7)=7
    LevelSequence(8)=8
    LevelSequence(9)=9
    LevelSequence(10)=10
    LevelSequence(11)=11
    LevelSequence(12)=12
    LevelSequence(13)=13
    LevelSequence(14)=14
    LevelSequence(15)=1
    LevelSequence(16)=0 ' 0 indicates end of sequence, restart from (1)
    LevelSequence(17)=0
    LevelSequence(18)=0
    LevelSequence(19)=0
    LevelSequence(20)=0
    LevelSequence(21)=0
    LevelSequence(22)=0
    LevelSequence(23)=0
    LevelSequence(24)=0
    LevelSequence(25)=0
    LevelSequence(26)=0
    LevelSequence(27)=0
    LevelSequence(28)=0
    LevelSequence(29)=0
    LevelSequence(30)=0
    LevelSequence(31)=0
    LevelSequence(32)=0

    M_Level_14 = 2
    M_Level_13 = 2
    M_Level_12 = 2
    M_Level_11 = 2
    M_Level_10 = 2
    M_Level_9 = 2
    M_Level_8 = 2
    M_Level_7 = 2
    M_Level_6 = 2
    M_Level_5 = 2
    M_Level_4 = 2
    M_Level_3 = 2
    M_Level_2 = 2
    M_Level_1 = 2
    M_VentPump = 1
    M_SmplPump = 2
    
    NAN_to_full_30min=1

    If ToRestart = 0 Then CallTable profile-cal
    ToRestart = 1
    
    CO2_wet_ETC=NAN    
    H2O_wet_ETC=NAN
    T_cell_ETC=NAN
    PRESS_cell_ETC=NAN

    If LevelSequence(5)=5 Then 'To try and set Level 5 (20m) values to NAN
    CO2_wet_ETC=NAN
    H2O_wet_ETC=NAN
    EndIf
  
  NextScan

Scan (200,mSec,3,0)
  LI7200(irga_fast(),1,8,2)
  AvgRun(irga(),10,irga_fast(),5)
  
  CO2_wet_ETC_fast=irga(3)*(8.314*(irga(9)+273.15))/irga(6)
  H2O_wet_ETC_fast=irga(4)*(8.314*(irga(9)+273.15))/(1000*irga(6))
  AvgRun(CO2_wet_ETC,1,CO2_wet_ETC_fast,5)
  AvgRun(H2O_wet_ETC,1,H2O_wet_ETC_fast,5)
  T_cell_ETC=irga(9)
  PRESS_cell_ETC=irga(6)
  
  If Level_ETC=10 Then    'To try and set Level 5 (20m) values to NAN?
    CO2_wet_ETC_fast=NAN
    H2O_wet_ETC_fast=NAN
  EndIf

  If NAN_to_full_30min=1 Then 
    CO2_wet_ETC=NAN
    H2O_wet_ETC=NAN
    T_cell_ETC=NAN
    PRESS_cell_ETC=NAN
  EndIf
  
NextScan

  SlowSequence
   Scan (1,Sec,0,0)

'creating correct format of timestamp for files going to ETC
  timestamps_IRGA=Status.timestamp(6,0) ' option 6 gives timestamp with format "yyyy-MM-dd_HH-mm-ss.ff"
  rtime_IRGA(1)=Mid(timestamps_IRGA,1,4) ' yyyy
  rtime_IRGA(2)=Mid(timestamps_IRGA,6,2) ' mm
  rtime_IRGA(3)=Mid(timestamps_IRGA,9,2) ' dd
  rtime_IRGA(4)=Mid(timestamps_IRGA,12,2)' HH
  rtime_IRGA(5)=Mid(timestamps_IRGA,15,2)' MM
  rtime_IRGA(6)=Mid(timestamps_IRGA,18,2)' ss
  timestamps_IRGA=rtime_IRGA(1)+rtime_IRGA(2)+rtime_IRGA(3)+rtime_IRGA(4)+rtime_IRGA(5)+rtime_IRGA(6)

  VoltDiff(Flow_meter_raw_ETC,1,mV5000,7,1,0,50,1.0,0))
  Flow_meter_ETC=0.0025*Flow_meter_raw_ETC-2.5
  
   CallTable ETC_IRGA
   

    VoltDiff (Q_raw,1,mV5000,5,True ,0,250,1.0,0)
    
    'Calculate Q
    Q=Q_raw*Q_M+Q_O

    'LI7200(irga(),1,8,2)

    CallTable (profile-raw) 'collect raw data

    Store_Trig=false

    If IfTime (0,SequenceStep,Sec)Then
      Store_Trig=true
      LevelIndex=LevelIndex+1
    EndIf


    CallTable (profile)

    If IfTime (Skip_s,SequenceStep,Sec)Then Skip=false
      If IfTime (0,SequenceStep,Sec)Then Skip=true
      
        If IfTime (0,30,Min) Then 
          LevelIndex = 1
          NAN_to_full_30min=0
        EndIf

        If IfTime (0,30,Min) Then LevelIndex = 1
        Level=LevelSequence(LevelIndex)
        If Level=0 Then LevelIndex =1 'restart if eos detected
        Level=LevelSequence(LevelIndex)
        If LevelIndex >= 32 Then LevelIndex=32



        If RUNAUTOSEQ = false Then
          Level=0
          LevelIndex=1
        EndIf

        For n=1 To 14
          If Level =(n)Then
            a(1,n)=1
          Else
            a(1,n)=0
          EndIf
        Next n

        If Level=1 Then Level_ETC=14
        If Level=2 Then Level_ETC=13
        If Level=3 Then Level_ETC=12
        If Level=4 Then Level_ETC=11
        If Level=5 Then Level_ETC=10 'Level 5 is 20 m which has damaged tube
        If Level=6 Then Level_ETC=9
        If Level=7 Then Level_ETC=8
        If Level=8 Then Level_ETC=7
        If Level=9 Then Level_ETC=6
        If Level=10 Then Level_ETC=5
        If Level=11 Then Level_ETC=4
        If Level=12 Then Level_ETC=3
        If Level=13 Then Level_ETC=2
        If Level=14 Then Level_ETC=1
           
        If NAN_to_full_30min=1 Then Level_ETC=NAN  'LevelIndex>7 OR LevelIndex<1

        'Always run sample pump if any level is active!
        a_SmplPump =0
        For n=1 To 15
          If a(1,n)=1 Then a_SmplPump =1
        Next n

        For n = 1 To 16
          If (M(1,n)>= 2) Then
            o(1,n)= a(1,n)
          Else
            o(1,n)= M(1,n)
          EndIf
        Next n

        For n = 1 To 16
          If (M(2,n)>= 2) Then
            o(2,n)= a(2,n)
          Else
            o(2,n)= M(2,n)
          EndIf
        Next n

        SDMCD16AC (o(1,1),1,0)
        SDMCD16AC (o(2,1),1,1)
      NextScan

      SlowSequence
      Scan (5,Sec,0,0)

'creating correct format of timestamp for files going to ETC
  timestamps_T=Status.timestamp(6,0) ' option 6 gives timestamp with format "yyyy-MM-dd_HH-mm-ss.ff"
  rtime_T(1)=Mid(timestamps_T,1,4) ' yyyy
  rtime_T(2)=Mid(timestamps_T,6,2) ' mm
  rtime_T(3)=Mid(timestamps_T,9,2) ' dd
  rtime_T(4)=Mid(timestamps_T,12,2)' HH
  rtime_T(5)=Mid(timestamps_T,15,2)' MM
  rtime_T(6)=Mid(timestamps_T,18,2)' ss
  timestamps_T=rtime_T(1)+rtime_T(2)+rtime_T(3)+rtime_T(4)+rtime_T(5)+rtime_T(6)
  

        PanelTemp (PTemp,_50Hz)
        Battery (batt_volt)
       
        BrHalf4W (RS_R0,1,mV25,mV25,3,Vx1,1,2035,True ,True ,20000,_50Hz,1.0,0)
        PRT (T_Pt_ref,1,RS_R0,1.0,0)
        '20ms settling time proven more than OK for the ref Pt sensor at 
        'Norunda
        
        TCDiff (TC_ref,1,mV2_5C,6,TypeE,T_Pt_ref,True ,0,_50Hz,1.0,0)



        'Activate mux
        PortSet (4,1 )

        'Mux step 1
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        'TCDiff (T(3),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'VoltSe (I_Fan(1),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(3),1,mV5000,4,0,0,_50Hz,1.0,0)

        'Mux step 2
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        TCDiff (T(3),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        VoltSe (I_Fan(4),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(5),1,mV5000,4,0,0,_50Hz,1.0,0)

        'Mux step 3
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        TCDiff (T(4),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        VoltSe (I_Fan(6),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(7),1,mV5000,4,0,0,_50Hz,1.0,0)

        'Mux step 4
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        TCDiff (T(5),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        VoltSe (I_Fan(8),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(9),1,mV5000,4,0,0,_50Hz,1.0,0)

        'Mux step 5
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        TCDiff (T(6),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        VoltSe (I_Fan(10),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(11),1,mV5000,4,0,0,_50Hz,1.0,0)

        'Mux step 6
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step
        '    I=I+1
        TCDiff (T(7),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        VoltSe (I_Fan(12),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(13),1,mV5000,4,0,0,_50Hz,1.0,0)

        'Mux step 7
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        TCDiff (T(8),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        VoltSe (I_Fan(14),1,mV5000,3,0,0,_50Hz,1.0,0)
        VoltSe (I_Fan(15),1,mV5000,4,0,0,_50Hz,1.0,0)


        'Mux step 8
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        'Mux step one step

        TCDiff (T(9),1,mV2_5C,1,TypeE,TC_ref,True ,0,250,1.0,0)
        VoltSe (I_Fan(16),1,mV5000,3,0,0,_50Hz,1.0,0
        VoltSe (I_Fan(17),1,mV5000,4,0,0,_50Hz,1.0,0)) 'Fan 17 in _climate system T/RH probe
        'but powered from _profile system
        
        'Mux step 9
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(10),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel

        'Mux step 10
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(11),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel

        'Mux step 11
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(12),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel

        'Mux step 12
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(13),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel

        'Mux step 13
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(14),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel

        'Mux step 14
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(15),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        TCDiff (T(2),1,mV2_5C,2,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel

        'Mux step 15
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(16),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)
        'no SE to this channel
        
        'Mux step 16
        PortSet (5,1 )
        Delay (0,10,mSec)
        PortSet (5,0 )
        TCDiff (T(1),1,mV2_5C,1,TypeE,TC_ref,True ,0,_50Hz,1.0,0)

        'reset mux
        PortSet (4,0 )



        CallTable T-profile      '5-min temp data
        CallTable T-profile-raw  '1-min temp data
        CallTable ETC_T
        
      NextScan
    EndProg

 


JDavis Nov 15, 2022 05:50 PM

 Yes, you can use an If statement to set a value to NAN if not within a range. I suggest writing out all of your logic plainly before writing code to do what you describe.

'Define Data Tables.
DataTable (Test,1,-1) 'Set table size to # of records, or -1 to autoallocate.
  DataInterval (0,1,Sec,10)
  Sample (1,CO2,IEEE4)
EndTable

'Main Program
BeginProg
  Scan (1,Sec,0,0)

    If (CO2 > 500) OR (CO2 < 10) Then
      CO2 = NAN
    EndIf

    CallTable Test
  NextScan
EndProg

 

PS. Your program is compiling in sequential mode. You will likely skip scans if not compiling in pipeline mode.

https://www.campbellsci.com/videos/pipeline-sequential


Darwyn72 Nov 16, 2022 12:06 PM

Thank you for the reply JDavis, this is what I though. I'll have a look at the program again. Thanks for the tip about the mode; we do get alot of skipped scans on this program. I will aim to get it into pipeline mode.


Hayleyvitt Mar 6, 2023 08:13 AM

This post is under review.

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