Made a little voltage regulator circuit

•July 11, 2009 • Leave a Comment

Among the things which came in the “value pack” of linear circuit ICs from Futurlec are some voltage regulators. While trying to figure out what to do with them, I came across this site:

How Electronic Gates Work.

Along the way to getting you started with TTL gates, it shows how to use a voltage regulator to get a +5V supply from something else, like a 15V supply.

Digging around in the data sheets for the L7805CV voltage regulator, I found similar circuits though with MUCH lower values for the capacitors. Apparently the particular value used isn’t all that critical. The data sheets gave very low values, but also said that those should be solid tantalum capacitors, and if aluminum electrolytic capacitors were used, the values should be increased by at least 10x.

Anyway, here’s my little circuit:
voltage_regulator_circuit

And here’s a shot of the oscilloscope showing 5v coming out. I’m powering the circuit with a 15v DC wall wart transformer I had lying around.
5volts
(a little out of focus, oh well.)

In the process of this I seem to have busted my voltmeter. I think it happened when I tried to measure the output voltage of the transformer (15 v, according to the scope, and what it says on the transformer itself.) I’m not sure why that would have smoked it, but it no longer measures voltage, and the ohm-meter is busted too, it seems to think it’s always shorted, which sucks because the continuity tester function is pretty useful. Hoping I just blew a fuse, but it seems odd that a 15V 1-amp max would blow the thing., or that while measuring 15v, that the thing would even draw any appreciable current at all. Oh well, it doesn’t seem to work anymore.

I also have 12V and 6V and 15V regulators, so I could make similar circuits with those, add some toggle switches and LED indicators and make a little DC power supply that does 5, 6, 12, and 15v.

PZ’s latest response to Mooney and Kirshenbaum’s “Unscientific America”

•July 10, 2009 • Leave a Comment

Jun 9, 2009. You’ve got to read PZ’s latest response to Mooney and Kirshenbaum’s new book, “Unscientific America.”

Unscientific America and those awful atheists

Bravo, PZ, Bravo!
.
orson clapping

First circuit

•July 10, 2009 • Leave a Comment

Thursday, Jul 9, 2009. Since I received my big box’o'lectronic components yesterday, I figured I may as well dive right in and start messing around. I figured I’d start simple with some LEDs. But it’s been so long since I’ve done any of this stuff, I’m not sure I remember much. I do remember Ohm’s law though. There are several things you need to know about LEDs, but the two most important are that 1) you can’t just hook them up to a battery, they need a resistor in series with them in order not to fry themselves, and two, they only go in the circuit one way — the two leads are not equivalent.

To figure out what kind of resistor you need, you need to know how much current the LED can take, or what the voltage drop across the LED is. From there, you can figure things out with Ohm’s law:

              V = IR

where V is voltage, I is current (in amperes) and R is resistance, in ohms.

Well, the first problem is the bag of LEDs I picked isn’t labeled very clearly. I picked some cheap red ones for my initial experimentation in case things went wrong and I burned it up. On this bag, it looks like it says, “SAM 3-” Huh? Maybe the S is really a 5, and the AM? milliamps? The “3-” might be the 3 volt voltage drop across the LED?

So, I figured to get 5mA at 3 volts, I = 0.005, V = 3, plugging that in to V=IR and solving for R gives you 3/0.005 = 600 ohms.

I doubled it just for safety to 1.2Kohms. (after all, I’m not remotely sure I’m interpreting that “SAM” as 5mA correctly! Nor sure if I can take that 3 volt drop across the LED and then stuff it through ohm’s law and sort of treat it as the internal resistance of the LED to get a kind of limit on the current.)

The next problem is, which way does the LED go? Googling around I find that the long lead is the positive lead.

Now a power supply. 4 AA batteries in a battery holder in series at 1.5 V each gets me 6V. 6.3V, actually, according to my ohm-meter.

So, I wire up the 1.2Kohm resister in series with the LED — check the polarity — and apply the 6.3 V.
Hey, it works:

first_circuit
My first circuit in a long long time.

I checked the voltage across the resistor, and it’s about 4 V, and across the LED about 2 volts (Hey, oh yeah, Kirchhoff’s law: 2 + 4 = 6 volts of the battery. Starting to come back to me a little bit.)

So, that means, with my doubling the 600 to 1200, that means it makes sense that 1/3rd of the voltage is across the LED and 2/3rds across the resistor. So I probably have a load of 1200 + 600 = 1800ohms,, and current of about 6/1800 = 3.3mA.

Hmm, let me try another LED. One of the expensive white ones this time. The bag these came in seems to be labeled “LoD 5W” Hmm. 5 Watts? That can’t be right, can it? Then I remember I think they are 5mm across, and white — that’s probably what the 5W means. So, no electrical hints there. Well, let’s just hook it up and see what happens.

second_circuit

Hey, it didn’t blow up. And it’s bright. I measured the voltage across the resistor and LED again, and it was about 2.7 V across the LED and about 3.5 across the resistor, so the internal resistance of the white LED is a little higher. Let’s see across the resistor was 3.5, so that means the current was 2.91mA, so the internal resistance of the LED should be 2.7/0.00291 = around 928 ohms — if it makes sense to talke about the resistance of an LED as a constant like that — maybe it varies with current, I don’t know.

Anyway, success so far, however tiny.

Setting up a little electronics workbench

•July 9, 2009 • 2 Comments

Since I graduated from college with CS degree with a minor in EE, I haven’t done much in the way of using that EE minor. It’s been all software, albeit software fairly close to the hardware, but still software.

I was thinking back to some of the lab courses I took, and I got it into my head that maybe I should put together a little electronics work bench and mess around making some stuff.

I ended up picking up a working Tektronix 465b oscilloscope off ebay for 80 bucks.

tektronix_465b

Then I followed some advice I googled up here from somebody called mpayson who recommended buying a bunch of stuff from futurlec. So I bought a bunch of stuff from them:

If you google up futurlec on the internet, you’ll see they are in Thailand, and they’re really inexpensive, but they also have a deserved reputation for slow shipping. My order took almost a month to get here, so don’t order from them if you need it tomorrow. If you don’t need it tomorrow, I had no trouble with them at all, and everything went smoothly. It just takes awhile, expect that going in, and you probably won’t be disappointed.

bunch_of_electronic_stuff

I bought a bunch of variety packs of resistors, capacitors, diodes, LEDs, linear ICs, IC sockets, and transistors. I also got some solder, some proto boards, and a couple of breadboards, some 100k, 10k, 5k and 1k pots, some knobs, some toggle switches, and some battery holders.

Here are some pics of the variety packs:

futurlec_transistor_pack

Transistor pack

futurlec_resistor_pack_2

Resistor pack (not shown, there’s another one like it, but 1/2 watt vs. 1/4 watt.)

futurlec_ceramic_capacitors_pack

futurlec_electrolytic_cap_pack

futurlec_mylar_cap_pack

futurlec_multilayer_ceramic_cap_pack

Various capacitor packs

futurlec_led_pack

LED pack

futurlec_ic_socket_pack

IC socket pack (they are jammed into pieces of foam, some have sockets on both sides of the foam so there are actually more there than it looks like.)

futurlec_linear_ic_pack

Linear IC pack. This one is probably the most interesting of the variety packs. I haven’t really looked to see what they gave me, though I did see at least one 555 timer chip, and I think a 556 dual timer chip, and what look to be some pretty hefty transistors. Edit: On googling a bit, and looking at some data sheets, the “hefty transistors” were actually negative voltage regulators — they gave me lots of 5, 12, and 15 volt voltage regulators, and a few positive v. regulators. Also, some timers, as noted before, and some voltage comparators, and a bunch of op-amps.

One think Futurlec doesn’t seem to have is a variety pack of TTL gates. That’s ok though because a) I still have a bunch left over from college, and b) they typically require a 5V power supply which is hard to get from batteries (though there may be some CMOS versions of TTL stuff that can work at different voltages, I don’t know, but then it’s probably not really “TTL”.)

ttl_misc

TTL ICs from my college days.

Also, I got a digital multimeter:

radioshack_multimeter

And a soldering iron. So, I’m all set to build, umm, blinky light thingies, or maybe a weird sound generator..

Since some one asked, here are the order details:

Qty    ItemNumber  Unit Price  Total Price
----------------------------------------------------------
1         RES14WPACK    1/4W Resistor Value Pack                2.45          2.45
1         RES12WPACK    1/2W Resistor Value Pack                4.95          4.95
1         CERPACK       Ceramic Capacitor Pack                  2.95          2.95
1         ELEPACK       Electrolytic Capacitor Value Pack       3.95          3.95
1         MYLARPACK     Mylar Capacitor Pack                    3.95          3.95
1         MULTIPACK     Multilayer Ceramic Capacitor Pack       3.95          3.95
1         LEDPACK       Led Value Pack                          4.95          4.95
1         TRAPACK       Transistor Value Pack                   4.95          4.95
1         LINEARPACK    Linear IC Value Pack                    5.95          5.95
1         DIOPACK       Diode Value Pack                        2.95          2.95
1         ICSPACK       IC Socket Value Pack                    5.95          5.95
5         PROTO777      Prototyping Board - 777                 1.50          7.5
3         PRBRDLG       Prototyping Board - Large               2.95          8.85
4         POT1K         1K Linear Taper Pot                     0.55          2.2
4         POT5K         5K Linear Taper Pot                     0.55          2.2
4         POT10K        10K Linear Taper Pot                    0.55          2.2
4         POT100K       100K Linear Taper Pot                   0.55          2.2
16        KNOB4         Black Aluminium with Pointer - Small    0.90          14.4
10        SPST10ST      SPST on-off Standard Toggle Switch      1.15          11.5
4         CD4017        CD4017 - Decade Counter/Divider         0.30          1.2
3         CD40106       CD40106 - Hex Inverter Schmitt Trigger  0.35          1.05
30        LED5W         White 5mm Round LED                     0.68          20.4
1         JUMPERKIT     Breadboard Jumper Kit                   4.90          4.9
2         BREADBRD      Breadboard                              5.90          11.8
3         2XAAHOLDERB   2 x AA Battery Holder                   0.30          0.9
2         4XAAHOLDERB   4 x AA Battery Holder                   0.50          1
2         6XAAHOLDER    6 x AA Battery Holder                   0.55          1.1
1         4XDHOLDER     4 x D Battery Holder                    1.10          1.1
10        9VBATTCLIP    9V Battery Clip                         0.10          1
1         SOLDERPEN     Solder Pen                              0.95          0.95
----------------------------------------------------------
Sub-Total                             143.40
Postage                               14.00
Total                                 157.40

(Actually there was an additional $31.00 to ship via FedEX,
so the total came to 188.40.)

Sylvia, you ignorant slut

•July 7, 2009 • 2 Comments

Via Bad Astronomy, indirectly, via The Lippard blog indirectly, via The mighty Pharyngula… (Jeebus these citation chains are a bit ridiculous. Isn’t there some way that lazyweb can do this for us?):

Here’s the money quote:

The earth’s been here 6000 years — and I know, I’m going on and on and on — it’s been here 6000 years, long before anybody had environmental laws, and somehow it hasn’t been done away with…

Arizona State Senator Sylvia Allen, you ignorant slut.

Well, my own state of Texas appears to be on the verge of replacing Head Moron of the Texas School Board Don McLeroy with uber-stupid ignorant slut Cynthia Noland Dunbar, who thinks that public schools are unconstitutional. That’s right, it seems that Texas moron-in-charge Gov. Rick Perry is considering Cynthia Dunbar, who thinks that public schools are unconstitutional and that Amurcuh is a Krischun Nashun for the position of chairman of the state board of (re)edyookashun. She’s written a book, One Nation Under God, Read the reviews on amazon. These people on the State Board of Education of Texas, influencing the textbooks that are used throughout the nation, HOMESCHOOL THEIR KIDS. This goes beyond stupidity. This goes staright into the territory known as evil. These people are actively trying to hurt your kids.

Cynthia Noland Dunbar wants to hurt your kids by depriving them of a decent education. Fuck that bitch up.

Fuck these seditious idiots.

Edit: Oh, and while we’re at it, let’s googlebomb the bitch with the phrase “cynthia dumbass dunbar” Cynthia Dumbass Dunbar, graduate of Pat Robertson’s Regent University School of Law (Ha! as if that were a real school.)

Edit: The nut bar runs deeply nutty with this one. According to the Houston Chronicle “In a column posted on the Christian Worldview Network Web site, Dunbar wrote that a terrorist attack on America during the first six months of an Obama administration “will be a planned effort by those with whom Obama truly sympathizes to take down the America that is threat to tyranny.” When asked to retract this ridiculousness, Nutbar’s response was “Those are my personal opinions and I don’t think the language is questionable.”

Cynthia, your mental health is questionable you fucking insane bitch. I’m starting to wonder if maybe she’s a clone of Michelle Bachmann.

Edit: Were I better at this whole blogging thing, I might have written something like this: Sub-subminimal by slactivist (via (where else) the mighty Pharyngula.)

Karen Armstrong’s “The Case For God”

•July 5, 2009 • 1 Comment

Simon Blackburn has reviewed Karen Armstrong’s book, “The Case For God” in the Guardian. The only reason I’m writing this post is to call your attention to a succinct little burn:

So Dawkins, Dennett, Hitchens and Harris have chosen a straw man as a target. Real religion is serenely immune to their discovery that it is silly to talk of a divine architect.

So what should the religious adept actually say by way of expressing his or her faith? Nothing. This is the “apophatic” tradition, in which nothing about God can be put into words. Armstrong firmly recommends silence, having written at least 15 books on the topic.

Oh, snap!

Well, I’ve read Karen Armstrong’s “History of God,” and actually it was pretty good, so don’t take this post of mine as any kind of slam against her. So far as I can tell, she actually mostly has her head screwed on straight. Mostly. (That’s the only book of hers I’ve read, so some screws may have loosened since then, I suppose.)

But, that was a pretty damn good burn, Mr. Blackburn, pretty damn good.

Probably just some random mutation…

•July 4, 2009 • 1 Comment

An interesting way to find the size of a structure in C

•July 2, 2009 • Leave a Comment

So today I ran into the problem that I needed to know the size of a structure. Well, ordinarily, you might just do something like this,

        printf("sizeof mystruct = %d\n", sizeof(struct mystruct));

and be done with it.

But, in this particular case the code was in a kernel driver, and I knew the size of the structure was incorrect (as there was some some magic macros watching my back. I knew that the consequence of this being wrong was that the kernel would panic because the structure needed to be padded to be a multiple of a certain size because that’s the only way some hardware that uses it likes it. But how much to pad it? To know that, I needed to know its current size, which I currently didn’t know. Adding the equivalent of the above printf and executing it was out of the question if the kernel panic was to be avoided. I could manually calculate the size of the structure, but it wasn’t trivial or obvious how to do so. Doing so would mean laboriously examining lots of headers, counting up fields, etc. Not fun, and error prone.

I could write some little program that included just the right headers and whatnot with all the right compiler flags, but figuring all that out would be pretty time consuming.

Or, I could do what I did, which was to came up with another, simpler, method. I added some code like this into the driver code:

        printk(KERN_WARNING "%d %d %d\n",
                0x1234abcd, sizeof(struct mystruct), 0xfedc4321);

Note the very obviously made up but recognizable constants.

I compiled the code, but I did not execute it, didn’t load the module, since if I had, it would have panicked the system, which I wanted to avoid. Instead, I just disassembled the resulting object code (with objdump -d) and got something like this:

 1b:   8d 4c 24 04             lea    0x4(%esp),%ecx
  1f:   83 e4 f0                and    $0xfffffff0,%esp
  22:   ff 71 fc                pushl  -0x4(%ecx)
  25:   55                      push   %ebp
  26:   89 e5                   mov    %esp,%ebp
  28:   51                      push   %ecx
  29:   83 ec 24                sub    $0x24,%esp
  2c:   c7 44 24 0c 21 43 dc    movl   $0xfedc4321,0xc(%esp)
  33:   fe
  34:   c7 44 24 08 70 02 00    movl   $0x270,0x8(%esp)
  3b:   00
  3c:   c7 44 24 04 cd ab 34    movl   $0x1234abcd,0x4(%esp)
  43:   12

Now you can see my obvious constants in there (and search for them, as the complete disassembled driver code was a lot bigger than what you see above). So there are 0xfedc4321 and 0×1234abcd, and right between them is 0×270. And that is the size of my structure, 0×270, and found without executing the code, or making any special program, or manually figuring the structure size.

(Note, the above dump is just a similar example from a user space program, not the actual dump from the kernel code.)

There is probably a simpler way to do this (which I’d be interested to find out, so if you know, leave a comment) but this worked, and quickly and easily.

Maybe someone else will find it helpful in case there turns out not to be a better way.

Lot of shit going down in Iran right now…

•June 21, 2009 • Leave a Comment

If you’ve been paying attention at all, you know there’s a lot of shit going down in Iran right now. Since the digital transition on TV, I haven’t been watching much tv. The quality pretty much just sucks, so it’s not worth it. The cable companies have, I suspect deliberately given us a total failure of a digital broadcast standard, so, broadcast tv is basically dead now.

So, I get my news from “teh internets” these days, and oddly enough, one of the better news sources about the current goings on in Iran seems to be, of all places, fark.com. If yoiu know anything about fark, you know that “it’s not news, it’s fark.” You know that fark typically has all the weird “man bites dog” type stories, and you know that your local news cherry picks bits and pieces from fark and with a bit of film, makes a story.

But on this Iran thng, fark seems to have somehow transcended its usual jokey personality.

Some fark threads of interest:
On 9/11, we were all Americans. Tonight, we are all Iranians.” Iran Discussion thread XXXII “
Her name was Neda; she is the voice of the people, a call to freedom. Iran Discussion XXXIII

In what is probably the biggest blunder the Iranian government has made so far, a bystander, a beautiful young woman, probably in her early twenties*, was shot by a sniper and died in front of her father., and a camera. What the camera captured has made its way around the internet, and you have almost certainly seen it already. If not, be warned, it is hard to watch, and is apt to make you cry, and you won’t soon forget it. The woman’s name was “Neda,”

Another angle:

Pretty rough, to say the least.

They’re already calling her the “Iranian Tank Man“, after the guy that stood up to the tanks in Tiananmen square in the ’80s.

Interesting times in Iran, these days.

Edit: It is completely unintentional, and horrific, that this post immediately follows my “Where is Kafirgirl?” post. Hoping Kafirgirl is doing well, and has just decided not to blog anymore.

*Edit again: According to what’s floating around the internet, it seems that she was only 16 years old.

Eidt: I see youtube has already removed the 2nd video because they’re fucking bastards. Google’s “don’t be evil” motto doesn’t seem to extend to youtube, despite the fact that Google bought youtube.

Edit again: I see youtube has removed both videos. Search for “neda” and you’ll find it.

Where is Kafir Girl?

•June 11, 2009 • 4 Comments

Where is Kafir Girl?

No posts or comments from her since January 24, 2009.

A bit worrying.