kill(all)$

maxima : electrical(2)      high pass filter  'version 1.0'
peter.vlasschaert@gmail.com, 18/12/2019

load 'packages'
----------------------

load(lrats);

High pass filter
============

fig : bluid with scilab ( xcos , simulator), source activated @ t= 0

V(A)  : source for filter. (input)     =>  VA   (DC source)  (general  : VA(t)  ,' AC source')  => input
V(B)  :                             (output)   => VB    (                  )  (general :  VB(t) ,'                    ')  => output
=========================================================================
t = time
DC = Direct Current
AC = Alternating Current
i = current  
Zj = impedance    j = 1,2
==========================================================================
connect to output = load of the circuit ( not shown in the figure)

source  =>  result  in  i(t)  ' in the circuit'

1e)  voltage : kirchoff law ( sum voltages closed loop = 0)

p1: VA(t) =i(t)*R+1/C*integrate(i(u),u,0,t);

2e)  Laplace transform  ( = reason get inside 'Initial Conditions' = IC)

declare(R,constant,C,constant);

a) reason :'differentation first' to remove integral  from p1
-----------------------------------------------------------------------------

p2:diff(p1,t);
p3:laplace(p2,t,s);
p31:expand(p3);

b)  set : i(0) =0,VA(0) = 0 , otherwise give some values
----------------------------------------------------------------------------

p3a:[i(0) = 0,VA(0) =0];
p3a1:subst(p3a,p31);
p3a2:factor(p3a1);

c)  remove  i(t)  with difference of voltages
----------------------------------------------------------

p4:[Z2=1/(s*C), Z1=R];
p4a1:i(t)  =subst(p4, (VA(t) -VB(t))/Z2);
p4a2:expand(p4a1);

c1) laplace transform 'p4a2'

p4b:laplace(p4a2,t,s);

d)  combination of  b) & c)
------------------------------------

p5:subst([p4b],p3a2);

solve for  :laplace(VB(t),t,s)

p5a:solve(p5, 'laplace(VB(t),t,s));

Transfer funtion : TF(s)
=================
(Call : Forward Transfer function)

p6:p5a/laplace(VA(t),t,s);

p6a:TF(s) = rhs(p6[1]);

other way to find : TF(s)  by  voltage divider of impedances
=============================================

p7:p4;

definition : voltage divider
====================

p8:VB(S)/VA(S) = Z1/(Z1+Z2);

p8a:TF(s) = ratsimp(subst(p7,rhs(p8)));

pole : high pass filter
----------------------------

p8b: denom(rhs(p8a))=0;
p8c:solve(p8b,s);

check : 'p6a' ?  'p8a'
----------------------------

p9:is(rhs(p6a) = rhs(p8a));

How to get time constant : τ
=====================

p10:R*C = τ;
p11:rhs(p10) = lhs(p10);

How to get new form : TF(s)
======================

p10a:lhs(p8a) = lratsubst([p10],rhs(p8a));

definition 
=======

V= I.R   ( = wet Ohm)
Q = I.t    ( = Charge relation)
C = Q/V ( = Capacity )

p11a: V = I*R;
p11b: Q = I*t;
p11c : Q/V=C;

find time constant = τ
================

p12:p11a*p11c;
p12a:subst([p11b],p12)/I;

because : t = τ  'time'

RC filter  =>

(C)utoff (f)requency :fC
==================
definition :ω =2*π*f*t

p13:ω =2*%pi*f*t;
p13a:[t=R.C,f=fC];
p13b:subst(p13a,p13);
p13c:solve(p13b,fC);

definition :(C)utoff (f)requency :fC
---------------------------------------------

p13d:lratsubst(p10,p13c[1]);
p13e:subst([p11],p13d);

rem :first order tranfer function
=======================

p14:G(s) = K*rhs(p8a);

differential equation : high pass filter
============================

a) current trough capacitor
------------------------------------

p15a :p4a1;

s above meaning  s  <=>  d/dt

p15a1:i(t) =C*diff((VA(t)-VB(t)),t);

b) current trough resistor
------------------------------------

p15b:i(t) = VB(t)/R;

c) combine  a) & b)
--------------------------

p15c:rhs(p15a1) = rhs(p15b);

p15c1:expand(p15c)*R;

d) solve ode for DC source  VA(t) = E ( fixed value)
----------------------------------------------------------------------
E avaible only  t ≥ 0 :switch

declare(E,constant);

p15d:[VA(t) =E];
p15d1:subst(p15d,p15c1)*R;

1e)  replace  CR with time constant = τ
______________________________

p15d2:lratsubst([p10],p15d1);

2e) a) laplace transform  : VB(0) = 0
_____________________________

p15d3:laplace(p15d2,t,s);

p15d4:solve(p15d3,'laplace(VB(t),t,s))[1];

reason :  t=0, VB(0) = 0

p15d5:[VB(0) =0];
p15d6:subst(p15d5,p15d4);

3e) a) inverse laplace transform
________________________

p15d7:ilt(p15d6,s,t);

4e) a) plot function : VB(t)
_________________

values => 'see fig'

p16:[C =3, R = 5,E=2];
p16a:subst(p16,p11);

p16b:p16[3];

p16c:[p16a,p16b];

5e) a) plot graph  (VB(0) = 0)
______________________

p17:lratsubst(p16c,rhs(p15d7));

p17a:wxplot2d([p17,2], [t,0,30],[y,0,2.2])$

rem : DC  signal blocked  ( When VB(0) =0)

2e) b) laplace transform  : VB(0) = E
_____________________________

p16d3:laplace(p15d2,t,s);
p16d4:solve(p16d3,'laplace(VB(t),t,s))[1];

reason :  t=0, VB(0) = E

p16d5:[VB(0) =E];
p16d6:subst(p16d5,p16d4);

3e) b) inverse laplace transform
________________________

p16d7:ilt(p16d6,s,t);

4e) b) plot graph  (VB(0) = E)
______________________

p18:lratsubst(p16c,rhs(p16d7));

p18a:wxplot2d([p18,2], [t,0,60],[y,0,2.2])$

differentation , 'p18' @ t=0
====================

p18b:diff(p18,t);

p18c:subst([t=0],p18b);

rem  :  y-y1=m*(x-x1)
m = p18c  , x = t 
(x1,y1) = (0,2)

p18d:wxplot2d([p18,2+p18c*t,2], [t,0,60],[y,0,2.2])$

rem : t= τ =15, time constant = R*C (intersecction red line with t axis)