LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication Parse

Solved!
Go to solution

Using an industrial weight scale with simple serial communication output. It's configured and talking with labview.

 

I leveraged the code is from the RS232 calling vi - https://forums.ni.com/t5/Example-Code/Read-status-of-RS232-serial-lines/ta-p/3499317

 

Now I just need to parse the string and convert it to a numeric value so I can use the signal for other data processing objectives. Any feed back would be much appreciated 

Download All
0 Kudos
Message 1 of 7
(1,098 Views)
Solution
Accepted by topic author JCuneo

Hi J,

 

use ScanFromString to parse the numeric value from the received string...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(1,091 Views)

Here's the code that gives reasonable outputs - not sure how to solve the chatter, any thoughts would be great

Download All
0 Kudos
Message 3 of 7
(1,000 Views)

What scale are you using?  Do you have a link to the manual?  I'm mostly looking for a clear definition of the communication protocol.

 

Based on the scale putting out ASCII characters, I would almost guarantee that you should NOT be using the Bytes At Port and you should enable the termination character.  Then you just tell the VISA Read to read more bytes than you should ever get back in a message.  This way you will know you got a complete message.  Then you are just parsing a single, full message.  As you have it now, you could have part of a message, multiple messages, or any weird mix in between.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(997 Views)

Your are more than likely correct - I'll give it a go right now and see what happens. Attached is the manual.

0 Kudos
Message 5 of 7
(994 Views)

Thanks for the suggestion, much appreciated, but the Scales data didn't read in however 

0 Kudos
Message 6 of 7
(991 Views)

It would most likely help if you not only connected the boolean True to the Termination Character Enable to the VISA Serial Port Config (which isn't really necessary since it is the default) but also a constant with the value decimal 13 (or hex 0xD, <carriage return>) to the "termination char" (default is 0xA, <line feed>). This should make sure that you receive with every read exactly one line.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(974 Views)