07-20-2009 05:44 AM
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.
Solved! Go to Solution.
07-20-2009 06:10 AM
Hi Rupali,
you can use "split number" to get what you need.
Mike
07-20-2009 07:18 AM
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.
07-20-2009 07:36 AM - edited 07-20-2009 07:37 AM
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
07-20-2009 07:57 AM - edited 07-20-2009 07:59 AM
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! 😄
07-24-2009 06:02 AM - edited 07-24-2009 06:03 AM
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...?
07-24-2009 06:20 AM
Altenbach wrote:
I don't know how you get from 16V to x00003E80
07-24-2009 12:28 PM
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.