Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
825 Views

Input and Output while using Altera Simulink Blocks

Hi all; 

I am new to Simulink and Altera blocks. Last couple days I have been working on simulating simple projects using simulink blocks. Now I started to use Altera blocks instead of simulink but I am having an Input/Output issue.  

When I use constant source, i see the expected result at the output but if I use a signal generator my output is zero.  

 

I have a screenshot but system doesnt let me post. :( But this is how I simply tested. 

 

Simulink Constant -----> Altera Input ------>Altera Gain ---------> Altera Output -------> Simulink Scope 

 

Simulink DSP SineWave ------->Altera Input ------>Altera Gain--------->Altera Output ------->Simulink Scope 

 

 

What am I missing?  

Thanks. 

-- 

 

Ilker
0 Kudos
12 Replies
Altera_Forum
Honored Contributor I
65 Views

How have you configured you Input and Output blocks? 

 

If your constant is outputting 0.5 and your Input is set to something like unsigned integer of width 8, then it would truncate your input to 0. 

 

Similarly with your Sine block, if your amplitude is too low it may be truncated.
Altera_Forum
Honored Contributor I
65 Views

Hi dabuk 

Thanks for your quick reply. 

I actually configured my input and output blocks to Signed Fractional [8].[8] and [17].[16] respectively. I thought it was Fixed or floating point option...
Altera_Forum
Honored Contributor I
65 Views

and what were your input values?

Altera_Forum
Honored Contributor I
65 Views

for constant  

input = 0.5 output becomes = 1 (gain set to 2) 

 

for sine wave  

amplitude max 10  

sampling time 1/1000
Altera_Forum
Honored Contributor I
65 Views

Ok so it works now?

Altera_Forum
Honored Contributor I
65 Views

No. I still have the problem. Does it work on your system?

Altera_Forum
Honored Contributor I
65 Views

Here's my sample design as well as a picture of it. 

 

Seems to work ok for me.
Altera_Forum
Honored Contributor I
65 Views

 

--- Quote Start ---  

Here's my sample design as well as a picture of it. 

 

Seems to work ok for me. 

--- Quote End ---  

 

I still don't get the output right. 

But do I need to add Signal Compiler and Testbench to the project for simulation? 

We have a licence issue for now and I can not use that blocks.
Altera_Forum
Honored Contributor I
65 Views

No you don't need the Signal Compiler and Testbench blocks to test your design. 

 

Have you tried using my design? Perhaps you should compare the configuration of the blocks to your blocks.
Altera_Forum
Honored Contributor I
65 Views

 

--- Quote Start ---  

No you don't need the Signal Compiler and Testbench blocks to test your design. 

 

Have you tried using my design? Perhaps you should compare the configuration of the blocks to your blocks. 

--- Quote End ---  

 

Sorry about my very late reply. I had really busy couple days. I tried your design also. I attached the screenshot of my result. I really wonder if it is some kind of license related issue..... 

image_link (http://db.tt/rjmeuawg)
Altera_Forum
Honored Contributor I
65 Views

It's not a license issue. A DSP Builder license is only required for generation. Simulation only requires Simulink licenses and would error out rather than give you incorrect results. 

 

Nothing is wrong here, but I can see why you might be confused by the result. There are two main issues here: 

 

Firstly, your scope is not returning all the data. Double-click on it and click the parameters button. Then click on the Data History tab of the scope and disable "Limit data points to last". Now you should see the full "10 sample times" worth of data, whereas previously you were seeing only 5. 

 

The reason it was only showing half the wave is because the Sine block has a sample time of 1/1000. The Stop time of the model is 10, so 10 / (1 / 1000) is 10000, which means you need 2 * 5000 samples. 

 

The second reason you may be confused is that the DSP Builder wave is jagged and the simulink wave is smooth. This is just down to sampling. You haven't configured a sample time for DSP Builder (by inserting a clock and setting its sample time) so it just uses its default which is 1. The other way to change this is to set the Sample time of the Sine Wave block to 1. 

 

Even after doing all the above the waves still won't be identical for 2 reasons: 

a) The Gain block has 1 pipeline stage so it will be slightly out of phase with the original. 

b) The DSP Builder Input and Output blocks are truncating the input during quantization.
Altera_Forum
Honored Contributor I
65 Views

 

--- Quote Start ---  

It's not a license issue. A DSP Builder license is only required for generation. Simulation only requires Simulink licenses and would error out rather than give you incorrect results. 

 

Nothing is wrong here, but I can see why you might be confused by the result. There are two main issues here: 

 

Firstly, your scope is not returning all the data. Double-click on it and click the parameters button. Then click on the Data History tab of the scope and disable "Limit data points to last". Now you should see the full "10 sample times" worth of data, whereas previously you were seeing only 5. 

 

The reason it was only showing half the wave is because the Sine block has a sample time of 1/1000. The Stop time of the model is 10, so 10 / (1 / 1000) is 10000, which means you need 2 * 5000 samples. 

 

The second reason you may be confused is that the DSP Builder wave is jagged and the simulink wave is smooth. This is just down to sampling. You haven't configured a sample time for DSP Builder (by inserting a clock and setting its sample time) so it just uses its default which is 1. The other way to change this is to set the Sample time of the Sine Wave block to 1. 

 

Even after doing all the above the waves still won't be identical for 2 reasons: 

a) The Gain block has 1 pipeline stage so it will be slightly out of phase with the original. 

b) The DSP Builder Input and Output blocks are truncating the input during quantization. 

--- Quote End ---  

 

 

Thank you very much. I added a clock and set the sample time and it worked.:D
Reply