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.

Logging Gill Windmaster Pro Using Serial Communications


Brent Apr 17, 2009 05:10 PM

Hello,

I am presently trying to log data from a Gill Windmaster Pro Sonic anemometer to a CR3000 using a serial stream. I know that the Gill is outputting a constant serial stream, because I can view the stream in hyperterminal.

I have the transmit and receive wires from the Gill hooked up to the Tx/Rx ports of Com3, and I have written the following program to retrieve the data from the Gill:


'-------------------------------------------
'Declare Windmaster variables
Public rawdata As String * 52
Public BytesReturned As Float
'rmc variables
Public u_wind As String
Public v_wind As String
Public w_wind As String
Public Ts As String

DataTable(gill,True,-1)
DataInterval(0,100,mSec,10)
Sample (1,u_wind,String)
Sample (1,v_wind,String)
Sample (1,w_wind,String)
Sample (1,Ts,String)
EndTable
'Main Program
BeginProg
SerialOpen(Com3,19200,0,0,500) 'Opens the com port
Scan(100,mSec,0,0)
SerialInRecord (Com3,rawdata,2,0,3,BytesReturned,01)
' Parse Gill data
u_wind=Mid(rawdata,4,8)
v_wind=Mid(rawdata,13,8)
w_wind=Mid(rawdata,22,7)
Ts=Mid(rawdata,40,7)
CallTable gill
NextScan
EndProg
'-------------------------------------

Unfortunately, no data shows up on my CR3000! The string variables remain blank, and the one numeric variable (BytesReturned) sits at 0.

Anybody have any idea what I'm doing wrong?

Some other notes:
-I'm sure the Baud rate is correct
-I don't know how to calculate how many bytes I need for the last argument of the SerialOpen command
-The Gill manual states that the start and end characters for the output ASCII string are 2 and 3 respectively, so that's where I got the numbers to place in the SerialInRecord arguments.

Any help would be appreciated!

Thanks,
-Brent.


artmann Apr 17, 2009 08:57 PM

Hi Brent,

some weeks ago i had to read data from a gill windmaster too.
At a slower rate and a different format i got it working on a CR1000(ComPort set via Device Configuration Tool).
Here is some code i can't test anymore, but i think it should work with some tweaking (baudrate,com-port,timing?).

'//////////////////////////////////////////////////
Const STX=CHR(2) 'ASCII start-of-text
Const ETX=CHR(3) 'ASCII end-of-text
Const USA_PORT=Com4
Const usa_string_expected_length=39 'IMPORTANT : GILL sends string with constant length.check format

Public usa_token(5) As Float
Alias usa_token(1) = USA_Dir
Alias usa_token(2) = USA_Speed
Alias usa_token(3) = USA_W
Alias usa_token(4) = USA_Temp
Alias usa_token(5) = USA_Status

Public usa_string As String * 50
Public usa_num_success As Long
Public usa_num_failure As Long
Public usa_num_bytes_in_buffer As Long

Dim usa_buffer As String * 100
Dim success As Boolean

'/// check buffer > read until STX > read until ETX > check length > tokenize > check for NANs
Function usa_read_data_from_gill() As Boolean

Dim USA_Valid As Boolean
Dim istart As Long
Dim iend As Long
Dim i As Long

USA_Valid = false
usa_buffer = ""
usa_num_bytes_in_buffer = SerialInChk(USA_PORT) 'any chars received?

If usa_num_bytes_in_buffer>0 Then
SerialIn(usa_buffer,USA_PORT,50,STX,200) 'read buffer until STX
SerialIn(usa_buffer,USA_PORT,50,ETX,200) 'read until ETX > complete string
EndIf
USA_Valid = IIF(Len(usa_buffer)=usa_string_expected_length,true,false)
If USA_Valid Then
iStart = InStr (1,usa_buffer,"Q",2)+2
iEnd = InStr (1,usa_buffer,ETX,2)-1
usa_string = Mid(usa_buffer,iStart,iEnd-iStart)
SplitStr (usa_token(),usa_string,"",5,0)
For i=1 To 5 'check vals
If usa_token(i)=NAN OR usa_token(i)>998 Then
USA_Valid = false 'if one value smells fishy discard all
EndIf
Next i
Else 'mark as invalid
For i=1 To 5 step 1
usa_token(i)=-1
Next i
EndIf
Return USA_Valid
EndFunction

'///
DataTable (Gill_Table,1,1000)
DataInterval (0,1,Sec,10)
Sample (5,usa_token(1),FP2)
EndTable

'///
BeginProg
SerialOpen (USA_PORT,9600,0,100,512) 'stays open
Scan (1,Sec,0,0)
success=usa_read_data_from_gill()
If success Then
usa_num_success = usa_num_success +1
Else
usa_num_failure = usa_num_failure +1
EndIf

CallTable Gill_Table
NextScan
EndProg

'//////////////////////////////////////////////////

The double reading for STX/ETX, the searching for "Q" and the two string-buffers look a bit clumsy now when i look at it, but this is quit near to the working final code.
I remember i even used a SerialFlush.
Hope this helps a bit.

greets artmann

* Last updated by: artmann on 4/17/2009 @ 3:01 PM *


SimonF Apr 22, 2009 03:06 AM

It sounds like there could be something wrong with the connections or port setup. I don’t know much about this other than it is easy to get wrong! I think there needs to be an earth connection as well as the Tx/Rx. It might be best to try it out using the logger RS232 port for a start, using the exact same connection as you had working with HyperTerminal.

I have seen the Gill serial data being logged successfully, and I have some code that generally works. But it occasionally misses a row of data. This might be due to the Gill and CR1000 not being synchronized. I have been wondering whether polling for the data might be a solution, but I don't know how the timing would work.

SimonF


febrama Oct 20, 2011 03:22 PM

somebody tried connect with differential channels? My own experience with other anemometer, especifically RM-young 81000, working with CR1000 or CR5000 indicate this connection is better than serial COM port.


geoeric Dec 16, 2016 04:22 AM

hello Brent

did you finally get the program working for your CR3000 with the windmaster pro? I have the same problem with a CR1000.

regards


MJMagaji Jul 5, 2017 11:38 PM

Good morning house. My station was reporting data in hourly now, it stop reporting daily but it was doing that before. How will I set it to be reporting on daily basis, and how would I convert the reported one to daily especially Max and Min temperature and the rest. Thanks, waiting for your responses.


MJMagaji Jul 5, 2017 11:38 PM

Good morning house. My station was reporting data in hourly now, it stop reporting daily but it was doing that before. How will I set it to be reporting on daily basis, and how would I convert the reported one to daily especially Max and Min temperature and the rest. Thanks, waiting for your responses.


MJMagaji Jul 5, 2017 11:38 PM

Good morning house. My station was reporting data in hourly now, it stop reporting daily but it was doing that before. How will I set it to be reporting on daily basis, and how would I convert the reported one to daily especially Max and Min temperature and the rest. Thanks, waiting for your responses.

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