09-05-2017 06:29 AM
Hi all,
This is the description of the problem I am trying to solve:
Could the "Cluster to Array" block do the job (second .jpg)?
Is there a better way?
Thanks in advance
09-05-2017 06:37 AM - edited 09-05-2017 06:42 AM
Hi milliken,
This is the description of the problem I am trying to solve:
My model has several inputs, and each of them is a byte (signed int8).
In your image you use orange wires, denoting float values, but in your description you are talking about I8 values. What exactly do you use?
Could the "Cluster to Array" block do the job (second .jpg)?
Well, yes.
Do you really have 2000 scalar values inside this cluster? (Is there no way to organize your data in arrays or subclusters?)
Btw. there often is a size limit for UDP messages, LabVIEW uses 548 bytes by default. Such a message could contain ~512 bytes of "payload data" (I tend to include some additional header/checksum data in such messages). Or you could transport 128 SGL or 64 DBL values in an UDP message of the same size…
09-13-2017 01:49 AM
Thanks GerdW for the quick response (and sorry for my late reply).
Since I am only receiving this data via UDP, I will contact the guy responsible for sending it, in order to explore the option of a more efficient way of transmission.
Following your advice, I changed the representation of the data in the cluster from double (orange) to int8 (blue).
I will keep everyone posted if we manage to find a solution that works and looks clean.
Cheers
09-13-2017 08:56 AM
If you were truly sending integers as doubles, sending them as I8 would shrink your data size by what, 8x? (Assuming your values fit into an I8.)
09-19-2017 10:23 AM - edited 09-19-2017 10:25 AM
I have made use of the UDP sender example from LabView, trying to replicate the same behaviour as in Simulink (which works).
Basically, concatenating 3x unit32 and 6x double into a boolean array and sending it via UDP.
In Simulink, I use the "Byte packing" block (which transforms from either uint32 or double into boolean), use a "Mux" block to concatenate the booleans, and send it via UDP.
In Labview, I try to convert each "Number to boolean array", feed them into a cluster, flatten it into a string and send it via UDP.
Any ideas?
PS. The fact that the 3x unit32 are fed with the same number (same as the 6x double) is to save wiring time 🙂
09-19-2017 01:13 PM - edited 09-19-2017 01:15 PM
Hi Miiliken,
Basically, concatenating 3x unit32 and 6x double into a boolean array and sending it via UDP.
Why do you want to convert typecast into a boolean array? Why not typecast into byte array or string?
In Labview, I try to convert each "Number to boolean array", feed them into a cluster, flatten it into a string and send it via UDP.
This conversion is bu**sh** nonsense… 😄
Try this:
Adapt as needed…
09-19-2017 05:37 PM
Personally, I would just put the numbers themselves into a cluster, flatten that, and send.
And if Matlab is involved, I am pretty sure you need to set to Little Endian.
09-21-2017 01:35 AM
I managed to make use of the example template provided by LabView for UDP (Sender, Receiver) to make it work.
I think the main difference between LabView and Simulink is (please correct me if I am wrong):
- Labview sends a STRING via UDP
- Simulink sends an ARRAY OF BYTES via UDP
This actually now puts the focus on the other piece of software which receives the UDP and must interpret what is beind sent.
I will try to make use of Wireshark today and show that in fact the UDP contents are not the same in Labview and Simulink cases. I will keep you posted.
09-21-2017 01:43 AM - edited 09-21-2017 01:46 AM
Hi Milliken,
Labview sends a STRING via UDP
Simulink sends an ARRAY OF BYTES via UDP
And what is the difference between a string and an array uf U8 - in LabVIEW terms?
(Please keep in mind the two functions StringToByteArray and ByteArrayToString…)
You can create the same byte array in LabVIEW as you do in Simulink. When they are not the same (although you use the same source data) then YOU made something wrong…
09-21-2017 04:31 AM
Milliken wrote:I think the main difference between LabView and Simulink is (please correct me if I am wrong):
- Labview sends a STRING via UDP
- Simulink sends an ARRAY OF BYTES via UDP
Array of U8 and a string actually have the exact same structure. So that should not be an issue. The issues I have ran into are with the Endianness of the data. LabVIEW defaults to Big Endian while Matlab uses Little Endian. You can set that with the Flatten To String.