LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

concatenate user defined hex code for serial communication

Solved!
Go to solution

Hi.. I am a beginner to LAbView. I am trying to communicate with an AC power Source. for which My command will be in the format of 4 to five bytes; e.g. for setting a voltage of 220VAC, it is 1509 0898 in Hex, in which 15 is fix for all commands for hand shaking, 09 is for different operations like setting Volatge or Freq. and last four digits 0898 is an Hex code of 2200 (for 220.0VAC).

 

While sending the full command 1509 0898 in Hex to Serail port my source is communicating, even by giving the them using concatenation of strings like 1509 is first string and 0898 in second, it is working fine.

 

But these last two bytes would be user defined and hence can vary in numeric, so I have put a Number to Hex code conversion there before concatenation. which is not sending the Hex code 0898 as reqd.  but sending this garbage value...3038 3938

 

Please Help.. Thanks in advance....

0 Kudos
Message 1 of 16
(1,051 Views)
You can set the string inputs or constant to display its contents in hex. Then you can type the data in hex. Alternately, you can create a 1D array of U8s and set the radix to hex. You can then convert the array to a string.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."
0 Kudos
Message 2 of 16
(1,035 Views)
Solution
Accepted by topic author Ermani

Hi Ermani,

 

here's the step-by-step long way:

check.png

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 3 of 16
(1,024 Views)

Hi.. GredW.. Thanks.. But can u please give the name and properties of 3th and 5th Function?? I could not find the same.

0 Kudos
Message 4 of 16
(1,015 Views)

Starting from left to right

1. Multiplication

2. Round to nearest

3. Convert to U16

4. Split number

5. Build array

 

All of them can be found in Numeric pallet.

With Regards

Miraz
Kudos is better option to thank somebody on this forum
------------------------------------------------------------------------------
Message 5 of 16
(1,007 Views)

Dear GerdW, Thanks a lot it is working for me.. Smiley Happy

0 Kudos
Message 6 of 16
(998 Views)

Thanks Miraz.. Smiley Happy

 

It is working..

 

But it wud be better if you can let me know about the same that what is going on behind the code..

0 Kudos
Message 7 of 16
(996 Views)

ok,

Ideally CTRL + H  should work for you, it will open help menu and explain each function for you.

 

For this time let me give you details.......

 

1. You are multiplying 220.0 and 10.0 which results in 2200.0 (fraction)

2. If it is not round number then you are rounding it to nearest (In this case it is already rounded value)

3. Then you are converting it to U16, that means you are converting value to be represented using 16 bits(2 bytes)

4. Then split number is spliting upper 8(1 byte) and lower 8(1 byte) bits  for you

5. These upper and lower bytesyou are then adding to array using build array function

With Regards

Miraz
Kudos is better option to thank somebody on this forum
------------------------------------------------------------------------------
Message 8 of 16
(988 Views)

but where the Hex conversion is done for this upper & lower byte?

0 Kudos
Message 9 of 16
(979 Views)

The final function Byte array to string converter.

With Regards

Miraz
Kudos is better option to thank somebody on this forum
------------------------------------------------------------------------------
0 Kudos
Message 10 of 16
(971 Views)