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.

code not writing to my table


Shanks.J Sep 27, 2021 03:06 AM

seems like a stupid issue, but hoping for a quick resolution. please see my code below. which is not writing to my table, can anyone see why not? should be a simple thing.

'CR6 Datalogger

 

'Date: 24/09/2021

'Program Authour: J Shanks

'Program Version: V1.0

 

'#################Wiring#######################

 

'VW1 = GEOKON 4427 SN 2129518 = U1 U2 U3 U4 red u1 black u2 green u3 white u4

'VW1 = GEOKON 4427 SN 2129519 = U5 U6 U7 U8 red u5 black u6 green u7 white u8

 

'weatherstation Vaisala WXT536

'Red, Ground Power

'Brown, Power 12V, pin1,, SW12-2

'Blue & White, SDI12, Must be combined, C3

'Green, Ground, not Power

'SDI12 address is set to "3"

 

'TBO3

'Red, U9

'Black, Ground

 

'Garmin GPS16X-HVS

'Red, Power 12V, pin1, red, SW12-1

'Grey, Signal PPS, pin2, white, C1

'White, Signal Tx, pin3, blue, C2

'Blue, Ground Rx, pin4, black, Ground

'Yellow, Power Switch G, pin4, black, Ground

'Black, Power Ground, pin4, black, Ground

'Clear, Shield, pin4, black, Ground

'SDI12 address is set to "0" (default)

 

'################# Variables #################

'Public Variables

Public PTemp,

Public Batt_volt(2)

Public WXT(7) 'weatherstation 7variables, model: WXT536

 

Public TB03Rain_mm

Public TBO3Rain_tips

 

Public GPS_SDI12(15) 'string from Garmin GPS. Note, Garmin GPS is left with the default SDI12 address of

 

'VW1

Public VW1_Sensor_Change

Public VW1_Freq, VW1_Digits, VW1_Eng_Units, VW1_Temp

Public VW1_Set_Zero As Boolean

'VW2

Public VW2_Sensor_Change

Public VW2_Freq, VW2_Digits, VW2_Eng_Units, VW2_Temp

Public VW2_Set_Zero As Boolean

 

'Dimmed Variables

'VW1

Dim VW1_Dest(6)

Dim VW1_C

Dim VW1_Install__Eng_Units

Dim VW1_Install_Temp

Dim VW1_Temp_Corr

Dim VW1_K

'VW2

Dim VW2_Dest(6)

Dim VW2_C

Dim VW2_Install__Eng_Units

Dim VW2_Install_Temp

Dim VW2_Temp_Corr

Dim VW2_K

 

'##########  Output strings ##########

 

'internal battery measurements 

Alias Batt_volt(1) = SupplyVolts

Alias Batt_volt(2) = LithiumVolts

 

'Vaisala weatherstation

Alias WXT(1)=WindDir

Alias WXT(2)=WindSpd

Alias WXT(3)=AirTemp

Alias WXT(4)=RelHumidity

Alias WXT(5)=AirPressure

Alias WXT(6)=wtxRain

Alias WXT(7)=Hail_cm2

 

'Garmin GPS 

Alias GPS_SDI12(1) = latitude_a          'Degrees latitude (+ = North; - = South)

Alias GPS_SDI12(2) = latitude_b          'Minutes latitude

Alias GPS_SDI12(3) = longitude_a         'Degress longitude (+ = East; - = West)

Alias GPS_SDI12(4) = longitude_b         'Minutes longitude

Alias GPS_SDI12(5) = speed               'Speed over ground

Alias GPS_SDI12(6) = course              'Course over ground

Alias GPS_SDI12(7) = magnetic_variation  'Magnetic variation from true north (+ = East; - = West)

Alias GPS_SDI12(8) = fix_quality         'GPS fix quality: 0 = invalid, 1 = GPS, 2 = differential GPS, 6 = estimated

Alias GPS_SDI12(9) = nmbr_satellites     'Number of satellites used for fix

Alias GPS_SDI12(10) = altitude           'Antenna altitude

Alias GPS_SDI12(11) = pps                'usec into sec of system clock when PPS rising edge occurs, typically 990,000 once synced

Alias GPS_SDI12(12) = dt_since_gprmc     'Time since last GPRMC string, normally less than 1 second

Alias GPS_SDI12(13) = gps_ready          'Counts from 0 to 10, 10 = ready

Alias GPS_SDI12(14) = max_clock_change   'Maximum value the clock was changed in msec

Alias GPS_SDI12(15) = nmbr_clock_change  'Number of times the clock was changed

 

 

 

'################# Constants ################# 

'generic VW

Const T_A = 1.4051e-3

Const T_B = 2.369e-4

Const T_C = 1.019e-7

Const K_M = 0.000376

Const K_B = 0.328

'VW1 (SN:2129518)

Const VW1_A = 1.7854e-6

Const VW1_B = 0.6242

Const VW1_G = 0.6400

'VW2 (SN:2129519)

Const VW2_A = 2.6922e-7

Const VW2_B = 0.6104

Const VW2_G = 0.6128

 

'################# Data Tables #################

 

DataTable(Table1,True,-1)

  DataInterval (0,10,Min,10)

  'VW1

  Sample (1,VW1_Eng_Units,IEEE4)

  Sample (1,VW1_Temp,IEEE4)

  Sample (1,VW1_Sensor_Change,IEEE4)

  'VW2

  Sample (1,VW2_Eng_Units,IEEE4)

  Sample (1,VW2_Temp,IEEE4)

  Sample (1,VW2_Sensor_Change,IEEE4)

  Minimum (1,Batt_volt,FP2,False,False)

  Sample (1,PTemp,FP2)

  'weatherstation section

              WindVector(1,WindSpd,WindDir,FP2,False,900,0,0)

            FieldNames("WindSpd_Mean,WindDir_MeanUnitVector,WindDir_SD1")

              Average(1,AirTemp,FP2,False)

              Sample(1,RelHumidity,FP2)

              Sample(1,AirPressure,IEEE4)

              Totalize(1,wtxRain,FP2,False)

              Totalize(1,Hail_cm2,FP2,False)

              'rainfall

              Totalize(1,TB03Rain_mm,FP2,False)

              Totalize(1,TBO3Rain_tips,FP2,False)

EndTable

 

'System Operation Parameters

PreserveVariables

SequentialMode

 

'################# Main Program #################

BeginProg

  Scan (1,min,0,0)

    PanelTemp (PTemp,50)

    Battery (Batt_volt)

 

'Weather station

    'switch

    If TimeIsBetween (720,725,1440,Min) Then 'between 1200noon and 1205

       SW12(2,0)'turn off SW2 ()

      Else

      SW12(2,1)'turn on SW2 ()

    EndIf

    'main prog

              'WindDir', 'WindSpd', 'AirTemp','RelHumidity', 'AirPressure', 'wtxRain', and 'Hail_cm2'

              SDI12Recorder(WXT(),C3,"3","M!",1,0)'WXT520 Weather Transmitter measurements

 

'TB-03'Rain_mm'

              PulseCount(TB03Rain_mm,1,U9,1,0,0.2,0)

              TBO3Rain_tips = TB03Rain_mm* 5

             

'VW1

    'Measure VW1 Sensor

    VibratingWire (VW1_Dest(),1,U1,1400 ,3500 ,1,0.01,"",50,T_A,T_B,T_C)

    VW1_Freq = VW1_Dest(1)

    VW1_Temp = VW1_Dest(6)

    'VW1 Convert Freq to Digits

    VW1_Digits = (VW1_Freq^2) / 1000

    'VW1 Calculate Engineering Units

    VW1_Eng_Units = (VW1_Digits^2) * VW1_A + VW1_Digits * VW1_B + VW1_C

    'VW1 Calculate & Apply Temperature Compensation

    VW1_K = ((VW1_Digits * K_M) - K_B) * VW1_G  'Example is for 4420-1-50mm

    VW1_Temp_Corr = (VW1_Temp - VW1_Install_Temp) * VW1_K

    VW1_Eng_Units = VW1_Eng_Units + VW1_Temp_Corr

    'Calculate Movement

    VW1_Sensor_Change = VW1_Eng_Units - VW1_Install__Eng_Units

 

'VW2

    'Measure VW2 Sensor

    VibratingWire (VW2_Dest(),1,U5,1400 ,3500 ,1,0.01,"",50,T_A,T_B,T_C)

    VW2_Freq = VW2_Dest(1)

    VW2_Temp = VW2_Dest(6)

    'VW2 Convert Freq to Digits

    VW2_Digits = (VW2_Freq^2) / 1000

    'VW2 Calculate Engineering Units

    VW2_Eng_Units = (VW2_Digits^2) * VW2_A + VW2_Digits * VW2_B + VW2_C

    'VW2 Calculate & Apply Temperature Compensation

    VW2_K = ((VW2_Digits * K_M) - K_B) * VW2_G  'Example is for 4420-1-50mm

    VW2_Temp_Corr = (VW2_Temp - VW2_Install_Temp) * VW2_K

    VW2_Eng_Units = VW2_Eng_Units + VW2_Temp_Corr  

    'Calculate Movement

    VW2_Sensor_Change = VW2_Eng_Units - VW2_Install__Eng_Units

 

'vw zeros

    'VW2 Set Zero (installation) Point

    If VW2_Set_Zero = True Then

      VW2_C = ((VW2_Digits^2) * VW2_A + VW2_Digits * VW2_B) * -1

      VW2_Install_Temp = VW2_Temp

      VW2_Install__Eng_Units = VW2_Eng_Units

      VW2_Set_Zero = False

    EndIf

    'VW1 Set Zero (installation) Point

    If VW1_Set_Zero = True Then

      VW1_C = ((VW1_Digits^2) * VW1_A + VW1_Digits * VW1_B) * -1

      VW1_Install_Temp = VW1_Temp

      VW1_Install__Eng_Units = VW1_Eng_Units

      VW1_Set_Zero = False

    EndIf

 

    'Call Output Tables

    CallTable Table1

  NextScan

            

'GPS Clock correction to run 5 mins every 60mins

  SlowSequence

  Scan (60,Min,0,0)

    SW12 (1,1)

    Delay (0,5,Min)

    GPS (GPS_SDI12(), -COMC1,0,100)

    SW12 (1,0)

NextScan

 

EndProg


Shanks.J Sep 27, 2021 08:09 PM

Resolved: had to update CR6 to latest OS https://www.campbellsci.com/downloads/cr6-os 

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