From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Manipulation

Solved!
Go to solution

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

0 Kudos
Message 1 of 15
(3,948 Views)

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

0 Kudos
Message 2 of 15
(3,928 Views)

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.

0 Kudos
Message 3 of 15
(3,918 Views)

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.

 

Example_VI.png

 

But seeing some code with example inputs and outputs would help answer some other questions.

0 Kudos
Message 4 of 15
(3,914 Views)
Solution
Accepted by topic author DPJones

Loopless: check.png

(Set byte order by changing the wiring…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 15
(3,904 Views)

Another option using Reshape Array before the FOR loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 15
(3,893 Views)

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. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 15
(3,882 Views)

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.

 

0 Kudos
Message 8 of 15
(3,872 Views)

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

0 Kudos
Message 9 of 15
(3,833 Views)

Hi David,

 

can you give an example for your "2s complement"? (With real numbers? With an example U32 input value and expected result!?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 15
(3,831 Views)