03-29-2017 07:00 AM
Hi
Could somebody please help me with my array?, I have an array of 3000(bytes) I then need to take three bytes(0,1,2) in sequence and convert them to a U32 and then store them in a new array of 1000 words
Can somebody please help me.
Regards
David
Solved! Go to Solution.
03-29-2017 07:57 AM
Hi
Could somebody please help me with my array?, I have an array of 3000(bytes) I then need to take three bytes(0,1,2) in sequence and convert them to a U32 and then store them in a new array of 1000 words
Can somebody please help me.
Regards
David
03-29-2017 08:07 AM
Well, a U32 is actually 4 bytes. So what is in the missing byte and which end of the number?
You can use Array subset and a typecast to convert it to a U32. But you might need to build another byte onto either the beginning or end of the 3 element array for it to convert properly. You can do this in a loop.
03-29-2017 08:16 AM
Yup use a for loop. If you want to just zero the last byte get array subsets of 3 bytes and turn them into a U32 with one option being the type cast, and another is join numbers.
But seeing some code with example inputs and outputs would help answer some other questions.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-29-2017 08:37 AM - edited 03-29-2017 08:38 AM
03-29-2017 08:50 AM - edited 03-29-2017 08:50 AM
Another option using Reshape Array before the FOR loop.
03-29-2017 09:01 AM
I was about to post an example using decimate array but I see GerdW beat me to it. This option only works if your input array always has a multiple of 3 values. If you have 3001 or 3002 items, those last two items are dropped.
03-29-2017 09:35 AM
Hi
There are only 3 bytes used it is a 20 bit number the top byte is not used and the LSB bits 0,1,2,3 are not used I shift right 4 once converted to a U32.
03-31-2017 04:39 AM
Hi GerdW
Your solution worked thanks,
I would also like to do 2s compliment on the U32 (I am only using the lowest 20 bits can you please show me how to do this with your Array manipulation below?
Best regards
David
03-31-2017 04:50 AM - edited 03-31-2017 04:51 AM