Here is a sample RSView32 VB file, for data logging of 20 Tags. You will also need an EVE (Event) file or program to call this program periodically. I call it once a minute:
Public Sub WriteCSVLogFile()
Dim LIW_Flow_WY_100 As Tag
Dim DensitySP_FCV101_D As Tag
Dim EvapSP_FCV101_E As Tag
Dim MoistureSP_FCV101_M As Tag
Dim FlowSP_FCV101_L As Tag
Dim MagFlow_FT_101 As Tag
Dim Moisture_AT_103 As Tag
Dim Pressure_PT_106 As Tag
Dim Level_LT_117 As Tag
Dim LIW_Flow_WY_200 As Tag
Dim DensitySP_FCV201_D As Tag
Dim EvapSP_FCV201_E As Tag
Dim MoistureSP_FCV201_M As Tag
Dim FlowSP_FCV201_L As Tag
Dim MagFlow_FT_201 As Tag
Dim Moisture_AT_203 As Tag
Dim Density_DT_301 As Tag
Dim Temperature_TT_107 As Tag
Dim Temperature_TT_112 As Tag
Dim Temperature_TT_116 As Tag
Dim LogDate As Date
Dim OldLogDate As Date
Dim LogFile As Integer
Dim HeaderTrack As Integer
On Error GoTo catch
MkDir ("C:\POT_CARB_LOG")
Check:
'Check to see if the header needs to be inserted.
'HeaderTrack is an Integer bit that is set to 0 if it is Midnight, otherwise set = 1.
If ((Format$(Time, "hh:mm:ss") >= #12:00:00 AM#) And (Format$(Time, "hh:mm:ss") <= #12:01:00 AM#)) Then
HeaderTrack = 0
Else: HeaderTrack = 1
End If
Set LIW_Flow_WY_100 = gProject.TagDb("WY_100_SCALED")
Set DensitySP_FCV101_D = gProject.TagDb("FCV101_D")
Set EvapSP_FCV101_E = gProject.TagDb("FCV101_E")
Set MoistureSP_FCV101_M = gProject.TagDb("FCV101_M")
Set FlowSP_FCV101_L = gProject.TagDb("FCV101_L")
Set MagFlow_FT_101 = gProject.TagDb("FT_101_SCALED")
Set Moisture_AT_103 = gProject.TagDb("AT_103_SCALED")
Set Pressure_PT_106 = gProject.TagDb("PT_106_SCALED")
Set Level_LT_117 = gProject.TagDb("LT_117_SCALED")
Set LIW_Flow_WY_200 = gProject.TagDb("POTCARB\WY_200_SCALED")
Set DensitySP_FCV201_D = gProject.TagDb("FCV201_D")
Set EvapSP_FCV201_E = gProject.TagDb("FCV201_E")
Set MoistureSP_FCV201_M = gProject.TagDb("FCV201_M")
Set FlowSP_FCV201_L = gProject.TagDb("FCV201_L")
Set MagFlow_FT_201 = gProject.TagDb("FT_201_SCALED")
Set Moisture_AT_203 = gProject.TagDb("AT_203_SCALED_IN")
Set Density_DT_301 = gProject.TagDb("DT_301_SCALED")
Set Temperature_TT_107 = gProject.TagDb("TT_107_SCALED")
Set Temperature_TT_112 = gProject.TagDb("TT_112_SCALED")
'Set LogDate equal to current date function.
LogDate = Date
'Get available file number
LogFile = FreeFile
'Open File for writing to and name file with form date.csv
Open "C:\POT_CARB_LOG\" & Format$(LogDate, "mmddyy") & ".csv" For Append As #LogFile
'Insert the Header into the csv file between 12:00 and 12:01 midnight and then insert the data in the correct columns.
If HeaderTrack = 0 Then
Print #LogFile, " Time"; ","; _
"WY-100_LossInWeight"; ","; _
"FCV101_D"; ","; _
"FCV101_E"; ","; _
"FCV101_M"; ","; _
"FCV101_L"; ","; _
"FT-101_Mag_Flow"; ","; _
"AT-103_Moisture"; ","; _
"PT-106_Pressure"; ","; _
"LT-117_Level"; ","; _
"WY-200_LossInWeight"; ","; _
"FCV201_D"; ","; _
"FCV201_E"; ","; _
"FCV201_M"; ","; _
"FCV201_L"; ","; _
"FT-201_Mag_Flow"; ","; _
"AT-203_Moisture"; ","; _
"DT_301_Density"; ","; _
"TT-107_Temp"; ","; _
"TT_112_Temp"; ","
'Insert data into column if the header was just inserted
Print #LogFile, Format$(Time, "hh:mm:ss"); ","; _
Format(LIW_Flow_WY_100.Value, "##0.00"); ","; _
Format(DensitySP_FCV101_D.Value, "##0.00"); ","; _
Format(EvapSP_FCV101_E.Value, "##0.00"); ","; _
Format(MoistureSP_FCV101_M.Value, "##0.00"); ","; _
Format(FlowSP_FCV101_L.Value, "##0.00"); ","; _
Format(MagFlow_FT_101.Value, "##0.00"); ","; _
Format(Moisture_AT_103.Value, "##0.00"); ","; _
Format(Pressure_PT_106.Value, "##0.00"); ","; _
Format(Level_LT_117.Value, "##0.00"); ","; _
Format(LIW_Flow_WY_200.Value, "##0.00"); ","; _
Format(DensitySP_FCV201_D.Value, "##0.00"); ","; _
Format(EvapSP_FCV201_E.Value, "##0.00"); ","; _
Format(MoistureSP_FCV201_M.Value, "##0.00"); ","; _
Format(FlowSP_FCV201_L.Value, "##0.00"); ","; _
Format(MagFlow_FT_201.Value, "##0.00"); ","; _
Format(Moisture_AT_203.Value, "##0.00"); ","; _
Format(Density_DT_301.Value, "##0.00"); ","; _
Format(Temperature_TT_107.Value, "##0"); ","; _
Format(Temperature_TT_112.Value, "##0"); ","
Else
'If time anything other than 12:00 and 12:01 midnight just insert the data
Print #LogFile, Format$(Time, "hh:mm:ss"); ","; _
Format(LIW_Flow_WY_100.Value, "##0.00"); ","; _
Format(DensitySP_FCV101_D.Value, "##0.00"); ","; _
Format(EvapSP_FCV101_E.Value, "##0.00"); ","; _
Format(MoistureSP_FCV101_M.Value, "##0.00"); ","; _
Format(FlowSP_FCV101_L.Value, "##0.00"); ","; _
Format(MagFlow_FT_101.Value, "##0.00"); ","; _
Format(Moisture_AT_103.Value, "##0.00"); ","; _
Format(Pressure_PT_106.Value, "##0.00"); ","; _
Format(Level_LT_117.Value, "##0.00"); ","; _
Format(LIW_Flow_WY_200.Value, "##0.00"); ","; _
Format(DensitySP_FCV201_D.Value, "##0.00"); ","; _
Format(EvapSP_FCV201_E.Value, "##0.00"); ","; _
Format(MoistureSP_FCV201_M.Value, "##0.00"); ","; _
Format(FlowSP_FCV201_L.Value, "##0.00"); ","; _
Format(MagFlow_FT_201.Value, "##0.00"); ","; _
Format(Moisture_AT_203.Value, "##0.00"); ","; _
Format(Density_DT_301.Value, "##0.00"); ","; _
Format(Temperature_TT_107.Value, "##0"); ","; _
Format(Temperature_TT_112.Value, "##0"); ","
End If
Close #LogFile
'If the directory already exists, skip to the next line
'Error 75 is directory already created or exists.
catch: 'Error handling routine
If Err.Number = 75 Then
Err.Clear
GoTo Check
Else:
If Err.Number = 4170 Then
Print "Error#4170--Communications driver is not available."
'roErrorTagEvent (4170) - an error occurred while waiting for the operation to complete
Err.Clear
GoTo Check
End If 'End errror #4170
Err.Clear
End If 'End errror handling
OldLogDate = LogDate
End Sub