Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

sin1(x) > 1 ?

DSP related issues, mathematics, processing and techniques

sin1(x) > 1 ?

Postby jotb » Mon Sep 22, 2014 12:49 pm

Hello,

studid question:
I run a 500Hz sine wave into the dsp module. If i process sin1(x), where x is the input, the output is > 1. how is that possible? :o
jotb
 
Posts: 23
Joined: Mon Jul 28, 2014 5:08 pm

Re: sin1(x) > 1 ?

Postby tester » Mon Sep 22, 2014 12:54 pm

Scaling something somewhere?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: sin1(x) > 1 ?

Postby jotb » Mon Sep 22, 2014 1:10 pm

for now, I just do:

y=sin1(x);

y is streamout
jotb
 
Posts: 23
Joined: Mon Jul 28, 2014 5:08 pm

Re: sin1(x) > 1 ?

Postby tester » Mon Sep 22, 2014 2:40 pm

Extract that part and post it.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: sin1(x) > 1 ?

Postby jotb » Mon Sep 22, 2014 5:01 pm

hmm. strange. I just build that and now the problem is gone.

but now I have another one:
I am trying to rebuild a matlab code in the code module. But I think the sin1(x) is different than the sin(x) in matlab. How do I "convert" that? I how do I get Pi in code module? :oops:
I think that is my problem:
http://www.synthmaker.co.uk/forum/viewt ... in1#p72502
And more embarrassing: how do I get the values of the variables in code module? e.g. streamin x ?
jotb
 
Posts: 23
Joined: Mon Jul 28, 2014 5:08 pm

Re: sin1(x) > 1 ?

Postby KG_is_back » Mon Sep 22, 2014 6:34 pm

jotb wrote:hmm. strange. I just build that and now the problem is gone.

but now I have another one:
I am trying to rebuild a matlab code in the code module. But I think the sin1(x) is different than the sin(x) in matlab. How do I "convert" that? I how do I get Pi in code module? :oops:
I think that is my problem:
http://www.synthmaker.co.uk/forum/viewt ... in1#p72502
And more embarrassing: how do I get the values of the variables in code module? e.g. streamin x ?


sin1(x) is normalized to 0-1 range where 0 is 0radians and 1 stands for 2pi radians.
sin(x)=sin1(x/2pi) or other way around sin(2pi*x)=sin1(x)
To get pi into code module simply declare it as variable:
Code: Select all
float pi=3.14;

simply google for more precise pi value, 9 decimal places are just enough. You can initialize variables to any numeric value. If you don't specify the value, code component simply assumes zero "float a;" is the same like "float a=0;"
For the inputs/outputs in code module use:
Code: Select all
streamin x;
streamout y;

Warning! never change the values of the input variables within the code, or you might get unexpected results in the rest of the schematic. You may use output variables just like normal variables. after all code is finished, the last value will be send out.

Code: Select all
streamin x;
streamout y;

x=123; //NEVER DO THIS!!!!
y=1;
y=2;
y=3+y;
//the code will output y=5 on stream output connector
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: sin1(x) > 1 ?

Postby jotb » Mon Sep 22, 2014 8:21 pm

Thank you!

sin1(x)/(2*pi) seems to work

:oops: I always looked for something like math.pi

I just don`t get the stream output to do what I want...
jotb
 
Posts: 23
Joined: Mon Jul 28, 2014 5:08 pm

Re: sin1(x) > 1 ?

Postby jotb » Tue Sep 23, 2014 12:12 pm

It still seems not right. I have too much "gain" and the phase seems wrong too.

the original function is:
y=sin(x)+(abs(sin(x)))^8-z

I have added the schematic. And a picture of how the sinewave should look like.
Attachments
gainstage.png
gainstage.png (59.34 KiB) Viewed 28832 times
gainstage_test2.fsm
(6.83 KiB) Downloaded 1269 times
jotb
 
Posts: 23
Joined: Mon Jul 28, 2014 5:08 pm

Re: sin1(x) > 1 ?

Postby KG_is_back » Tue Sep 23, 2014 9:07 pm

te provided image definitely doesn't show the graph of function you've written. check that with this plotter, It will output the same kind of wave like your schematic:
http://rechneronline.de/function-graphs/
and input "sin(sin(x))+(abs(sin(sin(x))))^8-0.01" (the inner sinuses are there to simulate a sine wave input)
You will see that your schematic shows the same graph as this function. Basically you've made perfectly the function you've written above within the code component.

It is possible that the user used different input wave, but unlikely. There must be something more in the paper that they've done with the signal, because the function and graph definitely doesn't match if input was sine.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: sin1(x) > 1 ?

Postby jotb » Wed Sep 24, 2014 9:46 am

thank you. very good link!

I have found something in the matlab code:
there is a point before ^
sin(x)+(abs(sin(x))).^8-z

i found out that is something like element by element calculation. but where is a matrix or so ?? :oops:
jotb
 
Posts: 23
Joined: Mon Jul 28, 2014 5:08 pm

Next

Return to DSP

Who is online

Users browsing this forum: No registered users and 15 guests