Cody Sam
Cody Sam

Reputation: 1

Convert a vector of 3 uint8 to a uint32 in simulink

I had a vector of 3 elements all type uint8 that need to be converted to a uint32, I’m struggling to find the correct block to do that I tried unpacking the signals but then that creates a problem with the input width size as it just outputs 3 signals. Does anyone have any idea if there’s such a block in simulink

Edit: A data packager block takes in a uint32 as an input and then outputs a vector of 3 uint8 elements. I’m trying to convert that back to one uint32 outputs but I’m unable to do so using the byte unpack as the size of the vector is incompatible.

I gave data unpack, signal selector and data conversion all a go, and they all outputted the wrong size of signal. As they outputted 3 signals instead of 1 uint32 signal

Upvotes: 0

Views: 874

Answers (1)

morteza
morteza

Reputation: 366

One solution is to unpack uint32 data into double and then separates the result into three numbers based on their values. Take for example, a 6 digit number such as 123456. 12, 34 and 56 can be converted to uint8 in order to send as a three byte package. In the receiver on the other hand, they need to combine to form the original number. Sending part is as follows. Receiver is opposite. sending 123456 as three uint8

Upvotes: 0

Related Questions