Performing Asynchronus Transmission (10 bits)

4 visualizaciones (últimos 30 días)
Ankur Saha Bindu
Ankur Saha Bindu el 28 de Mzo. de 2020
Respondida: Rahul el 12 de Ag. de 2025
function dn = asc2bn(txt)
dec=double(txt) %Text to ASCII (decimal)
p2=2.^(0:-1:-7) % 2^0,2^-1,.......,2^-7
B=mod(floor(p2'*dec),2) %Decimal to binary conversion %Columns of B are bits of chars
dn=reshape(B,1,numel(B));%Bytes to serial conversion
disp(txt);
end
How to formulate the code so that it can perform asynchronous transmission (10 bits)??

Respuestas (1)

Rahul
Rahul el 12 de Ag. de 2025
Hi Ankur,
I understand that you are working on enhancing your existing MATLAB function so that it can simulate asynchronous transmission with 10-bit framing. In typical asynchronous serial communication, each transmitted character is framed with a start bit (logic low), a set number of data bits (often 8), and one or more stop bits (logic high).
The current workflow already performs the ASCII-to-binary conversion and flattens the bits into a serial stream. To align with asynchronous framing requirements, the post-conversion stage can be extended so that framing bits are inserted programmatically around each byte before reshaping into the final bitstream. This preserves the existing vectorized computation style while making the code modular for reuse.
For example, an illustrative addition after binary extraction can be performed as shown below:
% Existing binary extraction from your code
dec = double(txt);
p2 = 2.^(0:-1:-7);
B = mod(floor(p2' * dec), 2);
% Framing: prepend start bit (0) and append stop bit (1)
framedBytes = [zeros(1, size(B, 2)); B; ones(1, size(B, 2))];
% Convert to serial bitstream
dn = reshape(framedBytes, 1, []);
If the simulation needs to be extended to a broader workflow, the generated serial bitstream could be directly integrated with the Communications Toolbox or Simulink blocks. For example, feeding the data into the following:
  • From Workspace: Serial to Parallel Converter (for bit grouping)
  • Bit to Integer Converter: UART Receiver model (for decoding simulation)
For more information regarding integrating the serial bitstream with various MATLAB entities, you can refer to the following documentation links:
This approach should allow the implementation to remain adaptable to different baud rates, parity settings, or stop bit configurations that might be tested within a MATLAB or Simulink environment.

Categorías

Más información sobre Communications Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by