LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you send bytes at serial port?

I need to send the following bytes at serial port, wich had a temperature sensor:

In Hex
C5 0C 00 01 00 00 00 00 00 01 0E 49

to request a temperature reading

The order of bytes:

CMD byte
PACKETlength bytes
ADDRESS bytes
ARGUMENT byte
CRC bytes

Thanks you.
0 Kudos
Message 1 of 3
(2,840 Views)
To send your Hex data to your temperature sensor, you would just use the Serial VI's available in LabVIEW, and convert your Hex data to ASCII (string) format. There are three serial examples that ship with LabVIEW, and these will give you a good sense for how to use the Serial VI's. These examples can be found by selecting "Search Examples" from the LabVIEW splash screen, clicking on the "I/O Interfaces" link, and then on "Serial Communication."

I have attached a bitmap image to this message that shows how to use the Byte Array to String function to convert your Hex data into the string format. Good luck!
Message 2 of 3
(2,840 Views)
Another way of producing the hex string to send would be to place a string constant on the diagram, right click on it and select 'Hex display' then just start typing the hex values you want to send. This is an easy way to generate command strings that you know will not change instead of having to build an array, set the values and generate a string. Matt is of course correct if the hex values you have are actual numbers (say, computed by some algorithim) but is cumbersome for generating command strings you know will not change from design time on.

Jared
0 Kudos
Message 3 of 3
(2,840 Views)