LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with RS 232

Hello,

I've got a measurement system which delivers 400 values (each of them
is a 16-bit-integer) via the RS 232 to the PC. I would like to
visualize and record these values.
The problem is, that because of limitations of the DSP used in the
system, each of the 16-bit-integer is divided into a highbyte and a
lowbyte, that means one 16-bit-integer is represented or transmitted
as two 8-bit-Integer-numbers.
How can I get the original Integer ?

Thanks a lot, Matthias



-- Dipl.-Ing. Matthias Bergmann
-- Institut für Theoretische E-Technik
-- und Hochfrequenztechnik, FGB HF
-- Universität Hannover
-- Appelstr. 9A
-- 30167 Hannover - Germany
-- bergmann@hft.uni-hannover.de
0 Kudos
Message 1 of 8
(3,253 Views)
Use the "Swap Bytes" and "Type Cast" functions. An example VI attached where the intermediate string is what your RS-232 data would look like.

Bruce Mihura
0 Kudos
Message 2 of 8
(3,253 Views)
Hello Bruce,

thanks a lot for your answer. Unfortunately LabVIEW 5.1 doesn't open the attached file, giving the error message "LabVIEW load error code 8: Could not load VI resource."

What's wrong with it ?
0 Kudos
Message 3 of 8
(3,253 Views)
You could use the Join Numbers function under Advanced>>Data Manipulation on the functions pallet.
Message 4 of 8
(3,253 Views)
That VI was built in LabVIEW 6.1-- I don't have version 5.1 installed, so I took some screen shots so you can build it in version 5.1.
0 Kudos
Message 5 of 8
(3,253 Views)
Other details not obvious from the picture:

(1) It helps to have the string indicator on the front panel set to "Hex display". That way you can see all the data quite easily.
(2) Those functions on the block diagram come from the "Advanced >> Data Manipulation" palette.
(3) Be sure to set the representation of those numeric arrays to I16 (or U16 would work too).
0 Kudos
Message 6 of 8
(3,253 Views)
One more detail:

It's remotely possible your incoming data stream might give you an odd number of bytes, so you only get half a number. I've seen that happen before. Store all data into a string (typically in a shift register), and make sure to ignore the "odd" byte when you change the string to 16-bit integers, or you'll have garbage data. Use the "Concatenate Strings" function to append each incoming chunk of data so you don't lose the "odd" byte.

Email me with any questions: bruce@LCtechnology.com
0 Kudos
Message 7 of 8
(3,253 Views)
If anybody else is interested in the example, I attached it for Version 5.1.
0 Kudos
Message 8 of 8
(3,253 Views)