Friday, March 6, 2020

Re: Weird behaviour of the analog signal source

Hi Lukas,

On 03/03/2020 16:52, Lukas Haase wrote:
> 3.) What would you do if you would want to create precise timing signals? Is a custom block really the only way? And then, how would you implement it?

This is a problem that I've run into as well in the past. You don't have
to create a custom block to work around it. You can simply create a
vector with your samples, and play that back on repeat. Use the 'Vector
Source' instead of the Signal Source.

Create an 'Import' block, with contents for the import field:
import numpy as np

Create a 'Variable' block, with Id 'Sine', and Value:
np.sin(np.linrange(0, 2*np.pi, samp_rate, endpoint=False)

Create a 'Vector Source' block, set 'Sine' as the Vector, Repeat = Yes,
Output Type = Float, Vector Length = 1.

Include the 'Throttle' and other blocks as before.

This gives you a 1 Hz sine wave of unity amplitude.

Of course this only works if your frequency fits an integral number of
times within your sample rate. Then again, you can choose a different
length than samp_rate as well.

Regards, Paul Boven.

No comments:

Post a Comment