Read Latex

Friday, February 03, 2012

Circuits As Proofs: Episode 1



Electronic Circuits As Mathematical Proofs
Episode 1: Resistance is Futile
L. Van Warren MS CS, AE

Warren Design Vision
 wdv.com
Friday, February 3, 2012

Introduction
I want you to forget for a moment that you are reading this as a consequence of digital technology.  I want you to forget that the screen it was written on was imaged as ones and zeros running through a multitude of logic gates at high speed. I want you to forget the mountain of computational complexity we use everyday as our lofty perch.

A Lofty Perch
The Naked Truth
At various points in school and life you may have encountered a mathematical proof. For many they are tedious, boring and purposeless arguments that seem to serve no purpose but their own. I hope to convince you that without them, the digital revolution you now enjoy would not have happened. Further, I hope to give you a way of seeing proofs as never before, as everyday objects,  familiar as bread and butter that you can consume to increase your understanding.
An Everyday Yet Monumental Example
When one enters a dark room, a common behavior is to flip on a light. A switch is thrown, and usually, but not always, the light turns on. Most of the time we proceed without giving this monumental event a second thought. But I tell you, that when and if that light came on, at that very moment, you proved something. You proved something mathematical. You proved something real. You proved that the light, and everything connected to it," worked". This is profound.
Not finished with your monumental act, you did something just as stupendous. When you left the room, the switch was thrown again. Usually, but not always, the light turned off.
If you flipped the switch AND the light came on, you proved that:
1)    the switch "worked", it served as a human control between an OFF state and an ON state.
2)    the wires from the switch to the light were connected and conducted electricity.
3)    the light itself "worked", that its filament, tube, or junction converted electricity into light & heat.
4)    that the power company, however complex, was intact and functioning.
If you flipped the switch and the light didn't turn on, you proved that one or more of the above statements was false, an equally majestic and complex treat of logical possibility.
Possible Explanations
It is possible, if you flipped the light switch, that something else happened.
It could be, that at the moment your hand touched the switch, you were abducted by magic aliens who connected your mind to an illusion machine that made you believe that the light turned on or off.
A Futile Resistance

This explanation violates common sense. It seems highly improbable. For Kurtnestetic incompleteness, we will consider such explanations unlikely at our current scale and existence. The magic aliens will be left in the care of our more mechanical readers, quantumly speaking
Situation as Circuit
Using this free download we sketch a circuit that represents our situation:

We have already committed several acts of abstraction, having:
·       replaced real world objects by symbols in a graph
·       chosen a voltage source  to represent the power company
·       chosen an LED to represent the light "bulb"
·       sized the components so they didn't blow up
The resistor is along for the ride. It represents inefficiency and injustice in the system,  such as "wires aren't perfect conductors" and poverty. We could have a separate resistor for each of the three original wires, but each time we add a resistor we must add a wire. This tendency of things to become more complex before they get simpler is called, "intermediate expression swell". Just how bloated things get is an interesting problem we will sidestep for now.  Pushing all three resistors through the circuit and placing them side by side allows us to replace them all by a single resistor. All the losses are then treated as single equivalent loss, adding another act of abstraction to our efforts!
In doing so we invoked the rule:
"Resistors in Series Add Linearly"

Requivalent = R1 + R2 … + RN
Having transformed our little world into an "equivalent" circuit, we must define what "working" means. "Working" means Proven, Demonstrated, QED.  We define "working" to mean that current is flowing around the loop in sufficient quantity and with sufficient potential to turn on the light. This is something we can measure in both worlds, simulated and real. We can measure voltage, we can measure current and we can measure whether the light is on or off. The single measurement of whether the light is on, abstracts away the need for two measurements, voltage and current. Aside: I always measure the voltage of household batteries before and after installation. It is incredibly informative. Measurement of current requires a meter alias ammeter to be placed in series with other circuit elements. Current flow is measured in units of Coulombs per second, or Amperes, much as water flow is measured in liters per second. It is represented by an arrow, labeled here "Meter de Courant" in a twisted French homage to the German American mathematician Richard Courant.
When the Hardware meets the Footwear
Two pictures conclude the example. One picture with the switch OFF, one with the switch ON. QED
OFF:

ON:

The astute reader will notice that the current is actually flowing more voluminously in one direction than the other. This happens too fast for us to see, so we think that the light is on, when it is actually pulsating. Because the light is an LED, it only shines when conducting current in the forward arrow direction. The back-flow happens because real diodes are naughty. They leak. Current flow is taken as positive when traveling from positive pole to negative pole of the source. The squiggly "current-limiting" resistor is sized to keep the LED from burning up like a comet and destroying our pretty little world in one puff of smoke, also known as the smoke test of a proof. The tiny fence on the arrow of the diode implies that current is not supposed to flow backwards even though it does. The act of proof, the light turning on when the switch is thrown, isn't affected by these details. They do however suggest deeper and more interesting issues are afoot.
Acknowledgements
This work is dedicated to parents, professors and friends that inspired it.
Illustrations are linked to their respective sources.

© 2012 · Warren Design Vision

Tuesday, January 17, 2012

An Unexpected Circuit





Introduction
I am going to write a short paper. It's going to be a fun paper because like you, I don't know how it is going to turn out. That should make it interesting for both of us. Today's topic is a little weird -  it arose in a rather offhanded way. I wanted to write about it because it was like stumbling on buried treasure. I am going to write in the first person because it is easier for me to express myself that way.
The stupefying beauty of this is that if I don't succeed, it is incredibly possible that you may. If I happen to succeed, we both get a useful tool.

Background
The problem is this. I need 50 Volts of Direct Current in a lightweight and portable package. 50 VDC, not 6, 9, 12 or 24. It is okay if I have to use an outlet or extension cord but I need 50 VDC. One more thing - I need 600 Watts of it. Because power is voltage times current there will be 12 Amperes flowing through a wire somewhere. Oh and one last thing -  I need this 50VDC with 600 Watts of power constantly available on the shortest of notice, say 1/20,000th of a second and also in a sustained manner.
Please don't hang up when you read the following statement. Stay with me, it will be worth your while.
An electronic circuit is a mathematical proof.
A circuit is a proof. It is a proof in an ideal sense with idealized components. It is a proof in a real sense with real-world components. If a circuit works, then the system that it represents is true. Many mathematical and mechanical systems have equivalent circuits. We will revisit this powerful idea.

Possible Ingredients
Lead-Acid
50 VDC is a weird number to want. I could use four 12 Volt lead-acid batteries, settling out of court for 48 Volts, knowing full well Lead-acid batteries are not 12 Volts they are 12.63 Volts. I would settle for 50.52 VDC. Lead-acid batteries have two problems though, lead and acid. The first problem, Lead, is toxic, and more seriously, it is heavy. I don't like heavy things. I don't like lugging them around. The second problem, Acid, is also toxic, and more seriously, it burns stuff. I don't like burns and that yucky corrosion that forms on car batteries. So let's just drop lead-acid.
Lithium
I could use thirteen 3.7 Volt lithium-ion polymer batteries, settling for 48.1 Volts. Lithium batteries have two problems, cost and explosion. I don't like things that are too expensive for widespread distribution. Also they explode if they aren't charged carefully. I can handle a small battery exploding. That might even be fun. A battery with nearly a horsepower is not small and neither is its explosion. So strike lithium.
Step Down Transformer
I could use a 120 VAC step-down transformer to transform household current to the lower AC value and then rectify and filter that into 50 VDC.
Two problems emerge. Even ordinary 120 VAC step-down transformers are expensive and they are heavy. I already mentioned my dismay with lugging expensive stuff around. The astute reader will note that this is a lie. I mentioned my dismay with lugging heavy things around and my dismay with things that cost too much, but I did not mention my dismay with lugging expensive stuff around. In that subtle distinction, there is meaning. You might think I don't like lugging expensive stuff around because of theft, and that would be true, but that was not the point. The point was, I never said that, but if one wasn't careful, one might assume I said it, and leave the encounter thinking something was said that wasn't. The structure of this argument is similar to a circuit we will discuss in a moment.
Now since I have ruled out batteries or transformers I need what is called a switching power supply. Switching power supplies are cheap and abundant, but they have a problem that intimately affects their use. They create NOISE. Electrical noise. Electrical noise bothers me more than weight or cost.

MOSFET Modulation: Smooth, Quick, Efficient
What I would like to do is somehow sample 120 VAC in a smooth, quick, and efficient way. Then I can rectify it into 50 VDC and filter it according to standard practice. So now, we have an apparently simpler problem than 600 Watts of 50 VDC. I just need 600 Watts of 50 VAC. Ignore that because of efficiency more than 600 Watts is needed. Ignore that because of voltage regulation, a more than 50 VAC is needed. Settle for 600 Watts of 50 VAC. If it is made from 120 VAC smoothly, quickly and efficiently the rest is cake.
What if instead of brutal switching, which creates far-reaching wideband racket, we gently turn something on and turn something off in a smooth and efficient way?
This circuit does that… partially. The control gate of an N-Channel MOSFET is fed with a version
of the same signal we are trying to clamp to 50 VAC. I say, "clamp" because when the voltage goes over 50 VAC we don't want any part of it. We especially don't want to accept this higher voltage and in turn dissipate the excess energy as noise or heat.


We can exactly tailor how much of the positive going side of the 120 VAC makes it to the voltage probe by adjusting the values of R1 and R2. If they are equal, we get 50 VAC on the positive going side of the wave:


So just like that we are halfway done. The signal is about 50 VAC on the top. In the figure above, both the 120 VAC signal and the output signal are drawn.
We would like to do the same thing on the bottom, so let's start simple and build a circuit that just does the opposite of the first one. Maybe then, we can combine them to get what we want. A circuit might do the "opposite" is one that uses a P-Channel MOSFET, the "opposite" of an N-Channel MOSFET:



After trying some different configurations we run it and get what we want –the negative side of the 50 VAC is present:


Now perhaps we can combine the two that will clamp both sides of the waveform to 50 VAC.


Running the simulation, we obtain:


We have achieved our objective. A real circuit might have some additional parts for protection, but this shows that the configuration is valid.

What I did not show you was the search process that a reasonable person might have employed to come up with this configuration.

If you look closely at the schematics, you will notice that MOSFETS are not commutative.
With the gate in the middle, they can be put in forwards or backwards.

This gives rise to four possible circuits, since there are two MOSFETS in use, and only one circuit topology will produce ("prove") the correct waveform.

In addition, the MOSFETS need not live on the positive supply, they could also be placed on the bottom of the load, but because of symmetry, this would still prove the correct waveform:

So now, we have eight possible circuits of which two are equivalent and correct and six are incorrect.
Additionally we can swing one MOSFET around to be on top of the load and one on the bottom:


Which produces the following output:


Swinging the P MOSFET around instead of the N MOSFET produces a similar incorrect outcome. That makes 2 of 10 possible configurations correct.
We can increase that by 4 more configurations by pivoting each MOSFET in the swung around configurations, which also produce incorrect outcomes.
If I have counted correctly, 2 out of 14 configurations are correct. But now we are not doing circuit design. We are searching over a space of possible connection topologies for a topology that proves (produces) the waveform we sought. Each of the topologies proves something, but only two proved what we set out to prove.

Conclusion
We have succeeded! It was discovered that we can produce (prove) the desired waveform and discovered two topologies that were satisfactory. The circuits we have produced are equivalent to other systems that have similar algebraic or mechanical characteristics. These equivalent circuits and their topologies not only model the equivalent algebraic and mechanical forms, they model the search process we might employ to discover useful circuits along with its combinatorial growth.
Easter Egg
I mentioned above that "protective circuitry" was needed to take this synthetic design into a practical unit. It turns out that the MOSFET gates need their voltage clamped to around +/- 10 volts. So the  working design looks like this. Twelve parts drawn from 5 types, not counting power cord, fuse and load. An ounce of material you can hide in your hand. Two MOSFETS and power diodes in the top section, all in T-220 cases on a heat sink to handle 12 amps. The “Logic” section on bottom, runs on 6 milliamps that turns on the MOSFETS in 7 microseconds. 576 Watts. $9.15 worth of parts, the front-end of a $600` power supply. Those savvy in the trade will notice that this is a smoother version of an H-Bridge circuit used to control motors, so they don't jerk as much when doing, "the robot".



The file with the component values is available for $9.95 if you send me an email at the address on the left. It uses TINA SPICE from TI.




Acknowledgements
Brian Beckman, private communication.

References
As hyperlinks throughout the text.

Wednesday, November 16, 2011

Scaling Laws for Fractal Antennas



I was doing some simulations of fractal antennas recently and a friend said, "I'm talking about the postage sized antenna for 160 meters."




The statement intrigued me for several reasons:
1) Perhaps fractal antennas scale differently because of fractal dimension?
2) How small would could an antenna for 160 meters (1.9 Mhz) REALLY be?
3) How does fractal dimension affect the performance of the antenna?


Analysis Tools


The questions were answered via extensive analysis. Analysis was performed using 4NEC2 an excellent adaption by Arie Voors of the Numerical Electromagnetics Code by J, Burke and A. Poggio. These links will open in a new window if you would like to check them out. Arie Voors has made his tool freely available to the technical community. The Minkowski Antenna configuration used in this study is described here by Camps-Raga and Islam at the University of Missouri, Columbia. The 'C' program minkowski.c, the bash script, doit.bash, and the parameter file, tail.txt used to generate the antenna examples are included at the bottom of this technical note.


Simulation Results


1) A fractal antenna of a given configuration and dimension scales
    linearly in wavelength just like all antennas do.
2) A Minkowski fractal antenna for 160 meters would be 36 feet wide.
    It would have a gain of -19.3 dB relative to an isotropic radiator.

3) Increasing fractal dimension decreases antenna size with
    gain dropping faster than size.


Discussion


1) A fourfold reduction in antenna size is accompanied by a gain reduction of 21.3 dB so there appears to be is a severe penalty for size reduction. My current hypothesis is that as fractal dimension increases, the antenna starts to look more like a mirror than an absorber of electromagnetic energy.
2) A level 0 Minkowski fractal is a square loop antenna! The makes a nice basis for comparison.




Analysis Details




















'C' Code Used to Generate the Minkowski Fractal Antennas


The 'C' code was written entirely by the author using the principle of segmenting a single line and offsetting the middle segment by a distance h. The code was compiled using the cygwin cc compiler from the fantastic and free cygwin running on top of Windows XP on a dual core Intel processor and ASUS motherboard from newegg.com. If you have never had the pleasure of building your own computer from off the shelf components I urge you to do so. You will save a ton of money and get a computer more suited to your needs. Anyway, here is the 'C' code:


------- cut here -------
// Minkowski fractal antenna generator by van at wdv dot com

#include
#define SOUTH 1
#define EAST 2
#define NORTH 3
#define WEST 4
#define MAX(a,b) ((a)>(b)?a:b)


int maxLevel = 1;


void edge(double xA, double yA, double xF, double yF, int type, int level)
{
    double W = 1.0 / 3.0;
    double H = 1.0 / 3.2;
    double L, w, h;
    double xB, yB;
    double xC, yC;
    double xD, yD;
    double xE, yE;


    if(level >= maxLevel)
    {
        printf("1\t0\t%9.4f\t%9.4f\t0\t%9.4f\t%9.4f\t1.e-4\n",
            xA, yA + 1, xF, yF + 1);
    }
    else
    {
        if(type == SOUTH)
        {
            L = xF - xA; w = L * W; h = L * H;


            xB = xA + w; yB = yA + 0;
            xC = xA + w; yC = yA + h;
            xD = xF - w; yD = yA + h;
            xE = xF - w; yE = yA + 0;


            edge(xA, yA, xB, yB, SOUTH, level + 1);
            edge(xB, yB, xC, yC,  WEST, level + 1);
            edge(xC, yC, xD, yD, SOUTH, level + 1);
            edge(xD, yD, xE, yE,  EAST, level + 1);
            edge(xE, yE, xF, yF, SOUTH, level + 1);
        }
        else if(type == EAST)
        {
            L = yF - yA; w = L * W; h = L * H;


            xB = xA + 0; yB = yA + w;
            xC = xA - h; yC = yA + w;
            xD = xA - h; yD = yF - w;
            xE = xA + 0; yE = yF - w;


            edge(xA, yA, xB, yB,  EAST, level + 1);
            edge(xB, yB, xC, yC, NORTH, level + 1);
            edge(xC, yC, xD, yD,  EAST, level + 1);
            edge(xD, yD, xE, yE, SOUTH, level + 1);
            edge(xE, yE, xF, yF,  EAST, level + 1);
        }
        else if(type == NORTH)
        {
            L = xA - xF; w = L * W; h = L * H;

            xB = xA - w; yB = yA + 0;
            xC = xA - w; yC = yA - h;
            xD = xF + w; yD = yA - h;
            xE = xF + w; yE = yA + 0;

            edge(xA, yA, xB, yB, NORTH, level + 1);
            edge(xB, yB, xC, yC,  EAST, level + 1);
            edge(xC, yC, xD, yD, NORTH, level + 1);
            edge(xD, yD, xE, yE,  WEST, level + 1);
            edge(xE, yE, xF, yF, NORTH, level + 1);
        }
        else if(type == WEST)
        {
            L = yA - yF; w = L * W; h = L * H;

            xB = xA - 0; yB = yA - w;
            xC = xA + h; yC = yA - w;
            xD = xA + h; yD = yF + w;
            xE = xA - 0; yE = yF + w;

            edge(xA, yA, xB, yB,  WEST, level + 1);
            edge(xB, yB, xC, yC, SOUTH, level + 1);
            edge(xC, yC, xD, yD,  WEST, level + 1);
            edge(xD, yD, xE, yE, NORTH, level + 1);
            edge(xE, yE, xF, yF,  WEST, level + 1);
        }
    }
}

main(int argc, char **argv)
{
    if(argc > 1) maxLevel = atoi(argv[1]);

    edge( 0,  0, 16,  0, SOUTH,  0);
    edge(16,  0, 16, 16,  EAST,  0);
    edge(16, 16,  0, 16, NORTH,  0);
    edge( 0, 16,  0,  0,  WEST,  0);
}




Bash Script Used to Generate the Minkowski Fractal Antennas


The 'C' program above, though somewhat minimal, produces extra copies of the segments during the recursion. The output lines are only part of the "card entry" fragments necessary for 4NEC2. To get the output file into a form usable by 4NEC2 the following script was run:


$doit.bash 2


which produces a level 2 Minkowski fractal antenna.


------- cut here --------------


#!/bin/bash
minkowski.exe $1 | sort -u | nl | sed -e 's/ //g' | sed -e 's/^/GW\t/' > head.txt
cat head.txt | wc -l > /tmp/tmp.txt
lineCount=`cat /tmp/tmp.txt`
echo $lineCount
sedCommand="s/NSEG/$lineCount/"
echo $sedCommand
cat tail.txt | sed -e "$sedCommand" > foo.txt
cat head.txt foo.txt > MI3ALVW.nec
u2d MI3ALVW.nec


~                       

The Last File


The last file "tail.txt" is used by the bash script to provide analysis parameters for 4NEC2. It looks like this:


------- cut here ----------


GE  0
EK
LD  5   0   0   0   5.74713e7   0
EX  6   NSEG    1   0   1   0
GN  2   0   0   0   13  0.005
FR  0   1   0   0   1.8 0


Addendum:
"Chip" W1YW owns US patents 6452553 and 7256751 on fractal antennas. He has measured the performance of a configuration similar to the one pictured at 175 MHz and does not report the dip in gain that appears in the 1.9 MHz version above. He states and I quote:


"For example,the MI2 (second iteration)  modeled in NEC4, reveals a 97% efficiency and dipole equivalent gain. Recently an open house with members of the Radio Club of America showed this to: K1VR; WB2MGP; K1BG; WA6RNU; W0BIW; KD0FAA; and several others. In addition, the visitors were treated to actual chamber measurements of a wire-bent MI2 at 175 MHz, Its gain was indisitinguishable (within 0.2dB) from an ETS calibrated dipole of 1.7 dBi. The fractal antenna is thus unity gain to a dipole."


Thus W1YW does not observe the same drop in gain that occur in my simulations. Work is proceeding to rectify this discrepancy.


Sunday, July 31, 2011

Testing a cool posting style excerpted from Matt Might



In his excellent blog on the Y-combinator, Matt Might - a professor at my alma mater, the University of Utah - uses a technique for placing executable Javascript code in the flow of his document.
Right now I am pasting his code into the html editor of my Google blogger to see if I can reproduce the trick he uses. The part that follows is in double quotes, as it is Matt's work:


Open Double Quote


The following example expresses the factorial function without using recursion:
[result1]


Take a close look at the definition of Y. It uses only three kinds of expression: anonymous functions, variable reference and function application.

Close Double Quote


Back to my words: Note that even though this is a blog, the html is still functional and the Javascript program executes when the "Evaluate" button is pressed. So handy for making those subtle programming points!


If you right click this page and choose, "View Source", You can see the embedding of the code between lines 456 and 524. A short preamble and "postamble" are all that are required. Thanks Matt!


Footnotes:
Attempts to paste commented html tags were futile as they were evaluated. Attempts to color the code red didn't work either.

Wednesday, July 20, 2011

Regarding "Informational Derivation of Quantum Theory" by Chiribella, et.al.



Regarding "Informational derivation of quantum theory", "PHYSICAL REVIEW A 84, 012311 (2011)", Chiribella

I was provoked to cast Information Compression as an Iterated Function

So given a string S, of length L, find an iterated function F, that produces a new string S’ of length L’ where L’ < L.
One might also require an iterated function G = F-1 that takes S’ and produces S.
If such a G exists, then F would be called a lossless or invertible iterated compression function.


S = "The rain in Spain stays mainly in the plain."
L = 45

F1 = { s/ain/1/g }

S1 = "The r1 in Sp1 stays m1ly in the pl1."
L1 = 37

F2 = { s/he/2/g }

S2 = "T2 r1 in Sp1 stays m1ly in t2 pl1."
L2 = 35

F()  = F1(F2())
S' = F(S)
L' < L since 35 < 45

G1 = { s/1/ain/g }

G2 = { s/2/he/g }

G = G1(G2())
S = G(S')

F is invertible, iterated and compresses.

Sidebar 1: F can be packaged with S:

Sp = F + S = /ain/1/he/2/"The rain in Spain stays mainly in the plain."

Next Step: Find an Iterated Function that performs Information Expansion

So given a string S, of length L, find an iterated function F, that produces a new string S’ of length L’ where L’ > L.
One might also require an iterated function G = F-1 that takes S’ and produces S.
If such a G exists, then F would be called a lossless or invertible iterated expansion function.

S = "The rain in Spain stays mainly in the plain."
L = 45

F = { s/[a-zA-Z]/[%3d]/ }

S1 = "084he rain in Spain stays mainly in the plain."
L1 = 47

S2 = "084104e rain in Spain stays mainly in the plain.
L2 = 49

S' = "0841041010321140971051100321051100320831120971051100
     3211511609712111503210909710511010812103210511003211
     6104101032112108097105110046010"

L' > L since 135 > 45

G = { s/[%3d]/[a-zA-Z]/ }
S = G(S')

F is invertible, iterated and expands.

Sidebar 1: F can be packaged with S:

Sp = F + S = /[a-zA-Z]/[%3d]/"The rain in Spain stays mainly in the plain."

In this context we call F, the "transcription apparatus".


Next Step: Show that the cost of mutagenesis is higher in the compressed case.


This is trivial and will be left as an exercise to the reader.

Source for F in Expansion Section:

#include

/* convert any number to itself and any letter to a number */
/* hint add a comma to each phrase and watch intronic explosion */
/* hint remove the commas and watch loss of reading frame */
/* hint add triplets and watch need for reading frame */

int isNumber(int c)
{
    return ( ('0' <= c) && (c <= '9') );
}

void echo(int c)
{
    printf("%c", c);
}

void number(int c)
{
    printf("%03d", c);
}

main()
{
    int i;
    int c;

    for(i = 0; (c = getchar()) != EOF; i++ )
    {
        if( isNumber(c) )
        {
            echo(c);
        }
        else
        {
            number(c);
            break;
        }
    }

    for(; (c = getchar()) != EOF;)
    {
            echo(c);
    }
}

Wednesday, June 08, 2011

The Impedance of Free Space



The impedance of free space is ~120π, or about 377 Ohms.

  1. What does that mean?
  2. Does nature oppose the propagation of light? 
  3. If it does, would we even see star light?
  4. Or is this a fee that, once paid, admits to a photon the right to propagate until it collides with something else?



It turns out that the "impedance" of free space is really just a ratio of strengths.


It is the ratio of the electric field strength, to the magnetic field strength.


Its numerical values are just an artifact of the definition of the ampere and the meter.

It might be interesting to work backwards and say that the impedance of free space is one and see how that could lead to a useful set of units for Maxwell's equations.