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

synthesizeNTF(order, OSR, opt=2,f0=0.25) #76

Closed
ghost opened this issue Sep 30, 2020 · 8 comments
Closed

synthesizeNTF(order, OSR, opt=2,f0=0.25) #76

ghost opened this issue Sep 30, 2020 · 8 comments

Comments

@ghost
Copy link

ghost commented Sep 30, 2020

I can't synthesize NTF at center freq of 0.25, I get TypeError
TypeError: 'float' object cannot be interpreted as an integer

@ghost
Copy link

ghost commented Oct 1, 2020

I folked this library and maintain in [Y-F-Acoustics/python-deltasigma] (https://github.com/Y-F-Acoustics/python-deltasigma).

This may synthesize NTF. I will try to check it can synthesize. Please paste your code which clarifies order and OSR.

I can't synthesize NTF at center freq of 0.25, I get TypeError
TypeError: 'float' object cannot be interpreted as an integer

@ghost
Copy link
Author

ghost commented Oct 1, 2020

Here's the code

order = 2
OSR = 64
H_inf = 1.5
opt = 2
f0 = 0.25

H0 = synthesizeNTF(order,OSR,opt,H_inf,f0)
subplot(121)
plotPZ(H0, markersize=5)
title('NTF Poles and Zeros')
f = np.concatenate((np.linspace(0, 0.75/OSR, 100), np.linspace(0.75/OSR, 0.5, 100)))
z = np.exp(2jnp.pif)
magH0 = dbv(evalTF(H0, z))

I'm not very good with python but I work on an electronic project and need to simulate the ADC
I tried the Matlab version and it works but I wish to use the python version

image

@ghost
Copy link

ghost commented Oct 1, 2020

Thanks a lot!
This problem is not your fault (It was already reported on #72 ). I checked the bug on this library and fixed them on my forked repository.

If you can install and use my folked python-deltasigma, please check it and pull request.

@ghost
Copy link
Author

ghost commented Oct 1, 2020

Thanks a lot, it works.

@ghost ghost closed this as completed Oct 1, 2020
@ghost ghost reopened this Oct 1, 2020
@ghost
Copy link
Author

ghost commented Oct 1, 2020

Hi again, I'm sorry but I think the same problem exists in some functions also
It solved for synthesizeNTF but when i try to complete the code same problem up again

Here's the new code.

order = 2
OSR = 64
opt = 2
f0 = 0.25
H = synthesizeNTF(order, OSR, opt, 1.5, f0)
subplot(121)
plotPZ(H)
title('Bandpass NTF Poles and Zeros')
f = np.concatenate((np.linspace(0, f0 - 1./(2.*OSR), 50),
np.linspace(f0 - 1./ (2 * OSR), f0 + 1./(2.OSR), 100),
np.linspace(f0 + 1./(2.OSR), 0.5, 50)))
z = np.exp(2j * pi * f)
magH = dbv(evalTF(H, z))
subplot(222)
plot(f, magH)
hold(True)
G = (np.zeros((order/2,)), H[1], 1)
k = 1./np.abs(evalTF(G, np.exp(2j
np.pi
f0)))
G = (G[0], G[1], k)
magG = dbv(evalTF(G, z))
plot(f, magG, 'r')
figureMagic([0, 0.5], 0.05, None, [-100, 10], 10, None, (16, 8))
#axis([0, 0.5, -100, 10])
grid(True)
xlabel('Normalized frequency ($1 \rightarrow fs$)')
ylabel('dB')
title('Bandpass NTF/STF Magnitude Response')

Here's the error
image

@ghost
Copy link

ghost commented Oct 1, 2020

In case of Python, np.zeros returns the zeros matrix like MATLAB.
So, input parameters in zeros must be integers. You can write like below,

G = (np.zeros((order//2, )), H[1], 1)
or
G = (np.zeros((np.int(order/2), )), H[1], 1)

You must be warn that the python returns float automatically like MATLAB.
For example, the formula '1/2' doesn't return '0', but '0.5'.

@ghost
Copy link
Author

ghost commented Oct 1, 2020

Ok, thanks a lot

@ghost ghost closed this as completed Oct 1, 2020
@ghost
Copy link

ghost commented Oct 1, 2020

Sorry for my poor English.

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

No branches or pull requests

0 participants