serial communication device without driver
Mostrar comentarios más antiguos
I want to send a signal or generate a signal for a serial control device connecting via RS232.
point to point link, Baud rate 38400, data bits 8, parity none, stop bits 1, CRC 16.
I want to generate or use matlab function or simulink to get a signal of fixed length of 6 bytes. The massage are transfered in 15ms cycle.
Example signal : AA ID AA 02 IC IE.
I want to generate or send a signal (AA ID AA 02 IC IE) keeping in mind all the parameters.
Respuestas (1)
Walter Roberson
el 2 de Mzo. de 2022
0 votos
That uses the Instrument Control Toolbox.
You could also use MATLAB Function Block, and code in calls to serialport() and related functions; https://www.mathworks.com/help/matlab/ref/serialport.html
6 comentarios
Ibnul Feraji Alam
el 2 de Mzo. de 2022
Walter Roberson
el 2 de Mzo. de 2022
For the Serial Send block in Simulink, the input port can be a vector of uint8. It also supports fixed header or fixed terminator. For example if your 6 bytes are always SOH followed by 4 data bytes followed by a checksum byte then your Signal could omit the SOH and you could configure that as a header.
At the MATLAB level, the write() method is for binary data.
https://www.mathworks.com/help/matlab/ref/serialport.write.html
Ibnul Feraji Alam
el 3 de Mzo. de 2022
Walter Roberson
el 3 de Mzo. de 2022
If you are using the serial send block in Simulink, you have two choices:
- Create a Simulink signal vector of length 6, that already has the STX and ETX in place, and have the block send it exactly as is. Configure the Header empty and the Terminator 'none'; OR
- Create a Simulink signal vector of length 4, that does not have the STX or ETX inside it. Configure the header to STX and the terminator to ETX; that would involve configuring the terminator as Custom and then filling in the Custom Terminator property.
Ibnul Feraji Alam
el 3 de Mzo. de 2022
Walter Roberson
el 3 de Mzo. de 2022
There is no particular block in Simulink to send fixed length signals. The serial send block will send whatever shows up on its input port. Most signals in Simulink are fixed-length signals.
In theory you could be feeding the output of a triggered system or an if/then block into the serial send block. It will not care: it will send whatever is in the input port when it gets triggered (it only makes sense to use such a block with a discrete section rather than a continuous section.)
Generally speaking if you were wanting to send a block of calculated results not all created at the same time, and it was important that they be transferred at regular times or with a regular header for the block, then you could use a buffer block.
Categorías
Más información sobre Signal Attributes and Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!