From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-12-2014 07:16 AM
I have a flow meter that when you write "x" to it over serial it spits out two lines:
Time HH:MM:SS MM/DD/YYYY
#1 METER #1 1234.22121 SCFM 121321 SCF
Initially I simply turned off the termination characters and read everything, and just set my bytes to read at how long this message was. But turns out this is different for every flow meter even if they are the same model. The manufactuer told me:
The output of the “x” command is a text string which is the summary of the configured meters. The number of bytes is dependent with the number of configured meters and the value of the measured variables. So the output is not a constant number of bytes and we don’t have a way to control this. The thing that I did before is, instead of counting the number of bytes on the response, I will look for the “LINE FEED” character to terminate a line. The model 155 is consistently append the CR LF character combinations every end of the line. And for the “x” command it will respond to “LOGGING DATA TO TERMINAL” heading as the 1st line then TIME and DATE for the 2nd line then METER 1 summary for the 3rd line, METER 2 summary for the 4th and so on.
I only have the 1 meter so how do i wire up a read after line feed? and how do I make sure that it reads both before changing the valuein the flow supply numeric indicator? Usually when it does not find the #1METER#1 string it puts out a 0 which makes my later calculations with this flow value worthless.
Solved! Go to Solution.
05-12-2014 07:24 AM
Just do two reads for each "x" command. The first will return the time, the second will return your data.
05-12-2014 07:25 AM - edited 05-12-2014 07:26 AM
You mean wire a second read after the first or a new write as well? The meter takes a good 250ms to spit out both lines after each x and querying too soon starts it over. Or do you mean split the wire coming from the write into two reads?
05-12-2014 07:45 AM - edited 05-12-2014 07:46 AM
Like this
05-12-2014 07:49 AM
05-12-2014 07:50 AM
05-12-2014 08:09 AM
Rereading everything here.
Are you getting the first header data that the manufacturer said you should? The data lines should be:
LOGGING DATA TO TERMINAL
Time HH:MM:SS MM/DD/YYYY
#1 METER #1 1234.22121 SCFM 121321 SCF
And there should be a line feed at the end of each line. So we should actually be doing 3 reads for each "x" command, letting the termination character do its job.
05-12-2014 08:11 AM - edited 05-12-2014 08:12 AM
I am not getting the header logging data. in either of my read buffers. What does the line feed look like? I am not seeing anything after SCF or the date.
05-12-2014 08:15 AM
05-12-2014 08:35 AM
This is where you start playing with a program like hyperterminal so you can see what is coming through everytime you type an "x". Once you have a clear picture, then you can figure out how many reads you need to do for everytime you type an "x".
Turn on \codes display on your indicators so you can see what a line feed "looks like".