How to read sensor that auto streaming-data using by PAC control?


#1

I had a sensor that could stream data. If i connected it with computer using by hyper terminal the result would be like this

☻0015008???0000
☻0015008???0030
☻0015008???0200
☻0015008???0090
...

The results is auto-streaming text. And the last for digits is values that i need.
I think this is very simple case for professional but i’m new in this software.

my question is:
How could i get these digits into variable?
Do you have some simple codes example(flowchart)?
#i connected sensor via RS-232 (the green one), SNAP PAC R2

Thank you in advance.


#2

Hi terces
Check out this old forum post for a bit of guidance for reading in serial data. http://www.opto22.com/community/showthread.php?t=112
I think there is another example floating around the forums that Mary posted as well.

Here’s a brief process that should get you started.

It looks like the string is terminated with a crlf so by setting your end-of-message terminator to 10 will ensure you read the complete string in at a time. It is then a matter of parsing the string and converting them to numbers.

Commands like ‘get substring’ or ‘get nth character’ will enable you to strip out the individual or groups of numbers you need to convert to a number. get substring will get a group of characters where get nth character will get an individual character at position n. Remember all strings start at index 0.

After getting the group of characters he command ‘convert string to number’ will enable the step of making the string data an integer. This can now be manipulated in the strategy as you see fit.

I hope this helps.

Nick