LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to separate U32 value into four U8 values?

Solved!
Go to solution

Hello all...

    

              I'm working on a project where I need to use electronic load and set it on different values..To communicate with electronic load I need to give commands in HEX format... The format I have to use is an array of U8 with 26 byte... Each byte is dedicated for some purpose... Like

1st byte - start bit

2nd byte - address

3rd byte - command

4th byte - the lowest byte of voltage value

5th byte - the lower byte of voltage value

6th byte - the higher byte of voltage value

7th byte - the highest byte of voltage value

 

and the manual says

 

"represent voltage by 4 bytes of HEX. Lower byte are in the front location, higher bytes are in the latter location. For example : voltage is 16.000V, HEX code is 0X00003E80, 4th byte 0X80, 5th byte is 0X3E, 6th byte is 0X00, 7th byte is 0X00."

 

in program I'm taking input voltage from user which in decimal format like 16V... Now rest work should done by software i.e. converting into HEX n separating it into 4 bytes... Enter into array...

 

 

my problem is I'm not able to separate it from U32 to U8. Can anyone please help me...?

 

thank you.

 

 

0 Kudos
Message 1 of 8
(8,099 Views)
Solution
Accepted by topic author Rupali

Hi Rupali,

you can use "split number" to get what you need.

 

Mike

Message 2 of 8
(8,095 Views)

Does your device want an array of U8 or a binary string? Easiest would be to setup a cluster with all the fields in the right order and each with the right datatyle, then flatten it to a string (little endian option) to generate your 26 byte string. If you really need an U8 array, just convert the string to byte array at the end.

 

There is no need to manually dissect and combine everything with "split number", etc.

 

 

Message 3 of 8
(8,074 Views)

Here's a simple example for the seven bytes in your description, just add more elements for the full 26 byte string.

 

1st byte - start bit

2nd byte - address

3rd byte - command

4th byte - the lowest byte of voltage value

5th byte - the lower byte of voltage value

6th byte - the higher byte of voltage value

7th byte - the highest byte of voltage value

 

Message Edited by altenbach on 07-20-2009 05:37 AM
Message 4 of 8
(8,068 Views)

Rupali wrote:

"represent voltage by 4 bytes of HEX. Lower byte are in the front location, higher bytes are in the latter location. For example : voltage is 16.000V, HEX code is 0X00003E80, 4th byte 0X80, 5th byte is 0X3E, 6th byte is 0X00, 7th byte is 0X00."


I don't know how you get from 16V to x00003E80, so most likely the manual would provide more information on the details.

 

If the voltage is actually 4byte SGL (16 (SGL) is however x41800000), you would simply make one small modification as shown here.

 

 

In any case, this should get you enough ideas to get started. Good luck! 😄

Message Edited by altenbach on 07-20-2009 05:59 AM
Message 5 of 8
(8,055 Views)

Hi all...

 

        Thank you for the support Mike S81 & altenbach.... 🙂

 

but I didn't get the method suggested by altenbach.... I'm using LabVIEW 7.1

how to use that little-endian...?

Message Edited by Rupali on 07-24-2009 06:03 AM
0 Kudos
Message 6 of 8
(7,994 Views)

 


For example : voltage is 16.000V, HEX code is 0X00003E80,

 


Altenbach wrote:

I don't know how you get from 16V to x00003E80


0x3E80 = 16000 = 16.000 *1000

 

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 7 of 8
(7,986 Views)

Rupali wrote:

how to use that little-endian...?


Older LabVIEW versions don't have a byte order input, so I you don't have it, you need to program around the limitation. For each multibyte numeric, you would need to reverse the bytes.

0 Kudos
Message 8 of 8
(7,963 Views)