NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to join to bytearrays with MSB / LSB to real number?

Hello,

i have two numeric arrays. One with MSB bytes and the other with LSB bytes.

How can i join this two bytes into a third array with the full number?

Thx

0 Kudos
Message 1 of 4
(4,157 Views)

I would make a for loop.  Inside the loop, you would have something like Array3[i] = (MSB[i]<<8) + LSB[i]

 

I don't think there's a join command.  You need to left shift the MSB and add it to the LSB.

 

Pulido Technologies LLC

Message 2 of 4
(4,149 Views)

Hi!

 

it is much easier than that. Join really works for that (see demo)

 

EDIT: Sorry I missread. I thought it was a LabVIEW question!

 

Best regards,

Christoph

Staff Applications Engineer
National Instruments
Certified LabVIEW Developer (CLD), Certified LabVIEW Embedded Systems Developer (CLED)


Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved
0 Kudos
Message 3 of 4
(4,111 Views)

 

USe a For loop loopin the number of elements in the  MSB array and put this statement inside the loop will join the arrays.

 

Locals.ResultArray+={Locals.MSB[Locals.Index],Locals.LSB[Locals.Index]}

 

 

 

So something like this

For (Locals.Index = 0,Locals.Index < GetNumElements( Locals.MSB),Locals.Index += 1)

 

 Locals.ResultArray+={Locals.MSB[Locals.Index],Locals.LSB[Locals.Index]}

 

End

 

BR

Christian

0 Kudos
Message 4 of 4
(4,055 Views)