Dear ...
Could you help me, where i put serialopen and serialout command to send printable ASCII (data flow) through COM1 for data table D_10mnt only.
Thank You
'CR1000
'Declare Variables and Units
Dim AirTC_17
Public BattV
Public BP_mbar
Public Rain_mm
Public AirTC
Public RH
Public SlrkW
Public SlrMJ
Public WS_ms_2
Public WindDir
Public Temp_C
Public Tot24jam
Public TdC
Public WR_m
Public VW
Public PA_uS
Public WS_knot
Public Flag(8) As Boolean
Units BattV=Volts
Units BP_mbar=mbar
Units Rain_mm=mm
Units AirTC=Deg C
Units RH=%
Units SlrkW=kW/m^2
Units SlrMJ=MJ/m^2
Units WS_ms_2=meters/second
Units WindDir=Degrees
Units Temp_C=Deg C
Units TdC=Deg C
Units WR_m=meters
Units PA_uS=uSec
'Define Data Tables
DataTable(Sesaat,True,-1)
DataInterval(0,1,Min,10)
Sample(1,BP_mbar,FP2)
Totalize(1,Rain_mm,FP2,False)
Sample(1,AirTC,FP2)
Sample(1,RH,FP2)
Sample(1,SlrkW,FP2)
Sample(1,WS_ms_2,FP2)
Sample(1,WindDir,FP2)
Sample(1,Temp_C,FP2)
Sample(1,TdC,FP2)
Sample(1,WS_knot,FP2)
Sample(1,VW,FP2)
Sample(1,PA_uS,FP2)
EndTable
DataTable(D_10mnt,True,-1)
DataInterval(0,10,Min,10)
Minimum(1,BattV,FP2,False,False)
Average(1,BP_mbar,FP2,False)
Totalize(1,Rain_mm,FP2,False)
Average(1,AirTC,FP2,False)
Sample(1,RH,FP2)
Average(1,SlrkW,FP2,False)
Average(1,WS_ms_2,FP2,False)
Sample(1,WindDir,FP2)
Average(1,Temp_C,FP2,False)
Average(1,TdC,FP2,False)
Average(1,WS_knot,FP2,False)
Average(1,VW,FP2,False)
Average(1,PA_uS,FP2,False)
EndTable
DataTable(D_1jam,True,-1)
DataInterval(0,60,Min,10)
Average(1,BP_mbar,FP2,False)
Maximum(1,BP_mbar,FP2,False,False)
Minimum(1,BP_mbar,FP2,False,False)
Totalize(1,Rain_mm,FP2,False)
Average(1,AirTC,FP2,False)
Maximum(1,AirTC,FP2,False,False)
Minimum(1,AirTC,FP2,False,False)
Maximum(1,RH,FP2,False,False)
Minimum(1,RH,FP2,False,False)
Average(1,SlrkW,FP2,False)
Maximum(1,SlrkW,FP2,False,False)
Minimum(1,SlrkW,FP2,False,False)
Average(1,WS_ms_2,FP2,False)
Maximum(1,WS_ms_2,FP2,False,False)
Minimum(1,WS_ms_2,FP2,False,False)
Average(1,Temp_C,FP2,False)
Maximum(1,Temp_C,FP2,False,False)
Minimum(1,Temp_C,FP2,False,False)
Average(1,TdC,FP2,False)
Maximum(1,TdC,FP2,False,False)
Minimum(1,TdC,FP2,False,False)
Average(1,WS_knot,FP2,False)
Maximum(1,WS_knot,FP2,False,False)
Minimum(1,WS_knot,FP2,False,False)
Average(1,VW,FP2,False)
Maximum(1,VW,FP2,False,False)
Minimum(1,VW,FP2,False,False)
Average(1,PA_uS,FP2,False)
Maximum(1,PA_uS,FP2,False,False)
Minimum(1,PA_uS,FP2,False,False)
EndTable
DataTable(D_24jam,True,-1)
DataInterval(0,1440,Min,10)
Totalize(1,Rain_mm,FP2,False)
Totalize(1,WR_m,FP2,False)
Sample(1,Tot24jam,FP2)
EndTable
'Main Program
BeginProg
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'CS106 Barometric Pressure Sensor measurement BP_mbar
PortSet(1,1)
VoltSE(BP_mbar,1,mV2500,1,1,0,_60Hz,0.240,500)
'TB4/TB4MM Rain Gauge measurement Rain_mm
PulseCount(Rain_mm,1,1,2,0,0.2,0)
'HMP155 (constant power) Temperature & Relative Humidity Sensor measurements AirTC and RH
VoltSE(AirTC,1,mV2500,2,0,0,_60Hz,0.14,-80)
VoltSE(RH,1,mV2500,3,0,0,_60Hz,0.1,0)
If RH>100 And RH<108 Then RH=100
'LI200X Pyranometer measurements SlrMJ and SlrkW
VoltDiff(SlrkW,1,mV7_5,3,True,0,_60Hz,1,0)
If SlrkW<0 Then SlrkW=0
SlrMJ=SlrkW*0.0002
SlrkW=SlrkW*0.2
'03002 Wind Speed & Direction Sensor measurements WS_ms_2 and WindDir
PulseCount(WS_ms_2,1,2,1,1,0.75,0.2)
If WS_ms_2<0.21 Then WS_ms_2=0
BrHalf(WindDir,1,mV2500,9,1,1,2500,True,0,_60Hz,352,0)
If WindDir>=360 Then WindDir=0
'105T (copper-constantan) Thermocouple measurements Temp_C
TCDiff(Temp_C,1,mV2_5C,6,TypeT,AirTC,True,0,_60Hz,1,0)
'24 hour running total calculation Tot24jam
Tot24jam=Tot24jam+Rain_mm
If IfTime(0,1440,Min) Then Tot24jam=0
'Dew Point calculation TdC
AirTC_17=AirTC
DewPoint(TdC,AirTC_17,RH)
If TdC>AirTC_17 Or TdC=NAN Then TdC=AirTC_17
'Wind Run calculation WS_ms_2
'Convert to meters per second if needed and multiply by the scan rate in seconds
WR_m=WS_ms_2*0.27778*1
'CS616 Water Content Reflectometer measurements VW and PA_uS
CS616(PA_uS,1,4,2,1,1,0)
VW=-0.0663+(-0.0063*PA_uS)+(0.0007*PA_uS^2)
'User Entered Calculation
WS_knot = WS_ms_2 * 1.94
'Call Data Tables and Store Data
CallTable(Sesaat)
CallTable(D_10mnt)
CallTable(D_1jam)
CallTable(D_24jam)
NextScan
EndProg
This is how I would accomplish the task. You didn't specify how you wanted the data to come out so I made it comma separated and added CR/LF at the end. You can get a general idea from this and modify as you see fit.
Add these to your public declarations:
Public Avg10mnt(13)
Public Avg10msg As String * 100
Public BattVout As String
Public BPout As String
Public Rainout As String
Public AirTCout As String
Public RHout As String
Public SlrkWout As String
Public WSout As String
Public WindDirOut As String
Public Tempout As String
Public TdCout As String
Public WSktout As String
Public VWout As String
Public PAuSout As String
Add this between BeginProg and Scan:
SerialOpen (Com2,9600,0,0,100)
**** NOTE ****
You have C1 and C2 occupied in the program, you have to use COM2 which is C3 and C4. You can change the 9600 Baud to whatever you need.
Add this to the bottom of the program between CallTable(D_24jam) and Next Scan
'Check to see if the D_10mnt table has been written
If D_10mnt.Output(1,1) Then
'Get the records from the data table
GetRecord (Avg10mnt(),D_10mnt,1)
'Format the data into strings
BattVout = FormatFloat (Avg10mnt(1),"%4.1f")
BPout = FormatFloat (Avg10mnt(2),"%6.1f")
Rainout = FormatFloat (Avg10mnt(3),"%5.2f")
AirTCout = FormatFloat (Avg10mnt(4),"%5.1f")
RHout = FormatFloat (Avg10mnt(5),"%5.1f")
SlrkWout = FormatFloat (Avg10mnt(6),"%6.1f")
WSout = FormatFloat (Avg10mnt(7),"%5.1f")
WindDirOut = FormatFloat (Avg10mnt(8),"%3.0f")
Tempout = FormatFloat (Avg10mnt(9),"%5.1f")
TdCout = FormatFloat (Avg10mnt(10),"%5.1f")
WSktout = FormatFloat (Avg10mnt(11),"%5.1f")
VWout = FormatFloat (Avg10mnt(12),"%5.1f")
PAuSout = FormatFloat (Avg10mnt(13),"%5.1f")
'Compile the individual data into a message string
Avg10msg = BattVout + "," + BPout + "," + Rainout + "," + AirTCout + "," + RHout + "," + SlrkWout + "," + WSout + "," + WindDirOut
Avg10msg = Avg10msg + "," + Tempout + "," + TdCout + "," + WSktout + "," + VWout + "," + PAuSout + CHR(13) + CHR(10)
'send the message out the serial port
SerialOut (Com2,Avg10msg,"",0,100)
EndIf
Dave's answer is thorough and gives you a lot of flexibility. However, if you just need the complete record sent out you can use the GetRecord instruction, as Dave suggested, but write it to a single STRING variable. From the GetRecord Help:
...if the Dest parameter is a single-dimensioned variable formatted as a string, all data values will be stored in the one variable. The data values will be separated by commas and the string will have a <crlf> termination...
Like this: GetRecord (Avg10msg,D_10mnt,1)
Regards,
Janet
Thanks for that tip Janet, I didn't know about that one.
Maybe I should come for some training :-)
Dear Dave Adam,
Thank For the quick response
Ariffudin