TCP/IP receive simulink byte size and order
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
Using the TCP/IP Receive simulink block, from the Instrument Control Toolbox, the output 'data size' has to be indicated in the parameters. I am trying to get a modbus standard message that has a mix of 2 bytes and 1 byte values expressed in hexa.
For instance this next message : 00 04 00 00 00 09 01 03 06 42 48 00 17 00 00 has:
- the first 2 bytes 00 04 are transmitting the value 4;
- the next 2 bytes 00 00 are for 0;
- next 2 bytes 00 09 are for 9;
- next byte, 01, is for 1;
- next byte, 03, is for 3;
- next byte, 06, is for 6 . this is actually the byte count of the modbus, indicating there are 6 bytes following (3 values of 2 bytes each)
- and so on the next are only 2 bytes values.
My problem is that when obtaining the data, the block searches only for 2 bytes values. Hence the sequence of the 3 values of 1 byte each gets mixed with the next values and then the bytes are mixed. I recreated the Hexa message and I could recreate the correct message (see the file) but as the block awaits for 2 bytes values and I receive an odd number of bytes, the messages get shifted with 1 byte for each message.
I have attached some files if further analysis should be done in order to understand my problem. In order to properly test the file one should use two computers while one of them has a modbus slave emulator with the registers at the addresses 0000 to 0003 (an example is attached for the free soft http://www.modbustools.com/download.html).
I am adding some m files of matlab coder to see how it should behave: for this run the read_modbus_f_I_V.m. The other file is only a function to obtain the value using IEE754. The read m file was used to read the frequency, current and voltage f,I,V of a meter.
Thanks in advance for any solution
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Instrument Control Toolbox Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!