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.

RS232 Flow Sensor


Ruben Aug 14, 2009 03:00 PM

Hi,
I have a LinkQuest FlowScout sensor.
The serial communications is ASCII RS232 and I need to get the string, but the Datalogger CR800 don't show me the complete string.

I use com1 , 9600, 8 N ,1
SerialInrecord

Hyperterminal shows the string:

#&!LQFM.COMD2525 FM_STARTED
$#FM.ENSÈ2ÿ$*0xÜeËþ)E0ËfVE12E2FS2M.2.0.03 FS STK011ÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¶a

Does anyone have any idea?
because between E0 and E1 we find the real value.

Thankyou very munch.....


jra Aug 17, 2009 02:55 PM

Hi Ruben,

Your SerialInRecord instruction has a Destination Variable that you would have declared earlier in the Program. It would be something like:
Public FlowString as String * 20

What is the number after the *? If you don't have the * # then that it defaults to 16 characters. Try making that a larger number, a little bigger than needed is probably not a bad idea.

Let us know if that helps.
Janet


aps Aug 19, 2009 02:32 PM

The sensor is clearly outputting a load of binary characters. Whilst you can write these into a string in CRBasic, you then need to be careful how you process and view that data.

Firstly you need to be aware that CRBasic treats a null (char(0)) as the end of a string. So if there is a possibility the the data can have a null within it you have to process the string carefully, as most of the string functions in the logger will only process the string up to the null.

The normal trick in that instance is to use the command MoveBytes to move the data out of the string into another type of variable, e.g. one or more longs, and then process and/or store that data in that format.

If you do not have null characters then most string processing will work, however, if you view the string using our PC or in fact most other software products, if there are binary non-printing characters within the string (which there clearly are) what you see on the screen can be unpredictable depending on how the program interprets the characters, e.g. many will treat a carriage return literally and if found mid-string will cause the end of the string to be written on top of the start of the string.

As a general rule if there are binary characters though you need to convert them to another type to smooth the display and processing of the data from collection to storage on the PC.


MiguelR Aug 24, 2009 07:10 PM

Hi,

I am currently working with ruben in FlowScout in the chain that are read by the RS232 null characters, page breaks, carriage returns, for this reason we did not find how to read the string, when we try to read the string does not show any characters .

Any suggestions on how we could read that string?


MiguelR Aug 24, 2009 09:32 PM

this is the string we get with HyperTerminal, the data we want to read is the E0 to E1 and convert to decimal.

But all that we read SerialInBlock instruction is:

FM_STOPPED
2.0.003 FS STK011

* Last updated by: MiguelR on 8/24/2009 @ 3:48 PM *


jtrauntvein Aug 24, 2009 11:36 PM

All string handling in CRBasic is sensitive to a "null" terminator in the content. If the data that you will be reading is likely to contain null characters (character 0), you will be constrained to use SerialInBlock() as you have been trying. In order to know how much data was read, you will need to store the return value for SerialInBlock() into a variable. Because of null termination issues in character data, you will not be able to examine the contents of this buffer as data using LoggerNet.

One other behaviour that you should recognise for SerialInBlock() is that it will not block to read in the specified amount of data but will simply return whatever has been accumulated in the instruction input buffer. So whether the entire response is present in the buffer is going to greatly depend on the timing of your program. One way of giving the sensor enough time to output the entire string is to use the Delay() instruction prior to calling SerialInBlock(). Alternatively, you could implement logic that will look for the start of a "record" and then look for the end of the record as a state machine. The latter alternative, although more complex to implement, will likely be more robust.

* Last updated by: jtrauntvein on 8/25/2009 @ 7:18 AM *

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