LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I send a binary number to the RS-232 com port

How do I send four binary bytes to my Rs-232 port by LabVIEW? The format I need to send is:
byte 1 - Address low byte

byte 2 - Address high byte

byte 3 - On/Off byte (0-255)
byte 4 - Number of bytes to be transmitted.

Thanks
0 Kudos
Message 1 of 5
(3,112 Views)
Depending on where your data is to start with, do 1A or 1B:

1A... Create a cluster with the data types you want in it. Pay attention to data representations - if you want a single byte, put a U8 in the cluster. I would guess your example would be four U8s. Pay attention to cluster order - they should be in transmission order.

1B... Use a BUNDLE function to assemble the data. Pay attention to data type - use conversions to U8 if necessary. If your address is a U16 or something, use the SPLIT function to make two U8s from it. Pay attention to the byte order.

2... Use a FLATTEN TO STRING function to convert the bundle (whether from a front panel cluster or a bundle) to a string.

3... Send the string out via the serial port SEND function.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 5
(3,112 Views)
Or build your data into an array of U8 then use the Byte Array to String function in the string functions > conversions palette...
0 Kudos
Message 3 of 5
(3,113 Views)
I am under the impression that the cluster introduces extra structure info when used in "Flatten to String". Basically, 4 (or any number) individual bytes is different from a cluster of 4 bytes. Please correct me if I am wrong.

-Joe
0 Kudos
Message 4 of 5
(3,112 Views)
Incorrect. The Cluster adds nothing to the flattened string - test it for yourself.

Four U8s in a cluster flattens out to a 4-byte string.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

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