'This is the Campbell CR1000 code for logging the weight with 4 Kern DE 35K0.5D balances 'On the balance, set output mode to "Auto PC". 'Uploaded by Markus Nolf, m.nolf@westernsydney.edu.au 'Declare Variables and Units, Dimensioning of counter variables Public Datastream1 As String * 50, Datastream2 As String * 50, Datastream3 As String * 50, Datastream4 As String * 50 Public Readfrom1 As Long, Readfrom2 As Long, Readfrom3 As Long, Readfrom4 As Long Public Plusminus1 As String *1, Plusminus2 As String *1, Plusminus3 As String *1, Plusminus4 As String *1 Public Weight1, Weight2, Weight3, Weight4 Public Unit1 As String *2, Unit2 As String *2, Unit3 As String *2, Unit4 As String *2 Public Batt Public PTemp 'Define Data Table DataTable (Weights,True,-1)) 'Set interval for recording data to 5 min DataInterval (0,5,min,10) Sample (1,Weight1,IEEE4) Sample (1,Unit1,String) Sample (1,Weight2,IEEE4) Sample (1,Unit2,String) Sample (1,Weight3,IEEE4) Sample (1,Unit3,String) Sample (1,Weight4,IEEE4) Sample (1,Unit4,String) Sample (1,Batt,IEEE4) Sample (1,PTemp,IEEE4) EndTable BeginProg 'Open serial connection to balances SerialOpen (Com1,9600,3,0,1000) SerialOpen (Com2,9600,3,0,1000) SerialOpen (Com3,9600,3,0,1000) SerialOpen (Com4,9600,3,0,1000) 'Start a reading every 5 seconds Scan (5,sec,3,0) 'Read continuous output (non-stable value) SerialIn(Datastream1,Com1,100,0,70) SerialIn(Datastream2,Com2,100,0,70) SerialIn(Datastream3,Com3,100,0,70) SerialIn(Datastream4,Com4,100,0,70) 'Balance 1 'Find where new line starts (line-feed character, ASCI dec.10) Readfrom1 = InStr(1,Datastream1,CHR(10),2) Weight1 = Trim(Mid(Datastream1,Readfrom1+3,14)) 'Extract minus sign (separated by spaces), apply if the value is negative Plusminus1 = Mid(Datastream1,Readfrom1+2,1) If Plusminus1 = "-" Then Weight1 = Weight1 * -1 EndIf Unit1 = Trim(Mid(Datastream1,Readfrom1-4,2)) 'Balance 2 'Find where new line starts (line-feed character, ASCI dec.10) Readfrom2 = InStr(1,Datastream2,CHR(10),2) Weight2 = Trim(Mid(Datastream2,Readfrom2+3,14)) 'Extract minus sign (separated by spaces), apply if the value is negative Plusminus2 = Mid(Datastream2,Readfrom2+2,1) If Plusminus2 = "-" Then Weight2 = Weight2 * -1 EndIf Unit2 = Trim(Mid(Datastream2,Readfrom2-4,2)) 'Balance 3 'Find where new line starts (line-feed character, ASCI dec.10) Readfrom3 = InStr(1,Datastream3,CHR(10),2) Weight3 = Trim(Mid(Datastream3,Readfrom3+3,14)) 'Extract minus sign (separated by spaces), apply if the value is negative Plusminus3 = Mid(Datastream3,Readfrom3+2,1) If Plusminus3 = "-" Then Weight3 = Weight3 * -1 EndIf Unit3 = Trim(Mid(Datastream3,Readfrom3-4,2)) 'Balance 4 'Find where new line starts (line-feed character, ASCI dec.10) Readfrom4 = InStr(1,Datastream4,CHR(10),2) Weight4 = Trim(Mid(Datastream4,Readfrom4+3,14)) 'Extract minus sign (separated by spaces), apply if the value is negative Plusminus4 = Mid(Datastream4,Readfrom4+2,1) If Plusminus4 = "-" Then Weight4 = Weight4 * -1 EndIf Unit4 = Trim(Mid(Datastream4,Readfrom4-4,2)) Battery (Batt) 'Default Datalogger Battery Voltage measurement PanelTemp (PTemp,_50Hz) 'Wiring Panel Temperature measurement CallTable Weights NextScan EndProg