Simulink: Buffer with constant input due to delay of input
14 views (last 30 days)
Show older comments
Hi,
We are trying to use Simulink to communicate between two computers by using DVBS2 (commdvbs2). One computer is the Transmitter (TX) and the second is the receiver (RX). When we have the diagram on the same computer, everything works, but when we try to separate them, we get the following error with the buffer that can't accept to wait for the next frame: " Error in 'DVBS_COM_RX/Buffer': All sample times must be discrete. No continuous or constant sample times are allowed."
We have trying the following diagram to reproduce the buffer, but it seems than there is something wrong with the switch. We are trying to just put the output to a terminator when the buffer is not full and send the data when the buffer is full. We can only have one output than will be connected to the rest of the diagram of DVBS2. The output of the buffer are complex values that will be send to the demodulation. Other solution than create a new version of the buffer will also be appreciate.
The diagram of the Buffer we are trying to do. We use a constant values has input for the test to reproduce an entry with latency acting like a constant value:

Code of the MATLAB Function (input always have the same length):
function [data_out, buffer_was_full] = fcn(data_in)
%#codegen
persistent buffer emtpy_data pos_data size_buffer size_data
buffer_was_full = 0;
if isempty(buffer)
size_buffer = 1843200;
buffer = complex(zeros(size_buffer, 1));
emtpy_data = buffer;
pos_data = 1;
size_data = numel(data_in);
end
end_data = pos_data + size_data;
%Case when buffer is not full
if end_data < size_buffer
buffer(pos_data:(end_data-1)) = complex(data_in);
pos_data = pos_data + size_data;
buffer_was_full = 0;
data_out = emtpy_data;
%Case when (size_buffer/size_data) is a integer and buffer is full.
elseif end_data == size_buffer
buffer(pos_data:end) = complex(data_in);
data_out = buffer;
buffer = emtpy_data;
pos_data = 1;
buffer_was_full = 1;
%If buffer will be full by adding data_in. Security in case
%(size_buffer/size_data) is not a integer.
else%if end_data > size_buffer
emtpy_space_buffer = (size_buffer - pos_data);
buffer(pos_data:end) = complex(data_in(1:emtpy_space_buffer));
data_out = buffer;
buffer_was_full = 1;
other_part_data = (size_data-emtpy_space_buffer);
buffer(1:other_part_data) = data_in(other_part_data:end);
end
end
0 Comments
Answers (1)
Jim Riggs
on 26 Jan 2018
The default sample time for a constant block is "inf". Based on the error message, the first thing I would check is the sample time setting in the block parameters for the constant block.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!