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.

SerialIn in Slowsequence


rwc Jul 18, 2017 07:24 PM

Hi all:

I'm trying to read some RS232 from a current meter within a slow sequence, but am not seeing the output.  My weather instruments are sampling at 1 Hz in the main scan,  while I have the current meter slow sequence happening every five minutes.  

The current meter is woken up with a couple of text strings,  then told to take a single measurement (by sending 'MA').  The measurements are spit out after 60 seconds.  In the terminal emulator I can see the commands being transmitted to the instrument,  and the measurements coming back a minute later,  but they are not showing up in the SerialIn destination variable.

Here is the relevant code snippet, this is compiled in sequential mode:

BeginProg

Scan(1,sec,1,0)

Battery(BattV)
PanelTemp(PTemp_C,_60Hz)

VoltSe(AirTC,1,mV2500,1,0,0,_60Hz,0.1,-40)
VoltSe(RH,1,mV2500,2,0,0,_60Hz,0.1,0)
If RH>100 AND RH<103 Then RH=100

CallTable Wx
NextScan

'ADCP
SlowSequence
Scan(5,min,0,0)
SerialOpen (Com1,9600,3,0,1000)
SerialOut (Com1,"@@@@@@","",0,0) '1st of two "wake up" strings
Delay(0,100,msec) 'Wait 100 msec for 2nd string
SerialOut (Com1,"K1W%!Q",CHR(06)+CHR(06),0,0) '2nd string
Delay(0,10,Sec) 'Wait 2 sec for ADCP to boot
SerialOut (Com1,"MA",CHR(06)+CHR(06),20,10) 'Take sample
SerialFlush(Com1)
SerialIn (RawString,com1,7000,-1,1000) 'Wait and collect data
SplitStr (SplitStrings,RawString," ",137,0) ' Split out lines

NextScan

EndProg

...When I run just the current meter in its own program and one main scan (i.e. not in a slow sequence), it collects the data into RawString just fine, so I suspect there is something I don't appreciate about how the slow sequence is operating.   I have tried bumping up the SerialIn timeout (70 seconds has generally worked fine),  and using both options in the delay statements.  What am I missing?

Thanks, Rob


JDavis Jul 18, 2017 07:48 PM

Try moving the SerialFlush to before SerialOut. The instructions are going to run in the same order, but delays can be longer in slow sequence. The flush might be happening after data comes in.


rwc Jul 18, 2017 08:48 PM

Thanks.  I've also had success with using some very long timeouts (three minutes)- it seems like there's enough processing going on that it is taking quite a while for everything to happen in that sequence.

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