## Tuesday, June 30, 2009

### Circuit Analysis II Lecture 9

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) Getting right into it we start on Page 486 with the equation:
F(s) = 100(s+3)/(s+6)(s2 + 6s + 25)

1. Get the roots:
-3 +- j4

k1 can be solved easily and will come out to -12
k2 can be solved via algebra and you'll get 6-j8
k3 can be determined by taking the complex conjugate of k2,which will be 6+j8.

Now we'll want to convert to polar form

|k2|ejtheta = 10
e-j53.13degrees
and then |k3|ejtheta = 10 e+j53.13degrees

After a bit of math we come upon the equation 10e-3t(ej(4t-53.13degrees + e-j(4t-53.13degrees

Now recall that
(eic + e-jc)/2 = cos c

What that means is we can finish this off by multiplying by two and just taking the contents of the () in the equation and make it cos(4t - 53.13degrees)

We learn that if we have an equation of the form:
|K|e-jtheta/(s+alpha -jbeta) + |K|ejtheta/(s+alpha +jbeta)

We can directly convert that to the equation:
2|k|e-alpha*tcos(beta*t + theta)
Found in table 12.3 page 493

Looking at the equation 10(s+2)/(s2 + 2s + 10)
you can use the repeated roots method above, one more thing to look at though is can you convert it into a form that can be solved by the tables?

Well if you complete the square you'll get the equation:
10(s+2)/(s+1)2 + 32

That looks ALOT like the s domain equation for e-atcos(wt)

Well we can make it look even more like it by simple manipulation and we'll get the equation:
10((s+1)/(s+1)2 + 32 + 1/3 * 3/(s+1)2 + 32)

This can then be easily be moved to the time domain where we get:
10e-t(cos 3t + 1/3 sin3t)

Now recalling that cos (a+b) is equal to cos(a)cos(b) - sin(a)sin(b),
we can assume that since we have the 3t we can call that a or b (doesn't matter)

Now separately we look at the co-efficients for the cos and sin and call them A and B where A (and A = cos a) is the co-efficient of cos and B (and B = sin b) is the co-efficient of sin and say that:
(A2 + B2)1/2 (square root) cos(the remaining variable - tan-1|B/A|)

What that means is that we can take the above equation and apply to our time domain equation and get:
10.5e-tcos(3t - 18.43degrees)

Which happens to be the exact same equation that they got in class and it's alot quicker.

Next we worked on Problem # 2 from the quiz.
We solved it out for the repeated roots, and got the answer's
k1 = 4
k2 = 200
k3 = -4

*Interesting note, not ALWAYS but there are times where k3 = -k1.

Transfer Function
Recall that H(s) = Y(s)/X(s)

With this equation there are always 4 possibilities
1. X(s) can be either a voltage or a current source
2. Y(s) can be either a voltage or a current source

If X(s) AND Y(s) are both voltage or current then they are dimensionless.
if one or the other is voltage or current H(s) is basically either z (impedence) or 1/z

AP 13.10a
We want to do the "unit step" of the function, well since we solved the equation earlier, we need only multiply the equation by u(t) or in the S domain 1/s

AP 13.11
We are looking for the unit impulse response, what that means is that since the unit impulse response in the s domain is 1 then the output is the h(t)
so we would convert v0(t) = 10000e-70tcos(240t + theta)
to the S domain to get H(s) (or the transfer function)
to find the step response we would need to know that tan(theta) = 7/24,
recalling the right triangle we can solve for cos and sin, and solve this equation as well for H(s).

What does this all mean?
Warning I don't know everything nor do I claim to, the below is not something that was taught to us and frankly its only my observations, correct or not that is all they are!
I'm not 100% but from what little I've been able to gather is that this is the "form" of the Ohms law for functions in the S domain, it's not 100% accurate, but in general if you have some equation and you know the 2 of the items H(s), X(s), or Y(s) then you can solve for the third one.

Since Y(s) = H(s) * X(s) that would most likely equate to the V = IR in the normal equation.

Since H(s) = Y(s)/X(s) that would be like R = I/V which sounds about right.
Finally X(s) = Y(s)/H(s) which equates to I = V/R.

So obviously if we had some equation where X(s) is a Voltage, we would want to remember that if we swapped current and voltage in these equations, we would want to invert H(s).

Thats about all I can figure out from this at this point, I only know what I can extract from this information and it appears to me that this is essentially a more generalized version of the Ohms law, it seems to make sense to me!
Practice Problems:
12.41 a & b
12.43 a
AP 13.1-5
13.8-11
Problem 13.49
Examples 13.1,2

Continue on to Lecture 10 7/1/2009

### Circuit Analysis II Lecture 8

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) Agenda:
Repeated Roots -Go over today
Complex roots -Go over today somewhat
Transfer function - Introduce.
Quiz -Hand back.

Starting with Repeated roots.
1. Make sure it's a proper fraction, if it's not long division is required.
2. Write out the equation in k/x form
I.E. k1/(s+1)
3. The equations with nothing raised to a power can be written as a k/equation, and solved like normal.
4. The equations with the power can have the first power written as k/equation...
I.E. k2/(s+4)3
5. Any additional roots are to have the derivative taken then solve
I. E. d/ds(k3/(s+4)2)
Then d2/ds(k4/(s+4))

So lets try AP 12.6
We get the equation in the form (4s2 + 7s + 1)/s(s+1)
Written as k/s + k2/(s+1)2 + d/ds(k3/(s+1))

So we can easily solve for k1 and k2
k1 = (4s2 + 7s + 1)/(s+1)2 evaluated at s = 0
thus k1 = 1/1 = 1

Similarly for k2 = (4s2 + 7s + 1)/(s) evaluated at -1
thus k2 = -2/-1 = 2

Now REMEMBER taking the derivative of k3 requires you to remember that you are solving for k3, but the equation you take the derivative of is (4s2 + 7s + 1)/(s)
after taking the derivative you should end up with 4- 1/s2 evaluated at -1
k3 = 4 - 1 = 3

So we solve it and get the equation:
F(s) = 1/s + 2/(s+1)2 + 3/(s+1)
Converting back to the time domain is as simple as looking at the tables and converting directly back.

Next we look at complex roots
AP 12.5
Things to remember:
1. k2 is the -root
2. k3 is the +root
3. k3 = k2*
-b +- (b2 - 4ac)1/2/2a (wikipedia)
5. (s - s-)(s - s+)
6. Solving the equation for k2 where s = -5+j12
7. Solving the equation for k3 where s = -5-j12
8. eajt - e-ajt/2j = sin (at)

Moving onto the equation we solve for the roots since the other parts are quite easy.
F(s) = 10(s2 + 119)/(s+5)(s+5-j12)(s+5+j12)

So solving for k2 we get (after much pomp and ceremony and of course algebra) we get j25/6
and of course since we know that k3 = k2* we can safely say that
k3 = -j25/6

Now we convert back to time domain.
which we'll get:
f(t) = (10e-5t + je-(5-j12)t - j25/6e-(5+j12)t)u(t)

Now leaving it in that form isnt good because we still have complex numbers in there, re-arranging the equation we get:
e-5tj25/6(ej12t - e-j12t/2j)*2j

a little more massaging we get (remember #8 above):
f(t) = (10e-5t - 25/3e-5tj25/6(sin 12t)) u(t)

Next we discussed the transfer function!

Basically we look at it this way:
fi(t) -> h(t) -> fo(t)
1. fi(t) represents the input, or X(s) in the s domain
2. h(t) represents the processing of the input (voltage or current), or H(s) in the s domain
3. fo(t) represents the output, or Y(s) in the s domain
This process now only works in the S domain.

Now what we can gather from this is that if the input changes we can determine the output by finding the answer to the equation
X(s) * H(s) = Y(s)

So what this means is that if we have H(s) solved we can change either the input or the output and determine the other.

Finally we went over the quiz and were recommended some problems to work on.

1. V0(s) = 25(s+2)/s(s2 + 2s + 10)
*practice problem for complex roots.

2. I0(s) = 104/(s+80)(s+30)2 A
V0(s) = 5*104s/(s+80)(s+30)2 V
*practice problem for repeated roots.

3. v(t) = (10e-1000t - 10e-4000t)u(t)

Continue on to Lecture 9 6/30/09

## Monday, June 29, 2009

### Error Checking

I was reading the book Mastering Regular Expressions by O'Reilly (BTW a great book and one I'd like to eventually do a review on), one of the initial topics the author spoke about was using regular expressions to check a file for errors. I liked the idea, but typically again we had to open the command prompt to run it and it was just not as "friendly" as I like things to be.

Onward we look to my context menu "hack". Basically what we'll do is write a perl script that will take whatever file was passed to it check it for errors and then when you want you can close it.

Lets look at our order of events here:
1. Discuss the script
2. Point you to the how to add to your context menu (we'll need to use the registry editor since windows doesn't seem to like perl scripts in the file types box)
3. Try it out!
Script:
if (scalar(@ARGV)>0)
{

\$file = @ARGV;
print "Testing \$
file \n";
}
else

{
print "Please drag the file you would like to see errors in onto the screen\n";
\$file = <>;

}

open DATAFILE, "\$file" or die "Missing \$file file.\n";
open (DATAFILE, \$file);
@getData = <DATAFILE>;
close (DATAFILE);
\$errors = 0;
\$lineNumber = 1;

foreach \$inputLine (@
getData)
{
if (\$inputLine =~ m/\berror[(s]?\b/i)
{
print "\$lineNumber ) \$inputLine \n";

\$errors++;
}
\$lineNumber++;
}

print "Complete!\n\$errors Errors found!";
\$asdf = <>;

Breaking it down:
if (scalar(@ARGV)>0)
{

\$file = @ARGV;
print "Testing \$file \n";
}

else
{
print "Please drag the file you would like to see errors in onto the
screen\n";
\$file = <>;

}

What this line does, is checks to make sure you at least have one argument, if you don't then it waits for you to type a file in that you want to check (or as stated you can drag the file onto the window). If you use an argument we'll print the file (in case you didn't actually type the filename in)

Next,
open DATAFILE, "\$file" or die "Missing \$file file.\n";
open (DATAFILE,
\$file);
@getData = ;
close (DATAFILE);

\$errors = 0;
\$lineNumber = 1;

Open our file get the contents set our error and linenumber variables to zero.

Almost done:
foreach \$inputLine (@getData)
{
if (\$inputLine =~ m/\berror[(s]?\b/i)
{
print "\$lineNumber ) \$inputLine \n";
\$errors++;
}

\$lineNumber++;
}

This rolls through each line of the file (each line is a different item in the array), checks for words that are error OR errors OR error(, prints that line and then increments our error counter as well as we increment our linenumber variable everytime we move through the array.

Lets look at our Regular Expression:
\$inputLine =~ m/\berror[(s]?\b/i

Breaking it down it literally means
match the beginning of a word, if it matches error error( or errors and ends the word and any variation of capitalization we can find we will return a positive match.

This can be modified to work with any kind of error or even any kind of other word you might want to look for in a particular file.

The last 2 lines basically keep the window from closing immediately if you haven't setup your system to keep the window open after running.

Next comes updating our registry to handle this!!! Check out this page, it contains a detailed how to modify our registry to add a command to the context menu.
What we'll be looking for is the txtfile entry.
if there isn't a key for shell add one, then add Check_For_Errors (or insert whatever you want to call it), then add one more key for command. This is the command I stuck in for the REG_SZ:
cmd.exe /k "C:\batch\checkErrors.pl %1"

So what that's going to do is open a command prompt and run the following which happens to be our perl script. just substitute the location where you saved your perl script at.

Lets check it out, I tried the above script on a text file containing this text:
This line contains an error.
if I knew any better there would be no errors in this file.
But unfortunately I will always make some kind of Error.
Now I know this line doesn't contain one.
But this one contains one with a ( like this error(
the only problem we'll run into is if we get errors( Good luck let me know how well it works out for you.

## Wednesday, June 24, 2009

### Circuit Analysis II Lecture 7

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) The links on the right, will contain all the links to this course's lecture notes.

In class we did 2 practice problems.
Problem # 1 was a circuit with a voltage source, resistor and capacitor in series, and an inductor in parallel with the capacitor.

The values are as follows:
Source = 30v
Resistor = 800 ohms
Capacitor = 6.25 uF
Inductor = 2.5H

1. We convert to s-domain
2. We find a node voltage equation
3. We solve for the node
(there happens to be only one node so we only need to solve for the one node).

Then it's Solved!

Next we worked on problem 13.42

1. Convert to s-domain
2. Get node voltage equations
3. Make v2 in both equations the same
(simply multiply both equations by the coefficient)
4. Add the equations and get one equation.
5. Multiply thorough all the parts, and then combine like items,

We end with the correct answer (can be found in the back of the book)

Don't forget we have a quiz tommorrow (June 25th, 2009)

Continue on to Lecture 8 6/29/09

## Tuesday, June 23, 2009

### Circuit Analysis II Lecture 6

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) The links on the right, will contain all the links to this course's lecture notes.

First we worked on problem 13.8c
it turns out that there is only one node so the equation is:
v1 - 20/s / 2 + v1 / 1.25s + v1 / 20 /s - 5/s = 0

Now we can simply solve for v1

Next we went over Thevinin starting on page 520, figure 13.17 - 19

First we migrate to the s-domain, so we end up with
480/s for the source
2*10-3s
Since we are looking at the circuit and the 60ohm resistor is not connected so it has no current running through it, so we can get rid of that particular resistor.

We end up using voltage division because we want to know the voltage at the inductor in this particular example.

vth = (480/s / 20 + .002s * .002s)
so pulling things out and canceling things out we get
vth = 480 / s+104

Next we want to convert it to look at it from the a and b terminals, so what we'll want to do is get rid of the source, remember:

voltage = short
current = open
doing that we can get zth
zth = (20s / s + 10000) + 60

Cleaning it up we get:

zth = (60s + 6*105 + 20s/s + 4)

and finally we can get:
80(s+7500)/(s+104)

Now we add a 5uF capacitor to the a and b terminals, so looking for the current we get:
Ic = (480/s+104) / (80(s+7500)/(s+104))

Basically what we're looking at is
Ic = vth / zth + zc

after solving it we get 65/(s+5000)2

We would be able to do partial fraction decomposition to continue but that is outside the scope of this class period, so we didn't continue.

Next we worked on problem 13.20 on page 552
1. We want to move to the s-domain
2. Next we find Req
note: we use voltage division in this case.
3) Using Partial fraction decomposition we want to get the k's
4) Convert back to t-domain

Next we worked on Problem 12.42a page 504
F(s) = (10s2 85s +95) / (s2 6s + 5)

First reaction might be to try to reduce it, but it turns out this is not a proper fraction and therefore we will need to do long division to make it a proper fraction.

Once we do that we get
10 + (25s + 45)/(s2 + 6s + 5)
reducing it we get:
10 + (25s + 45)/(s+1)(s+5)

using partial fraction decomposition for the second part we get,
20 and 5 for the k's

since 10 is a constant we use (delta)(t)
so our equation ends up as:
10(delta)(t) + 5e-t + 20e-5t

Finally we tried one last one and that was:
problem 12.21a
20e-5(t-2)u(t-2)
which using the laplace transform from the table f(t-a)u(t-a)
we get
e-2s-20/(s+5)

Continue on to Lecture 7 6/24/09

### Circuit Analysis II Lecture 5

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) The links on the right, will contain all the links to this course's lecture notes.

First,
AP 12.3 page 485

F(s) = (6s2 + 26s +26)/(s+1)(s+2)(s+3)

using Partial fraction decomposition we get
K1 = 3
K2 = 2
K3 = 1

Of course converting back to the time domain we get
(3e-t + 2e-2t + e-3t)u(t)

Next we do Problem 13.5 from page 519
Our plan is to move to the s-domain, analyze the circuit and then move back to the time domain (or t-domain)

The circuit in the s-domain has the values as such:
5/s for the current
15/s for the voltage
1/s for the capacitor
s for the inductor

Additionally to note is that we have no initial charge so we don't need to "convert" the inductor to a inductor current/voltage source combination, as well as the capacitor.

So using Nodal Analysis we get:
Node 1:
-5/s + v1/1/s + v1 - v2/s = 0

Node 2:
v2 - v1/s + v2/3 + v2 - 15/s / 15 = 0

We were asked to solve for v1 and v2

we were given that it ends up as :
s(s+3) / s(s+.5)(s+2)

Using Partial Fraction Decomposition:
We were asked to solve for all the k's.

Once we finish, convert it to t-domain.

We were then asked to try it using mesh current.

Hw: Try 13.42, and Ap 13.8c using node voltage

Review Thevinin, Norton Equivalent for next class.

We then went over the test, as well as did all the problems.
I have problem 7 solved, and 8 solved, from class, the rest of the problems can be given if you just either leave a comment or email me.

Continue on to Lecture 6 6/23/09

## Monday, June 22, 2009

### VB6 Speed Tests I

This will be a multipart series to explain how to do some speed testing/throughput of a program.
So I was thinking about this the other day,I have a few programs that take a little bit to get setup and start running. I found that I would really like to know how long it takes for a particular function to run. In the past I usually just stick a timer of some sort at the beginning and end of a particular function.

This works great for a particular function, but lets say you have a fairly large program and would like a big picture of the times of the entire program?

I got to thinking about it, now the particular version of the code that I wanted to time was actually VB6 code, so I thought "hey I can write a perl program that will just open these files up and add 3 variables in the beginning get the clock count, then move to the end of the function and get the clock count and then print it out to an output file.

So I got going....Follow along if you dare....

So let's work out an algorithm or a set of steps that we are going to attempt to do!
1. Search for anything in the file that starts with Public/Private Sub/Function
2. Insert our initialization of our variables and code for getting initial clock time
3. Search for End/Exit Sub/Function
4. Insert code to get the last clock value.
5. Insert code to calculate the diff from the end time-start time
6. Insert code to print out the value last calculated.
* A catchya I found was that even though I was opening .cls files, there is text at the beginning of the file to I suppose initialize the class as VB is opening, what this amounts to is that you have now stuck a "declaration" before the page was setup, so you'll need to trigger on sticking the code in right after this chunk of "header" data.

So now what we will hopefully have (by this point), will be the times that each function is running, also how many time's it's ran (because EVERY TIME it is ran it will print out a time).

Let's start taking apart this file I wrote up...I'm sure it can be modified to work with most programming languages...but this one will specifically explain for VB6 (possibly working for VB.Net+)

@file_list = <*.cls>; #match the normal cls file extensions

So here we want to get a list of all the .cls files in the folder (since most of my functions are here this is where we'll start anyways!

foreach \$file (@file_list) {
open DATAFILE, "\$file" or die "Missing \$filename file.\n";
open (DATAFILE, \$file);
@filenames = ;

close (DATAFILE);

\$one = 0;
for( my \$n=0; \$n < scalar(@filenames); \$n++)
{
if (\$filenames[\$n] =~ m/^\s*(Public|Private) (Function|Sub)/)
{
\$one++;
}
}

if (\$one > 0)
{
open (OUT, ">\$file");
}
else
{

}

So what we've done is we read in each file check to see if there are functions and if there are we open the stream to output our updated file contents to.

The interesting thing to note is that we used a nice regular expression I managed to learn from the regular expression book published by O Reilly, I plan to do a book review on it in the near future,

m/^\s*(Public|Private) (Function|Sub)/

Now the interesting thing to see is that there is always more then one way to do things, and I feel like this looks way better then:
m/^(\s+|)Public Function|^(\s+|)Public Sub|^(\s+|)Private Sub|^(\s+|)Private Function/

So what I am doing is searching for a string starting with none or more spaces containing either public or private, AND either function or sub, the top example shows it much more elegantly.

Stay tuned as I write more follow on posts.

### Future Posts

I've been looking around and have noticed that my posts have a habit of getting quite long, something I would like to try to limit.

I want my posts to follow 3 c's:
1. clear
2. concise
3. consistent
The whole point of me starting this blog was to improve my clarity in explanations. Hand in hand with clear writing is concise writing, get to the point, explain what we're working towards, and that's it. I feel like the consistent is lacking in that I don't post often enough, with quality content,
I hope and plan to work on that, I will continue to post notes from my class, but I intend to post on other subjects I've been reviewing.

If you have any other suggestions or recommendations please let me know (if anyone out there happens to find this blog....)

Thank you,
Tyson

## Sunday, June 14, 2009

### Random Post: "Handbrake Perl Script" I have Google Analytics setup on my blog and I can see the keywords that have actually brought people to my site.... I find this interesting and this inspires me...If it's obscure, why not try to "guess" what the person was searching for and then do a post on that subject, if it's pretty straight forward,why not solve it..
Today's keyword subject is : perl script handbrake windows

This one doesn't look too bad.

Per Handbrake.fr's site:
HandBrake is an open-sourced, GPL-Licensed,multiplatform, multithreaded, video transcoder, available for Mac OS X, Linux, and Windows
Looking at the documentation on handbrake's site, there is a command line interface, so we can use that to make any calls to the handbrake program.

The basic command we are going to use would be:
HandBrakeCLI -i source -o destination
\$source = "sourcefile";
\$destination = \$source . "_converted";
print `HandBrakeCLI -i \$source -o \$destination`;

This will simply take whatever specified source file we have and output to the destination location.

But if that was all we wanted to do we wouldn't need a perl script would we?

How about if we have a list of files in a document (along with paths)?

We can open that document grab all the paths then simply do a mass conversion!

The final "guess" would simply grab all files of extension x and convert them and dump them in a folder. Again this isn't hard as well.

Lets start with this one, it shouldn't be too bad, of course we'll want to do some error checking, such as if we already have a converted filename of the same type then we definitely want to hold off on converting.
Regardless let's see what we can come up with real quick!
@file_list = <*.mpg *.avi *.vob>;
@converted_list = <*.mp4>;
\$extension = ".mp4";
Here we are grabbing a list of all the files we might want to convert, note that you can update that list to contain whatever extensions you might have/like to use. We also grab the list of converted files in there just to do some error checking (in case you leave all your files in the same folder), also the output type should match the type of files you are trying to convert to. We also should define our extension for later use!

Now it's a matter of rolling through each item in the filelist, so we'll start a for loop:
foreach \$file (@file_list)
{
@filename = split(/./, \$file);
\$exists = 0;
}
Something to note is that we want to do a search on the filename in the converted files so in order to do that we'll need to break up the filename from the extension.

Now inside this loop we'll want to do a quick check to see if the file we have a handle on is already listed
foreach \$converted (@converted_files)
{
if (\$converted =~ m/@filename/i)
{
\$exists = 1;
}
\$baseName = @filename;
}
So now we've done a check and if we have a file that our converted files contains.

What we can now do is make an if/then that will basically skip the file altogether if we see that \$exists contains a 1!
if (\$exists == 1)
{
}
else
{
\$source = "\$file";
\$destination = \$baseName . "_converted" . \$extension;
print `HandBrakeCLI -i \$source -o \$destination`;

}
Something to remember:
If you want to save to a separate folder I would recommend doing a check for whether that folder exists rather then grabbing a list of files in the current directory.
Entire Script (small text...just copy paste):
@file_list = <*.mpg *.avi *.vob *.AVI>;
@converted_list = <*.mp4>;
\$extension = ".mp4";

foreach \$file (@file_list)
{
@filename = split(/\./, \$file);
\$exists = 0;

foreach \$converted (@converted_list)
{
if (\$converted =~ m/@filename/i)
{
\$exists = 1;

}
\$baseName = @filename;
print @filename . "\n";
}

if (\$exists == 1)
{
}
else
{
print "Converting";
\$source = "\$file";
\$destination = \$baseName . "_converted" . \$extension;
\$asdf = <>;
print `HandBrakeCLI -i \$source -o \$destination`;
}
}

The only difference between the above script and one that will open a document and pull all the filenames from it is that you would use the command:

open DATAFILE, "\$inputfilename" or die "Missing \$inputfilename file.\n"; open (DATAFILE, \$inputfilename);
@file_list = ;
close (DATAFILE);
The above would replace the line:
@file_list = <*.mpg *.avi *.vob>;
That's really the only difference!

Well let me know what you think in the comments and if you happen to have found this site looking for just this random post please let me know!!!

## Friday, June 12, 2009

### Circuit Analysis II Lecture 4

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) The links on the right, will contain all the links to this course's lecture notes.

Beginning with
F(s) = -20(s+15000)/s2 + 15000s + 50*106

By factoring it out we can find the equation
-20(s+15000)/(s+10000)(s+5000)

Our game plan will include fraction decomposition, then we just convert back to the time domain using the Tables in the book.

Decomposition: -20(s+15000)/(s+5000) (where s = -10000) k1= 20

and,
-20(s+15000)/(s+10000) (where s = -5000) k2 = -40

This brings us to:
20/(s+10000)-40/(s+5000)

Because this looks like e-ax we can convert it as such:
f(t) = (20e-10000t - 40e-5000t)u(t)

Again we need to remember to use u(t) to keep it in the positive domain which is the only place Laplace Transforms work.

Next we work on the equation:
9600s/s2 + 140s + 62500

We can find a perfect square and get
9600s/(s+70)2 + 2402

if we take and replace s with (s+70-70) this then looks like something we can work with
so we can break it up looking at it in the respect of what does our "k" have to be to make the number 240 (which is our w), it happens to be that it has to be 2800

so we end up with:
9600e-70tcos(240t) - 2800e-70tsin240t

Problem 12.18c the book actually has the wrong answer in it so,
remember that the second derivative of t2 is actually 2 and since we can get (2!/s3) * s3 will give us 2 then the previous information will cause it to be 2-2 which is 0

Problem 12.35, this problem requires us to know the equation that we get from section 12.28, and that is based on section 12.6
So Section 6 primarily talks about RLC circuits which you have a basic equation for:
Idcu(t) = v(t)/R + 1/L(integral)v(x)dx + Cdv(t)/dt

Here are some things we can note from this equation:
1. We can transform each part.
2. We can then solve in the S domain
3. This will come out as a rational expression and can be solved.
4. We can convert back to time domain

Some equations to note:
V(s)/R = v(t)/R
V(s)/sL = (integral)v(x)dx
C[sV(s) - v(0)] = Cdv(t)/dt

So the equivalent circuit in the S domain will now look like this:
Idc/s = V(s)/R + V(s)/sL + C[sV(s) - v(0)]

Re-arranging to make it set to V we get the equation:
V(s) = (Idc/C)/s2 + s/RC + 1/LC

Now the expression is in an algebraic form and can be manipulated!
This solves Problem 12.28 and allows us to simply plug in the values from 12.35.

120000/s2 + 10000s + 16000000

This can be factored down to
120,000/(s+8000)(s+2000)

Using partial fraction decomposition we can get the values 20 and -20
which can be easily be converted using the Laplace tables.

We can have table 13.1, 12.2,12.1 copied for the test

Some things to make sure you know what to do for the test are:
RC, RLC, RL circuits with and without source as well as with or without an initial charge

Practice problems:
12.23b

f(t) = (integral)e-axcos(wx)dx
This follows nearly identical to an operational transform from the book:
Time Domain S domain
(integral)f(x)dx = F(s)/s

and the f(x) part looks like
Time Domain S domain
e-atcos(wt) = s+a/(s+a)2 + w2

Problem 12.21a
f(t) = -20e-5(t-2)u(t-2)

This looks alot like the transform f(t-a)u(t-a) which = e-asF(s)
so using that information we can gather that
a = 2 for the e-as
and for F(s) we would use f(t) so replacing t-2 with t we get -5t for the exponent,
so we have for F(s) a=5

Converting to the S domain we get the equation:
-20e-2s/s+5

Finally we tried
(8t-8)u(t-1)

we simply pull the 8 out to get
8(t-1)u(t-1)
Using the same equation we did for the last problem. we'll get
8e-s/s2

Continue on to Lecture 5 6/22/09

## Thursday, June 11, 2009

### Circuit Analysis II Lecture 3

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) The links on the right, will contain all the links to this course's lecture notes.

Starting with the class with doing AP 12.2c
Looking for the laplace of :
t cos(wt)

This looks alot like
tf(t)
which is in the table and can then be converted fairly easily, so doing this you would do:
-dF(s)/ds

Substituting our equation in we get
-d(s/s2 + w
2)/ds

Now we would have to take the derivative and then we'll get the same answer as in the book.

Next we worked on problem 12.17a
the integral of e-axdx

This looks strikingly similar to
F(s)/s
so substituting it in for it we get
(1/s+a)/s

and finally
1/s(s+a)
In this case x and t are interchangeable since they are describing the same thing (a variable), which is why we could use the form from the table.
Followed by Problem 12.23a

Figure out the Laplace of:
f(t) = d/dt (e-atsin(wt))
looking at that equation we can say that everything in the parantheses would be the equivalent to f(t)

Using that we can use:
df(t)/dt = sF(s) - f(0)

Then we can convert it to
sw/((s+a2) + w2)

Next we attempted
F(s) = 40/(s2 + 1.2s +1)

To do this problem we want to do completing the square, so we would end up with :
40/((s+.6)2 + .82)
we can get w in the top to match the form
w/(s+a)2 + w2

so we just do 40/.8 which gives us 50 so we can put the equation in the correct form looking like this:
50 * (.8/((s+.6)2 + w2))

now converting back into the time domain
50e-.6tsin(.8t)

Continuing
A circuit with a voltage source (160v), a resistor(4.8), an inductor (4H) and, a capacitor(.25F) all in series, to be solved for.

*Remembering that V = IR
I(s) = (160/s)/(4.8+4s + 4/s)

moving s down to the denominator and pulling a 4 out we get the equation as such:
I(s) = 40/(s2+1.2s+1)

Since we have already done this equation just a few moments ago we can consider ourselves done.
Next we look at the equation
F(s) = 10(s+6)/(s+1)(s+3)

Using Partial Fraction Decomposition we are able to get
K1 = 25
K2 = -15

From there we sub them back in and get
25/(s+1) - 15/(s+3)

Using the Table to convert from Laplace to time domain we get:
(25e-t - 15e-3t)u(t)
We add u(t) on there to force this equation to only be valid in the Positive time domain, this works because u(t) = 0 for all time less then 0 and u(t) = 1 for all time greater then 0.
Problem 13.9 on page 550

Breakdown of how we'll solve this circuit:
1. Get the Initial values for the circuit using t<0,>
2. Calculate the rest of the circuit using the initial values, again draw the circuit.
3. We are looking for the voltage across the capacitor so we can use the voltage division.
4. Use Partial fraction decomposition to finish the circuit off and solve the formula
Your t<0>0 circuit consists of the inductor (.8H) another resistor (2K), and a capacitor (1.25uF) all in series

to find V we use the equation
(8*105*12mV/s)/2*103+.8s+(8*105/s)
That eventually ends up in the form:
12000/(s2 + 2500s + 106)

We continue and use partial fraction decomposition and leave 12000 in and we get 8 and -8 for our k's
following that through we can use the equation
-((1/8)/(s+500) - (1/8)/(s+2000))
which again looks alot like a Laplace form answer
k/s+a
convert it back and you're golden!

Practice and In-class problems and guidelines for Test #1:
1. Section 12.1,2,4,5
2. AP 12.2a,c
3. Problems 12.13a-d,12.14b,12.17,18,23,35
4. Section 13.1,2,3 (p512-3)
5. AP 13.4a,b
6. Problem 13.9
Assigned reading for the following week is:
1. AP 12.3,4,5
2. Review Chapters 3,4,7,9
3. Review Appendix B (Complex Numbers)

Continue on to Lecture 4 6/11/09

## Wednesday, June 10, 2009

### Circuit Analysis II Lecture 2

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:
Electric Circuits (8th Edition) If you haven't read Lecture 1 it can be found here:Lecture 1

Also if you notice the links on the right, there is a list of links that will contain all the links to this course and you can move around freely, this will become nicer as there are more Lectures posted.

The main topic of this class period was converting actual circuits to the s domain, then using algebra to re-arrange the equations to a format of a function that the table has for you.

Key points:
• Time domain is represented by small letters
• S domain is represented by Capital Letters
• di/dt = sI(s) - i(0)
• I0 = i(0)
• ZL = sL and since s = jw then ZL = jwL
• I0 indicates Initial charge
• If your target is Voltage convert the circuit to use Current
• If your target is Current convert the circuit to use Voltage
First problem was to convert a inductor in series with a resistor

Our target was Current so we converted it using Table 13.1 to a series circuit.
Inductor = sL
Source = LI0
Resistor = R

Now we are able to treat this as a circuit using Ohms law (Remember V/IR)
So, I = (LI0)/(R + sL)

Now it's time to move back to the time domain,
Since this circuit looks most like k/(s+a)
we can massage it into a form similar
pulling L from the bottom we get the equation:
I = L(I
o)/L(s + R/L)

The L's cancel so you are left with:
I0/(s+(R/L))

Which if you say:
K = I0
a = R/L
you have the form k/s+a

Simply Converting back you have
I0e-(R/L)t

Next we tried the same process with a circuit containing a Capacitor
Again the target is Voltage so we use Current.

so using the formula v = ir
and
V = CV0Zeq

Zeq = R1R2 / R1 + R2

Inserting the "newly determined" values for the capacitor and Resistor.
We have ((1/cs)*R)/(R + (1/cs)) which is equal to:
R/(Rcs + 1)

Putting that back in our equation gives us
V = CV0 * R/(Rcs + 1)

extracting C and R from the equation gives us:
CRV0/CR(s+1/RC)

That is then transformed to
V0 / s+ (1/RC)

Now we do the same as with the Inductor circuit we try to find a similar Laplace Transform we can invert!
Again it looks like k/s+a
k = V0
a = 1/RC

V0e-t/RC

The Final Problem we did was try to use the RL circuit from 7.3 which is a RL circuit with a source:

We are going to say that L has no initial charge thus I0 = 0

Converting to the S domain we get
Inductor = sL
Resistor = R
Source = Vs/s

Now we look at the equation we can get from that:
I = (Vs/s)/(R+sL)

This can be rewritten as:
Vs/s(sL + R)

Using Partial Fraction Decomposition we would use an equation of the form:
A/s + B/s+a
and then solve for A and B

Doing this we get
A = 1/2
B = -1/2

Subbing those back in we get the equation:
Vs/L * ((1/(R/L))/s - (1/(R/L)/s+(R/L))

Simplifying and extracting L we get:
Vs/R * (1 - e-Rt/L)u(t)

Note: The u(t) added to the end will keep our function in the positive time domain which is what we want to happen.

Recommended Study/Homework
Use the S Domain for:
Ap 7.1, 7.3

Continue to Review Chapter 3, 7, 9.

Good reference videos on Differential Equations from MIT's OpenCourseWare Site: MIT OpenCourseWare Laplace Transforms (direct link to the video...very helpful on explaining how it works)
Continue on to Lecture 3 6/10/09

## Tuesday, June 9, 2009

### Circuit Analysis II Lecture 1

Disclaimer: This series of posts is to serve as notes for myself as well as any others interested in the subject of Circuit Analysis II. This is the course ECE 213 at UNM.
The course will follow the book:

Next, we
discussed the concept of voltage in ECE 203 (Circuit Analysis I)
v(t) = v0 where t>= 0
later in that semester in Chapter 9 we considered where v(t) = Acos(wt + phi)

Now, in ECE 213, we are to consider "all" cases of voltage for example
v0u(t) or ku(t)

when u(t) = 1 t>0
when u(t) = 0 t<0

This is a stepwise function

Important Note: u(t) = 1

In the previous section of this course we learned about moving from the time domain to the phasor domain.

The direction of this course will be learning to move to the s domain.

One Aspect of the S domain is the use of Laplace Transforms to be able to move more difficult equations to a easier to solve format, then the ability to move that back using an Inverse Laplace Transform.

Important Note: s = jw (j omega that is)

When moving from the time domain to the s domain we will be referring to our equations as such:
Time Domain f(t)
S Domain F(s)
Therefore whenever we are looking at f(t) we are looking at the function in the time domain and with F(s) we are looking in the S domain.

Looking at tables 475 and 480 there is a list of Laplace Transforms a quick google search nets this site which looks to have a good chunk of the Laplace Transforms

Something to remember is that f1(t) * f2(t) != F1(s) * F2(s)
(That is they are NOT equal)

We proceeded to take a look at problem 12.13
the first 2 (a,b) are pretty simple because we look at the table and there is a direct correlation.

Part C uses an equation of the form sin(ab + c) which remembering our trig identites such that sin(ab)cos(c) + sin(c)cos(ab) once we have that information we are able to break the problem up pretty quickly.

Next we looked at the Laplace of the equation df(t)/dt = sF(s) - f(0)

What that equation means is that we are including an "initial condition" which is f(0).

Next we looked at the VI relationship in this new section and compared them to the time domain.

For a resistor we use the relationship v=ir in the time domain
in the s domain we would use V(s) = RI(s)

For an Inductor we use v(t) = Ldi/dt in time domain
in s domain we use V(s) = L(sI(s) - i(0))
If you note that last equation we used the equation mentioned above that follows the form df(t)/dt = sF(s) - f(0)

For a Capacitor it's the same process
i(t) = c(dv/dt) in time domain
I(s) = C(sV(s) - v(0)) in s domain

It's interesting to note that the formula for impedance is ZL = jwL
if you remove the initial condition of the equation for the inductor it's the equation sLI(s) since s = jw then it's jWLI(s) which then is essentially V = ZI

by re-arranging the equation of an inductor you have I(s) = V/sL + I0/s

Homework/Review material:
Review Chapters 3, 7, 9
Problems 12.17,18,19

All links to future and past posts regarding this topic will be found on the right column, so you can jump from lecture to lecture!

http://www.vibrationdata.com/Laplace.htm
Circuits Book

Continue on to Lecture 2 6/09/09
If you have any Comments, Suggestions or Questions please leave them in the comments and I will do my best to address them.

## Monday, June 8, 2009

### Windows Selected Filenames Pt II

Welcome back, well as we all know, in the words of my good friend Phil:
"But with all programming/design problems – there are a multitude of unique methods that may be employed to removed the dermal layer of the felinus domesticus"
If you don't know how to setup a "right click" menu item for files and folders I would recommend checking out the following posts:

Lets get on with it, This "version" of the selected filenames will use the same steps to get it up and running, (right click menu), but the only difference is that now when we have our script setup we'll copy the files to the clipboard, then deslect the files and right click on a single filename and select your copy filenames script, Lets get into the meat of this script,

#! perl
use WIN32::CLIPBOARD;

\$text = "";
\$CLIP = Win32::Clipboard();

if (\$CLIP->IsFiles())

{

@files = \$CLIP->GetFiles();

foreach \$file (@files)

{
@sp = split(/\\/, \$file);

\$text = \$text .\$sp[@sp-1] . "\n";
}
\$CLIP->Set(\$text);

}
Breaking it down again:

First we declare:
use WIN32::CLIPBOARD;
This is so we can use Windows Clipboard functions

Next is
\$text = "";
We want a clean text string.

Then,
\$CLIP = Win32::Clipboard();
Here we setup the \$clip as a clipboard object.

Next,
if (\$CLIP->IsFiles())
What this is doing is checking that there are "files" in the clipboard, we want this because otherwise we'll try to write "nothing" to the clipboard and I'm sure that's not a problem, but if for some reason you really didn't mean to do this and you already had text in the clipboard then it won't overwrite your text clipboard contents, either way it won't write to the clipboard if you don't have any files in the clipboard, you can remove this if you want but I haven't tested it out, it may work just fine.

Then,
@files = \$CLIP->GetFiles();
This chunk of code goes out and gets the files in the clipboard, and stores them in an array.

Next,
foreach \$file (@files)
So what we're going to do is run the next couple of lines for each file (or in this case we'll be grabbing the filename)

Then,
@sp = split(/\\/, \$file);
This line splits the "filename" up into segments if you were interested in the whole pathname you could omit this step and just assign the \$text variable to whatever \$text contained and the \$file variable plus "\n", so you get each filename on a new line.

Next,
\$text = \$text .\$sp[@sp-1] . "\n";
This takes the split up line above and grabs the last bit of it, which happens to be the actual filename. Remember if you wanted the entire pathname you could use the \$file variable like so,
\$text = \$text . \$file . "\n";

Finally,
\$CLIP->Set(\$text);
This line sets your newly created text to the clipboard!

Give it a try and let me know how it works out for you!

I'm sure this isn't the last post about this subject, as always things are always improving, I am constantly thinking of a way to cut back on the amount of steps to run this little "tool" my plan is to eventually "simulate" the keystroke to "copy" the files then copy the filenames, not sure how to go about it, without running multiple instances, I'm sure hotkeys will be a big help on this, either way I'll be improving this script again in the future...Stay tuned I'm certain there will be more posts on getting this working better.

## Saturday, June 6, 2009

### Server Part II

Continuing from our previous post: Server Part 1
Review:
2. Setup Harddrives

Ok time to get started...

1. Download and burn an ISO of the Server Ubuntu 9.04 Server Edition

2. I was having some problems installing so I decided that rather then chance losing data, I unplugged all the hard drives on my server leaving ONLY the HDD that I intend to install the software on.

3. Boot to the ISO burned in step 1.

4. Follow the prompts, I was fine with letting the disk setup the entire thing, just select the defaults (If you have different preferences make the changes as needed). 5. When you reach the point where you choose what kind of server you want I selected Samba Server.

6. Once it's done try rebooting (without the Server Install disk in the cdrom drive) and see if it comes up, if it does, great, continue on then.