Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waveform Source outputs a constant function if frequency is too low #36

Closed
xloem opened this issue Nov 1, 2015 · 6 comments
Closed
Labels

Comments

@xloem
Copy link
Contributor

xloem commented Nov 1, 2015

A quick debug shows that _step becomes zero, so _index is never increased in the work function.

@guruofquality
Copy link
Contributor

Can you share the sample rate and waveform rate that caused this. There is a little note about the resolution parameter here. Was resolution on automatic or something else?

|param res[Resolution] The resolution of the internal wave table (0.0 for automatic).
 * When unspecified, the wave table size will be configured for the user's requested frequency.
 * Specify a minimum resolution in Hz to fix the size of the wave table.

@xloem
Copy link
Contributor Author

xloem commented Nov 1, 2015

Resolution was automatic; sample rate 1e6; frequency < 0.5 causes constant output.

@xloem
Copy link
Contributor Author

xloem commented Nov 1, 2015

This is coded for; the stepUpdate function aborts and allows the step size to be 0 if the table size would exceed a million: https://github.com/pothosware/pothos-comms/blob/master/waveform/WaveformSource.cpp#L191

Is there a proper way to display to the user that this is an invalid frequency?

@guruofquality
Copy link
Contributor

The table lookup has a limited resolution. Small enough and eventually you cant allocate enough space for the table. std::sin and cos can be expensive, so the table is a nice optimization, but I can see where it breaks down. We might need a block that doesn't use a table, but performs the live calculation. Or make that a configurable option at least in the waveform source.

Anyway, for this its probably best to log a warning when the calculated _step is significantly different than the (_freq/_rate). I want to throw a range error, but theres some need here to be careful that the error is only thrown after the freq, rate, and resolution are applied. We could accidentalaly cause the error while still applying settings. The FIR designer actually has a similar design, and it uses if (not this->isActive()) to avoid doing calculations until the block is activated.

@xloem
Copy link
Contributor Author

xloem commented Nov 1, 2015

Note: could also use a sin/cos table rather than a waveform table.

@guruofquality
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants