# Fourier series in Multisim

Discussion in 'General Electronics Chat' started by xxxyyyba, Sep 18, 2014.

1. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
Is it possible to represent some signal in terms of Fourier series in Multisim? For example, Fourier series of sawtooth voltage with period T=2pi is
$\sum_{n=1}^{\infty }\frac{2}{n}(-1)^{n+1}sin{(nt)}=2sin{(t)}-sin{(2t)}+\frac{2}{3}sin{(3t)}-\frac{1}{2}sin{(4t)}+...$
These terms on right side of equation will be AC voltage sources connected in series. For good approximation of sawtooth waveform I should use few hundreds terms of series. It would be impossible to connect all these sources manually Is there any better way to do this?

Last edited: Sep 18, 2014

Feb 19, 2010
3,297
482

3. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
I want to see how it works in electrical circuit Multisim had already sawtooth generator so it would be easier to use it directly instead of using Fourier representation of sawtooth signal but I used sawtooth signal just as an example. Actually, I was wondering is it possible to simulate random periodic signal which can be represented through Fourier series in Multisim in order to calculate, for example, current in some branch or some voltage.

4. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
For example, how can I simulate this circuit if input voltage is

$E(t)=1+\sum_{n=1}^{\infty}\frac{2(-1)^{n}}{\sqrt{n^{2}+1}}\cos({nt+\arctan{n}})$

5. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,297
482
Circuit simulator simulates circuit.

Circuit simulator DOES NOT simulate equation.

That is why we have MatLab and other mathematical software.

Mar 6, 2009
5,448
782
7. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
Is it possible maybe in Simulink? I didn't find way to put sum in Multisim in ABM source.

Feb 19, 2010
3,297
482
9. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
Here is Fourier series of sawtooth waveform with 2pi period:
$e(t)=\sum_{n=1}^{\infty}\frac{2(-1)^{n+1}}{n}\sin{(nt)}$

I wrote program in Matlab to plot it:

clear
clc
t=linspace(0,2*pi,1000);
suma=0;
for n=1:10000
suma=suma+((2./n).*(-1).^(n+1)).*sin(n.*t);
end
plot(t,suma)
grid

Can I link it somehow with Simulink to generate this waveform as an electrical signal?

Last edited: Sep 20, 2014

Aug 7, 2012
249
2

Feb 19, 2010
3,297
482
12. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,297
482
Equation is not a circuit. Therefore circuit simulation software like Multisim will not work.

Aug 7, 2012
249
2
Ok thanks

14. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
782
I suppose I have a different perspective on what a circuit simulator does. It essentially solves mathematical relationships with circuit laws providing the necessary constraints and boundary conditions.
I see no reason why in principle a simulator can not have a block element with a defined mathematical output. An infinite series simulation is a problem but one can envisage a truncated approximation which might provide certain insights.
A circuit simulator I regularly use has a circuit block element which can produce an arbitrary time dependent output defined by a mathematical function of my choosing. So if I had the patience I could enter a partial or truncated Fourier series for a sawtooth waveform as the source output definition.
An interesting observation, for instance, might be the Gibbs phenomenon.

Last edited: Sep 20, 2014
15. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
Which circuit simulator do you use?
ABM source in Multisim unfortunatelly doesn't support sumation. It is necessary to use few thousands of terms (see my code) for excellent approximation of sawtooth signal. There is maybe some simulator which can sum all these terms and produce signal. I used sawtooth signal as example, some other signal maybe doesn't need such big number of terms for good approximation .

16. ### xxxyyyba Thread Starter Member

Aug 7, 2012
249
2
Finally I solved it!
In order to simulate arbitrary periodic signal written in terms of Fourier series, it is necessary to calculate sum using my code for example (it's for sawtooth waveform), post #9 . For every value of t we have appropriate value of "suma". Then we have to save our data in text file, time goes in first column and values for "suma" goes in second column. Then we load our text file in PWL Voltage in Multisim (Enter data points int table - Initialize from file...) and that's it

Last edited: Sep 22, 2014