I am trying to make QPSK Transmitter and Receiver Model using Simulink. I am getting one error. Can Anybody resolve this error??. I will be thankful to you.

38 次查看(过去 30 天)
The Simulink file is attached. I am facing problems in loading signal parameters from workspace.
  5 个评论
Walter Roberson
Walter Roberson 2017-3-5
  • I assist multiple people at the same time
  • I have domestic duties that take time
  • With my health being unpredictable, sometimes I sleep a fair bit
Walter Roberson
Walter Roberson 2017-3-5
编辑:Walter Roberson 2017-3-5
The first step is to run
prmQPSKTxRx = QPSKTxRx();
After that the variables will resolve in the diagram, leaving you with:
Invalid structure-format variable specified as workspace input in 'ASSIGNMENT/Receiver /Data Decoding/Bit Generation/From Workspace'. If the input signal is a bus signal, the variable must be a structure of MATLAB timeseries objects. Otherwise, the variable must include 'time' and 'signals' fields, and the 'signals' field must be a structure with a 'values' field. Component:Simulink | Category:Model error
Invalid structure-format variable specified as workspace input in 'ASSIGNMENT/Transmitter /Bits Generation/From Workspace'. If the input signal is a bus signal, the variable must be a structure of MATLAB timeseries objects. Otherwise, the variable must include 'time' and 'signals' fields, and the 'signals' field must be a structure with a 'values' field.
I do not have solutions for those as yet.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2017-3-5
编辑:Walter Roberson 2017-3-6
In your Transmitter Block (first on the left in our model) you have a Bits Generation block. Your Bits Generation Block has a From Workspace requesting to extract data from the workspace variable named prmQPSKTxRx, with it expecting to output data of type int32.
Simulink is detecting that the variable prmQPSKTxRx is not the right data type to act as a source for input data. It is noticing that it is not a structure of timeseries objects, and that alternately it is not a structure with fields "time" and "signals".
After having run prmQPSKTxRx = QPSKTxRx() at the MATLAB command prompt, then prmQPSKTxRx will be a structure, but not a structure of time-series objects, and it does not have any "time" or "signals" fields.
The same problem occurs for your Receiver block, which has a Data Decoding block, that has a Bit Generation block, that has a From Workspace that reads from the workspace variable prmQPSKTxRx .
Your prmQPSKTxRx does have an sBit field that looks like something you might want to use as the bits to be transmitted, and then later compared against. You could then experiment by updating the variable names in the two From Workspace blocks from prmQPSKTxRx to prmQPSKTxRx.sBit .
If you make this change then the error will change to:
Invalid variable specified as workspace input in 'ASSIGNMENT/Transmitter /Bits Generation/From Workspace'. The variable is either a matrix or is a Simulink.SimulationData.Dataset object with an element containing matrix data. The matrix data must be a real, double, have two dimensions, and at least two columns. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN.
So, what you could do is:
prmQPSKTxRx.sBit = [prmQPSKTxRx.Ts * (0:length(prmQPSKTxRx.sBit)-1).', prmQPSKTxRx.sBit];
... but that would lead you to
Cannot specify cyclic repetition in 'ASSIGNMENT/Receiver /Data Decoding/Bit Generation/From Workspace' when the time vector is explicitly specified for the data. The cyclic option is supported only when the data is in the form of a structure with an empty time vector.
So instead,
sb = prmQPSKTxRx.sBit;
prmQPSKTxRx.sBit = struct('time', [], 'signals', struct('values', int32(sb)));
and set both From Workspace blocks to turn off "interpolate data" and set "output data type" "inherit: auto". Also, set Transmitter -> Bits Generation -> From Workspace "Form output after final data value by" to "Cyclic repetition" to agree with your other From Workspace block. Set the From Workspace block for the Receiver -> Data Decoding to "sample time" -1 (inherit)", but set the From Workspace block for Transmitter -> Bit Generation to "sample time" prmQPSKTxRx.Ts
Now go into Receiver -> Data Decoding -> Buffer and open that, and change "Output buffer size (per channel)" from "qpsktxrx.FrameSize*2" to "prmQPSKTxRx.FrameSize*2", and "Buffer overlap" from "qpsktxrx.FrameSize" to "prmQPSKTxRx.FrameSize".
Now go into Transmitter -> Raised Cosine Transmit Filter and open that, and change "Filter span in symbols" from "2*(qpsktxrx.RaisedCosineGroupDelay)" to "2*(prmQPSKTxRx.RaisedCosineGroupDelay)", and change "Output samples per second" from "qpsktxrx.Upsampling" to "prmQPSKTxRx.Upsampling"
Now go into Receiver -> Data Decoding -> Descrambling -> Selector and open that, and look down to the group in the "Index Option | Index | Output Size" table. Click on the "Index" field associated with that first line, and change "[qpsktxrx.BarkerLength*log2(qpsktxrx.M)+1:qpsktxrx.FrameSize*log2(qpsktxrx.M)]" to "[prmQPSKTxRx.BarkerLength*log2(prmQPSKTxRx.M)+1:prmQPSKTxRx.FrameSize*log2(prmQPSKTxRx.M)]"
In the Selector1 item two to the right of the Selector block, change the "Index" field from "[1:qpsktxrx.MessageLength]" to "[1:prmQPSKTxRx.MessageLength]"
Now go to Receiver -> Data Decoding -> Error Rate Calculation and open that, and change "Receive delay" from "(qpsktxrx.RxBufferedFrames+1)*qpsktxrx.FrameSize*log2(qpsktxrx.M)" to "(prmQPSKTxRx.RxBufferedFrames+1)*prmQPSKTxRx.FrameSize*log2(prmQPSKTxRx.M)" and change "Computation delay" from "(qpsktxrx.RxBufferedFrames+1)*qpsktxrx.FrameSize*log2(qpsktxrx.M)" to "(prmQPSKTxRx.RxBufferedFrames+1)*prmQPSKTxRx.FrameSize*log2(prmQPSKTxRx.M)"
Now go to Receiver -> Data Decoding -> Phase Offset Estimator -> Selector and (similar to above) change Index from "[1:qpsktxrx.BarkerLength]" to "[1:prmQPSKTxRx.BarkerLength]"
Now go to Receiver -> Fine Frequency Compensation -> DDS -> Gain and change Gain from "-1*qpsktxrx.PhaseRecoveryGain" to "-1*prmQPSKTxRx.PhaseRecoveryGain"
Now go to Receiver -> Fine Frequency Compensation -> Loop Filter and change "Number of Samples/Symbol" from "qpsktxrx.Upsampling/qpsktxrx.Downsampling" to "prmQPSKTxRx.Upsampling/prmQPSKTxRx.Downsampling" and change "Phase Detector Gain (Kp)" from "qpsktxrx.PhaseErrorDetectorGain" to "prmQPSKTxRx.PhaseErrorDetectorGain" and change "DDS Gain (K0)" from "qpsktxrx.PhaseRecoveryGain" to "prmQPSKTxRx.PhaseRecoveryGain"
Now go to Receiver -> Raised Consine Receive Filter" and open that and change "Filter span in symbols" from "2*(qpsktxrx.RaisedCosineGroupDelay)" to "2*(prmQPSKTxRx.RaisedCosineGroupDelay)" and change "Input samples per symbol" from "qpsktxrx.Upsampling" to "prmQPSKTxRx.Upsampling" and change "Decimation factor" from "qpsktxrx.Downsampling" to "prmQPSKTxRx.Downsampling"
Now go to Receiver - Timing Recovery -> Buffer and open that and change "Output buffer size (per channel)" from "qpsktxrx.FrameSize*qpsktxrx.Upsampling/qpsktxrx.Downsampling" to "prmQPSKTxRx.FrameSize*prmQPSKTxRx.Upsampling/prmQPSKTxRx.Downsampling"
Now go to Receiver -> Timing Recovery -> Modified Buffer" and open that and change "Buffer size" from "qpsktxrx.FrameSize" to "prmQPSKTxRx.FrameSize"
Now go to Receiver -> Timing Recovery -> Timing Recovery PLL -> Loop Filter and open that and change "Phase Detector Gain (Kp)" from "qpsktxrx.TimingErrorDetectorGain" to "prmQPSKTxRx.TimingErrorDetectorGain" and "DDS gain (K0)" from "qpsktxrx.TimingRecoveryGain" to "prmQPSKTxRx.TimingRecoveryGain" and "Number of Samples/symbol (N)" from "qpsktxrx.Upsampling/qpsktxrx.Downsampling" to "prmQPSKTxRx.Upsampling/prmQPSKTxRx.Downsampling"
Now go to Receiver -> Timing Recovery -> Timing Recovery PLL -> NCO_ctrl and double click on that. Opening that will get you some MATLAB source code. The very first line of that code is
function [Underflow, mu] = NCO_ctrl(Delta, qpsktxrx)
Change that to
function [Underflow, mu] = NCO_ctrl(Delta, prmQPSKTxRx)
and make the same change on lines 22 and 23. and save.
Whew.
Okay, now at this point you have a design problem.
Transmitter -> Bits Generation creates a 13 x 1 bit vector, replicates it, and concatenates on to that something input from the From Workspace block. You get one bit per cycle coming in, and 13 x 1 replicated once -> 26 x 1, for a total of 27 x 1. That is fed into the QPSK Modulator Baseband block. However, when that QPSK block is set to Bit inputs, that block needs signals of an even length. The cure for this is to go in to the Transmitter -> Bits Generation block, and between the To Frame block and the Scrambler block insert a Buffer block, with its "Output buffer size (per channel)" set to an even number. Setting it to prmQPSKTxRx.FrameSize might be appropriate.
With all this changed and saved and diagram updated, we are now at the point where the messages are
Parameter precision loss occurred for 'Threshold' of 'ASSIGNMENT/AWGN Channel With Frequency Offset and Variable Time Delay /Delay Generator/mVariableRamp/Counter Free-Running/Wrap To Zero/FixPt Switch'. The parameter's value cannot be represented exactly using the run-time data type. A small quantization error has occurred. To disable this warning or error, in the Configuration Parameters > Diagnostics > Data Validity pane, set the 'Detect precision loss' option in the Parameters group to 'none'.
Error in 'ASSIGNMENT/Receiver /Data Decoding/Error Rate Calculation': The Tx and Rx inputs must have the same length.
The first of those two is a warning and I do not know if it matters or not. I would leave that for the moment.
The second of those is more serious. My guess is that you need to put in a buffer after the From Workspace block in Receiver -> Data Decoding -> Bit Generation, just like for the Transmitter side. However... that leads to
Error in 'ASSIGNMENT/Receiver /Data Decoding/Bit Generation/Buffer': All sample times must be discrete. No continuous or constant sample times are allowed.
and I do not know what to do about that.
  15 个评论
vivek rathi
vivek rathi 2017-3-7
I have made all the changes which you told me inside the block properties. I am unable to run the commands. Can you tell me step by step what to do to make my model run??
Walter Roberson
Walter Roberson 2017-3-7
The licenses that show up as having been used are
communication_toolbox fixed_point_toolbox matlab signal_blocks signal_toolbox simulink
However I do see a buffering problem when I run ASSIGNMENT_R2013a.slx
Sorry, but this is at the point where it is not worth the effort; I would just be spending hours learning how to work around problems that would not exist if you were using a current MATLAB version. I have already worked on this for four to five hours.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by