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 multiple serial devices that burst data


erehm Sep 9, 2023 12:36 AM

I'm looking to log data for four RS-232 serial devices that will burst data (CR/LF terminated ASCII strings)  at 1 Hz for 10 seconds every XX minutes, where XX is probably 15. On each serial device, I can specify data rate (1 Hz), burst size (10 samples), and burst interval (15 min = 900 s).  The devices are not synchronized.

Inelegant solution:  Starting wtih just one sensor, I scan continuously a 1 Hz and test the value NBytesReturned from SerialInRecord. (NBytesReturned is guaranteed to be >= 42 if the sensor has valid output.)  So, I conditionally CallTable based on the value of NBytesReturned. 

The nice thing about this is that I don't have to change any code should I change the burst interval on any device.

This works reliably,  I think I can do the same trick in the Main program with the other devices inside the same Scan loop.  But is there a more elegant solution?    

-- Eric

 

DataTable (EcoTriplet,1,-1) 'Set table size to # of records, or -1 to autoallocate.
   Sample (1,Chl470,Long)
   Sample (1,Beta700,Long)   
   Sample (1,FDOM,Long)
   Sample (1,RawString,String) 
EndTable

'Define Subroutines
'Sub
'EnterSub instructions here
'EndSub

'Main Program
BeginProg
  SerialOpen (PortEco,19200,0,0,200,0)
  Scan (1,Sec,3,0)
    'Each Eco record is a tab-delimited string of 42-48 bytes plus :
    '99/99/99	99:99:99	695	xx38	700	xx49	460	xx41	999
     SerialInRecord (PortEco,RawString,&h0A,0,&h0D,NBytesReturned,01)   
    
    'Get counts for each measurement by splitingt string at tabs CHR(09)
    SplitStr (SplitStrings(1),RawString,CHR(09),9,5)
    Chl470=SplitStrings(4)      'xx38, where xx are additional digits
    Beta700=SplitStrings(6)     'xx49
    FDOM=SplitStrings(8)        'xx41
    
    'Update table
    If NBytesReturned >= 42 Then
      CallTable EcoTriplet
    EndIf
  NextScan
 
  
EndProg

 


 

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