zerodeviation.net - musings of an engineer, web developer, and picky theologian

Archive for the ‘Engineering’ Category

Engineering

May 25, 2009

Audio Amplifier

Tags: ,

Just wanted to get this out there before I forget about it, so I won’t have the schematics up.

This is your basic audio amplifier without any filters or fancy stuff. The little breadboard on the right has the pre-amp stage, a simple inverting op-amp amplifier with a gain of 4 V/V or so to get the voltage up. The one on the big breadboard on the left is the Class AB stage amp that provides the current to drive the speakers.

All that is plugged into my iPhone on one side and some computer speakers (without internal amplifier, that would be cheating) on the other. David Crowder Band – Wholly Yours is playing! You can see the waveform on the scope in the background, too!

Here’s the video, enjoy!

Engineering

April 2, 2009

Matlab Goodness for System Analysis

Tags: , ,

This is mostly for my own reference, but I hope someone else will benefit from it. It’s mainly to play with transfer functions.

First, generate the transfer function:

% numerator coefficients for s^2 + 2s + 4
num = [1 2 4]
% denominator coefficients for s + 6
den = [ 1 6 ]
% build the transfer function
H = tf(num, den)
% now we can do fun stuff like get a bode plot
bode(H)
% or plot it over a range of frequencies, 100 to 200 radians/s
bode(H,{100,200})
% or we could get the gain and phase shift for a certain frequency, 4*pi here
[gain, phase] = bode(H, 4*pi)
% how about zeroes and poles? Okay...
tzero(H)
poles(H)

To add some more stuff, the transfer function can also be generated when you have the factored form of it to begin with:

% if the denominator looks like (s-1)(s-2)(s-3)
poles = [1 2 3]
% same for zeros: (s+1)(s+2)(s+3)
zeros = [-1 -2 -3]
% and finally, gain K
k = 1
% now we can get the system like so:
H = zpk(zeros, poles, k)

I may add more at a later point. Not too fancy stuff here, but pretty helpful to what I needed done.

Engineering

February 5, 2009

Proximity sensor

Tags: , , ,

First of all the video. Music by lostprophets. That’s what I was listening to at the time and thought I’d leave it to make it more interesting.

Schematics and explanation below.

Schematics (click to enlarge):

proximity sensor schematics

The IR LED acts just like any other LED. It’s rated for 100mA continuous current, but to play it safe I only provide about 80mA at approximately 6V. The IR photo transistor acts like a simple transistor with the base current being determined by the IR receiver part. This way, when no IR light is detected, the transistor is in shutoff mode, i.e. it acts like an open, so no current flows and the voltage at node A = Vcc. As more IR light is detected, the transistor changes to active and then saturation mode, eventually acting like a short, which makes the voltage at node A = 0V. So the voltage range, depending on the amount of IR detected, is 6V – 0V. The voltage change is just about linear.

The output voltage is then fed into four op amps that act as comparators. That means the voltage on the positive and negative pins is compared. When the voltage on the + side is larger than on the – side, the output bounces to the positive rail, Vcc. Otherwise it bounces to the negative rail, in this case 0V or ground. The + voltage is regulated using one potentiometer per comparator.They act like a simple voltage divider, so I can adjust the threshold to a value between 6V and 0V, the same range I get from the photo transistor. The outputs of the op amps are connected to one LED each.

Using the pots, I adjusted the threshold such that no LEDs are on when no IR is detected, and all are on when IR is maxed out. That means LED 1 will come on when the voltage is lower than about 4.5 V, LED 2 when the voltage is lower than 3V – the midpoint -, LED3 at anything lower than 1.5 V, and LED 4 at just little over 0 V.

Overall a fun project that wasn’t too difficult to do, but fun to get my hands wet with.