Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I read a data stream from a com port

We have a scale that can transmit a continuous data string out one of its' com ports (RS232).  Can lookout read this string real time and extract parts of it so we can view what the weight on the scale is and use this weight in our process?  Thanks!
0 Kudos
Message 1 of 5
(4,052 Views)
Check out the Online Help on the ASCII Object. This Object is meant for just such applications.

-Khalid
0 Kudos
Message 2 of 5
(4,047 Views)

I have created and ascii object, set the com port settings, checked "monitor com port", and tried inserting an expression that is connected to the ascii object.  The format for com port string is:

<STX><POL><WWWWWWW><SP><Units><SP><Mode><SP><Status><CR><LF>

1   STX Start of Text Character (ASCII 02)

2   Polarity “-“ for Negative , Space for Positive

3 - 9   W    Weight String (Padded with spaces, includes decimal point) Least Significant Digit

10   Space ASCII 32

11 -12   Units    “KG” = Kilograms           “LB” = Pounds

13    Space ASCII 32

14 - 15   Mode   “GR” = Gross weight   “NT” = Net weight

16    Space ASCII 32

17    Status Space=Valid, “O”=Over, “M”=Motion, “-“=Negative

18    CR Carriage Return (ASCII 13)

19    LF Line Feed (ASCII 10)

 

The scale is setup as a continuous feed to the comport and we can see the data when we use hyperterminal.  The only information we need is characters 2-9 which is polarity and weight.  We would use the Mid(string,2,8) function and then convert the text to a numeric somehow, but we can't display the string to be able to use the Mid fubction.  We have no online help as this is a remote location and we have tried to understand the help menu and experimented but with no luck.  Thanks for taking the time to look at this!

Kevin

0 Kudos
Message 3 of 5
(4,022 Views)
Hi Kevin,

I am afraid ASCII Object isn't the easiest of Lookout objects. The Request and Response formats can be very tricky. I am actually surprised you have come this far without the documentation for it.

You can download the documentation for Lookout from here (see page 3-59):

http://www.ni.com/pdf/manuals/370010c.pdf

Hope this helps.

-Khalid
0 Kudos
Message 4 of 5
(4,013 Views)

I figured it out, I just had to create an Ascii object and configure the port settings, click on "monitor serial port", create and expression using mid(ascii.response,2,8) and that was it.  No configuration of request strings or response strings was needed.  Thanks for the help!

Kevin

0 Kudos
Message 5 of 5
(3,971 Views)