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.

CR6 + GILL HS-50 anemometer


JBL Nov 18, 2015 07:18 AM

Hi,

I try to interface an HS-50 with a CR6 datalogger through full duplex RS-485 (ComC1 -> C1, C2, C3 and C4).

HS-50 output data are binary like this: "BA BA 01 FF..."
I can't use the ASCII mode because data are also received by Eddy Meas software.

In my program, I have tried to use "SerialIn", "SerialInRecord" and 'SerialInBlock" but received data are always displayed in non ASCII characters. I have tried differents connection parameters like TTL or RS232, data bits...

With the Campbell terminal emulator, I can see binary data properly...

Could you explain to me the difference between terminal and serial instructions?


My programm is available below:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'CR6 Series Datalogger
'date: 30/09/2015
'program authors: Jean-Baptiste LILY & Patrick GROSS
'Society: INRA Champenoux, EEF, ARBECO team
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Program description: LI-7200 ethernet connection V1.0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Bug fix

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PipeLineMode


Public LI_7200(22) As String * 10
Public Ligne_Config_LI7200(5) As String * 150 '140
Public Param_LI7200 As String * 700
Public i As Long'
Public tcpip_0 As Long
Public tcpip_1 As Long
Public tcpip_2 As Long
Public exec_time(5) As Long
Public tcp_close As Boolean
Public tcp_open As Boolean
Const GA_72_SCAN_BUFF_SIZE = 20 'Number of LI-7200 records to stack in the serial buffer, before extracting data with SerialInRecord(). This is done to minimize NAN.
Dim ga_72_socket As Long
Dim ga_72_scan_cntr As Long
Public DATA_String As String * 1000
Public ga_72_nmbr_bytes_rtrnd As Long
Public Nb_lignes_Config_LI7200 As Float
Public Diag_Storage, Valid_OK As Boolean
Public rTime(9) As Float'
Public OutStat As Float
Public OutStat1 As Float
Public LastFileName As String * 30
Public LastFileName1 As String * 30
Public DataFile As String * 30
Public DataFile1 As String * 30
Public timevalue As String * 30
''Public test
Public NBytesReturned As Float
Public Sonic_SubString(10) As String * 10
Public Sonic_String As String * 50
Public Param_Anemo As String * 80
Public Nb_lignes_Config_Anemo As Float
Public Ligne_Config_Anemo(2) As String * 40
Public proctime As Long
Const CRLF = CHR(13) & CHR(10) 'Caracteres <retour chariot> et <fin de ligne>
Public Split_Diag(16) As Boolean
Public Diag1_Long As Long
Public Diag1_Bin As String * 16
Public test As Float
Public conversion As String


'Nommage automatique fichiers
Public PTemp, batt_volt
Public HHMM As String * 4
Public HHMM1 As String * 4
Public JJJ As String * 3
Public JJJ1 As String * 3
Public YYYY As String * 4

Alias LI_7200(1) = Sequence_Number
Alias LI_7200(2) = Diag1 'A 1Hz
Alias LI_7200(3) = Diag2 'A 1Hz
Alias LI_7200(4) = Date 'Date sur l'analyseur
Alias LI_7200(5) = Time_Heure 'Heure sur l'analyseur
'Alias LI_7200(6) = Time_Minutes
'Alias LI_7200(7) = Time_Secondes
Alias LI_7200(6) = CO2D
Alias LI_7200(7) = H2OD
Alias LI_7200(8) = Pres
Alias LI_7200(9) = DPres
Alias LI_7200(10) = SFVin 'NON UTILISE
Alias LI_7200(11) = CO2MFd
Alias LI_7200(12) = H2OMF 'MFd??????
Alias LI_7200(13) = AvgTemp
Alias LI_7200(14) = TempIn
Alias LI_7200(15) = TempOut
Alias LI_7200(16) = MeasFlowRate 'A 1Hz dans table Diag
Alias LI_7200(17) = FlowPressure 'A 1Hz dans table Diag
Alias LI_7200(18) = FlowDrive 'A 1Hz dans table Diag
Alias LI_7200(19) = H2OAW
Alias LI_7200(20) = H2OAWO
Alias LI_7200(21) = CO2AW
Alias LI_7200(22) = CO2AWO

Alias Sonic_SubString(1) = Status_Addr 'A 1Hz dans table Diag
Alias Sonic_SubString(2) = Status_Data 'A 1Hz dans table Diag
Alias Sonic_SubString(3) = U_Axis 'In m.s-1
Alias Sonic_SubString(4) = V_Axis 'In m.s-1
Alias Sonic_SubString(5) = W_Axis 'In m.s-1
Alias Sonic_SubString(6) = Speed_Of_Sound 'In m.s-1 (Not used)
Alias Sonic_SubString(7) = Sonic_Temp 'In K degree
Alias Sonic_SubString(8) = CO2D_bis
Alias Sonic_SubString(9) = H2O_bis
Alias Sonic_SubString(10) = Inclinometer_Values 'In degree

Alias Split_Diag(1) = Signal_Strength0 'Pas ICOS
Alias Split_Diag(2) = Signal_Strength1 'Pas ICOS
Alias Split_Diag(3) = Signal_Strength2 'Pas ICOS
Alias Split_Diag(4) = Signal_Strength3 'Pas ICOS
Alias Split_Diag(5) = Synch
Alias Split_Diag(6) = PLL
Alias Split_Diag(7) = DetOK
Alias Split_Diag(8) = Chopper
Alias Split_Diag(9) = PDif
Alias Split_Diag(10) = Aux_Input 'Pas ICOS
Alias Split_Diag(11) = Tin
Alias Split_Diag(12) = Tout
Alias Split_Diag(13) = Head
'Alias Split_Diag(14) = Not_Used
'Alias Split_Diag(15) = Not_Used
'Alias Split_Diag(16) = Not_Used

Alias Diag1_Bin = DiagVal


'Declaration des unites
'Units Time_Heure = h
'Units Time_Minutes = mins
'Units Time_Secondes = s
Units CO2D = umol.m-3
Units H2OD = mmol.m-3
Units Pres = kPa
Units DPres = kPa
Units CO2MFd = umol.mol-1
Units H2OMF = mmol.mol-1
Units AvgTemp = degres C
Units TempIn = degres C
Units TempOut = degres C
Units MeasFlowRate = l.min-1
Units FlowPressure = kPa
Units U_Axis = m.s-1
Units V_Axis = m.s-1
Units W_Axis = m.s-1
Units Sonic_Temp = degres C
Units Inclinometer_Values = degres

'Declaration des tables
DataTable (Ethernet_data,TRUE,-1)
DataInterval (0,1,min,10)
Sample (1,LI_7200(1),IEEE4)
Sample (2,LI_7200(4),String)
Sample (17,LI_7200(6),IEEE4)
'Sample (1,proctime,Long) '(For debug)
'Sample (1,ga_72_nmbr_bytes_rtrnd,IEEE4)
Sample (3,Sonic_SubString(3),IEEE4) 'Extraction donnees anemometre
Sample (3,Sonic_SubString(7),IEEE4) 'Suite extraction donnees anemometre


TableFile("USR:U",8,-1,0,1,min,OutStat,LastFileName) 'Creation d'une table de donnes a 20 Hz sur la carte micro SD

If(OutStat = -1) Then 'Nommage auto fichiers selon horloge centrale
Call Nommage 'Appel sous programme de creation de noms formalises
DataFile = "USR:U"+rTime(1)+JJJ1+HHMM1+".dat" 'Concatenation des donnees pour former le nom du fichier
FileRename(LastFileName,DataFile) 'Renommage du fichier sur la carte CF
EndIf
EndTable

DataTable (Diagnostique,Valid_OK,-1) 'Table d'enregistrement des variables de diagnostique a 1 Hz

'Sample (2,LI_7200(2),IEEE4) 'Extraction Diag1 et Diag2 (LI-7200)
Sample(1,DiagVal,String) 'DiagVal en binaire
Sample (3,LI_7200(16),IEEE4) 'Extraction MeasFlowRate, FlowDrive et FlowPressure (LI-7200)
Sample (2,Sonic_SubString(1),IEEE4) 'Extraction donnees status anemometre
Sample (1,Sonic_SubString(10),IEEE4) 'Extraction donnees inclinometre de l anemometre
Sample (1,Sonic_String,String)


TableFile("USR:DIAG",8,-1,0,30,min,OutStat1,LastFileName1) 'Creation d'une table de donnes sur la carte micro SD

If(OutStat1 = -1) Then 'Nommage auto fichiers selon horloge centrale
Call Nommage 'Appel sous programme de creation de noms formalises
DataFile1 = "USR:DIAG"+rTime(1)+JJJ1+HHMM1+".dat" 'Concatenation des donnees pour former le nom du fichier
FileRename(LastFileName1,DataFile1) 'Renommage du fichier sur la carte CF
EndIf

EndTable


Sub Initialisation

tcpip_0 = SerialInChk (ga_72_socket)
If (tcpip_0 = -1) Then
ga_72_socket = TCPOpen ("192.168.1.125",7200,1000*8)
EndIf

Nb_lignes_Config_LI7200 = 5
Ligne_Config_LI7200(1) = "(Outputs(ENet(Freq 0)(Ndx TRUE)(Time TRUE)(Date TRUE)(CO2Raw FALSE)(H2ORaw FALSE)(DiagRec FALSE)(DiagVal TRUE)(DiagVal2 TRUE)(CO2D TRUE)(H2OD TRUE)" 'Freq = 0 pour mode polled!
Ligne_Config_LI7200(2) = "(Temp FALSE)(AvgTemp TRUE)(TempIn TRUE)(TempOut TRUE)(Pres TRUE)(APres FALSE)(DPres TRUE)(FlowPressure TRUE)(MeasFlowRate TRUE)"
Ligne_Config_LI7200(3) = "(VolFlowRate FALSE)(FlowPower FALSE)(FlowDrive TRUE)(Aux FALSE)(Aux2 FALSE)(Aux3 FALSE)(Aux4 FALSE)(Cooler FALSE)(CO2MF FALSE)(CO2MFd TRUE)"
Ligne_Config_LI7200(4) = "(H2OMF FALSE)(H2OMFd TRUE)(DewPt FALSE)(H2OAW TRUE)(H2OAWO TRUE)(CO2AW TRUE)(CO2AWO TRUE)(AvgSS FALSE)(CO2SS FALSE)(CO2MG FALSE)(H2OG FALSE)"
Ligne_Config_LI7200(5) = "(H2OSS FALSE)(DeltaSS FALSE)(DIAG FALSE)(RSSI FALSE)(CH4D FALSE)(CH4 FALSE)(NANOSECONDS FALSE)(SECONDS FALSE)(Labels TRUE))(BW 5))" 'ATTENTION (BW 10) dans les () de Outputs et non ENet!!!!

For i = 1 To Nb_lignes_Config_LI7200
Param_LI7200 = Param_LI7200 & Ligne_Config_LI7200(i)
Next i
SerialOutBlock (ga_72_socket,Param_LI7200+CHR(10),700)

'Configuration de l'anemometre GILL HS-50 en mode UVW-continu

'CONFIGURE PAR EDDY MEAS!!!!!!!!!

' Nb_lignes_Config_Anemo = 2 '2
' Ligne_Config_Anemo(1) = "*" & "A4" & CRLF & "C2" & CRLF & "E1" & CRLF & "G0" & CRLF & "H2" & CRLF & "I1" & CRLF & "J1" & CRLF & "K50" & CRLF & "L1" & CRLF
' Ligne_Config_Anemo(2) = "NQ" & CRLF & "O1" & CRLF & "P8" & CRLF & "S3" & CRLF & "T1" & CRLF & "U1" & CRLF & "V1" & CRLF & "X1" & CRLF & "M1" & CRLF & "Q" & CRLF 'P8 pour 20Hz P6 pour 10Hz
' 'Ligne_Config_Anemo(1) = "*" & "D3" & CRLF 'Ordre de recup trame de config (pour debug)
' 'Ligne_Config_Anemo(1) = "Q" & CRLF 'Ordre de re-passage en mode mesure (pour debug)
'
' For i = 1 To Nb_lignes_Config_Anemo 'Concatenation des lignes de commandes de l anemometre
' Param_Anemo = Param_Anemo & Ligne_Config_Anemo(i)
' Next i
'
' SerialOut(SensorPort,Param_Anemo,"",15,100) 'Envoi trame d'initialisation: verification envoi par lecture du caractere "M1"
EndSub


Sub Nommage
RealTime(rTime()) 'Appel a l'horloge temps reel centrale
HHMM = rTime(4)*100+rTime(5) 'Concatenation heures mins
JJJ = rTime(9) 'Jour julien

Select Case HHMM 'Permet de forcer l'affichage des 0 sur les 4 digits de l'heure/mins
Case Is >= 1 AND <= 9
HHMM1 = "000" & HHMM
Case Is >= 10 AND <= 59
HHMM1 = "00" & HHMM
Case Is >= 100 AND <= 959
HHMM1 = "0" & HHMM
Case Is >= 1000 AND <= 2359
HHMM1 = HHMM
Case Else
HHMM1 = "0000"
EndSelect

Select Case JJJ 'Permet de forcer l'affichage des 0 sur les 3 digits du jour julien
Case Is >= 1 AND <= 9
JJJ1 = "00" & JJJ
Case Is >= 10 AND <= 99
JJJ1 = "0" & JJJ
Case Is >= 100
JJJ1 = JJJ
Case Else
JJJ1 = "000"
EndSelect
EndSub

Sub Split_Diag_Value

Diag1_Bin = FormatLong(LI_7200(2),"%016b")'Conversion de DiagVal en binaire (avec forcage des zeros sur 16bits: %016b
Diag1_Long = LI_7200(2) 'Conversion en long pour pouvoir effectuer le masque

Split_Diag(1) = Diag1_Long AND &h0001 'Utilisation de masques pour extraction des bits de diag
Split_Diag(2) = Diag1_Long AND &h0002
Split_Diag(3) = Diag1_Long AND &h0004
Split_Diag(4) = Diag1_Long AND &h0008
Split_Diag(5) = Diag1_Long AND &h0010
Split_Diag(6) = Diag1_Long AND &h0020
Split_Diag(7) = Diag1_Long AND &h0040
Split_Diag(8) = Diag1_Long AND &h0080
Split_Diag(9) = Diag1_Long AND &h0100
Split_Diag(10)= Diag1_Long AND &h0200
Split_Diag(11)= Diag1_Long AND &h0400
Split_Diag(12)= Diag1_Long AND &h0800
Split_Diag(13)= Diag1_Long AND &h1000
Split_Diag(14)= Diag1_Long AND &h2000
Split_Diag(15)= Diag1_Long AND &h4000
Split_Diag(16)= Diag1_Long AND &h8000
EndSub

BeginProg
TCPClose (101)

SerialOpen (ComC1,19200,19,0,200,5) 'Ouverture port RS485 Full duplex sur C1,C2,C3 et C4 (mode 16) => 19200, 8 bits data, 1 stop bit, no parity, no handshake

Call Initialisation 'Envoi trame initialisation LI-7200

Scan (50,mSec,10,0)

Diag_Storage = TimeIntoInterval (0,1,sec) 'Synchronisation table ethernet et diag (Ne surtout pas deplacer sinon saut de donnees!)

'LI-7200 data software buffer
If ( ga_72_scan_cntr > GA_72_SCAN_BUFF_SIZE ) Then 'Taille du buffer dans l'initialisation (20)
SerialInRecord (ga_72_socket,DATA_String,&h4E64,0,&h0A,ga_72_nmbr_bytes_rtrnd,11) 'Recuperation des donnees du LI-7200
SplitStr (LI_7200(),DATA_String,CHR(32),22,4) 'Decoupage des donnees

Call Split_Diag_Value

If ( ga_72_nmbr_bytes_rtrnd = 0 ) Then 'Flush and restack the TCP/IP input buffer with GA_72_SCAN_BUFF_SIZE number of records after communication is established.
ga_72_scan_cntr = 0
SerialFlush (ga_72_socket)
EndIf
Else
ga_72_scan_cntr += 1
EndIf

SerialOutBlock (ga_72_socket,"(Data ?)"+CHR(10),9) 'Configuration du LI-7200 en mode poll
proctime = Status.ProcessTime 'Process Time storage (For debug)

'HS-50

test = SerialInChk(ComC1)
SerialInBlock (ComC1,Sonic_String,100)
'conversion = FormatLong(Sonic_String,"%b")
'SerialIn (Sonic_String,ComC1,0,CHR(10),100)
'SerialInRecord (ComC1,Sonic_String,&h42,0,&h0A,NBytesReturned,01) 'Recherche de trame selon un caractere de debut <STX> et un de fin <ETX> de l'anemometre

SplitStr(Sonic_SubString(),Sonic_String,CHR(44),7,4) 'Extraction donnees de la trame separees par des virgules
SerialFlush(ComC1)
CallTable Ethernet_data

If Diag_Storage = TRUE Then 'Condition pour Diag_Storage vraie toutes les secondes
Valid_OK = TRUE
CallTable Diagnostique 'Appel du sous-programme de diag
Valid_OK = FALSE 'Remise a zero du flag de validation synchro tables ethernet et diag
EndIf

NextScan

EndProg


aps Nov 18, 2015 04:34 PM

I believe you are misinterpreting the Gill manual and the output shown in our terminal mode.

In the Gill manual it shows a hex representation of the binary data sent by the sensor, the actual data includes non-printable data so cannot easily be shown in their manual. The exact definition of the structure is shown in an Appendix of their manual.

When you use our terminal mode with the W "sniffer" option and select the binary mode the logger also converts the binary data and shows it as a hex representation.


JBL Nov 19, 2015 07:42 AM

M. Sandford,

Thx for your answer. I now it's an hexadecimal representation of binary data; so is it possible to display the data in the connect screen like in sniffer as a hex representation and no ASCII?

In the sniffer, you can choose ASCII or binary representation, so I think it's also possible in my CRBasic program.


aps Nov 19, 2015 09:28 AM

We do not have an option to show a string variable in hexadecimal format in the connect screen.

If you want to see binary data in a hexadecimal form in that screen you would need to write a little code in your program to create a new display string with hex values in it.

A word of warning when doing this and also processing binary data returned from the sensor, which is to be aware that normal string functions will stop at the point where the first null (ASCII 0) character is found in a string. To deal with strings including nulls you have to work with them as an array of characters, typically use the syntax varname(1,1,i) for single dimensioned strings.


Chakir Dec 26, 2015 01:43 PM

hello JBL can i have the wiring for HS 50 that you have made to connect it in CR6 ?

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