Tuesday, November 1, 2011

A note about H-bridges

If you are a n00b like I was back in freshman year, or just forgetful (like I am now) you might want to take note before you burn out a bunch of transistors.

At some point you may realize you only need 2 inputs to control your h-bridge. You will tie the left hand inputs (base of Q1,Q3) together, and the right hand inputs (base of Q2, Q4) together.

Likely, burning transistors will at some point result, because the inputs will be left floating. For me, I accidentally pulled out the input wires.

"The important thing is you cannot leave any of the terminals AC and BD float. Let’s look at the AC terminal in more detail. Since A and C are tied together, and if it is left float then there will be a path for current through the collector of Q1, through its base, through the base of Q3, through its emitter to the ground. So, Q1 and Q3 are on resulting a short circuit. So, you must be careful if you are thinking about reducing the control pins by tying A with C and B with D. You just can’t leave the tied terminals open or float. They should be either grounded or pulled high."

Read more here: DC Motor Interfacing to PIC Micro. Scroll down to the "Important Note."

Convergence Plots

Argh, as usual, I never really finish any personal projects thanks to schoolwork...but it isn't all bad, here's a school-related project that is really cool:

You can solve the equation shown by posing it as a problem mapping from R2->R (rather than the complex numbers C->R). You can do this by expanding it out if you substitute the term a+bi for z.

Then I used three different methods of finding minima: Newton's method, fixed step-size gradient method, and the conjugate gradient method. The gradient methods were sloooooow especially at the center where the gradient is small.

Yellow means it converged to the point [a,b] = [0,1]. Green: [1,0]. Blue: [0,-1]. Red: [-1,0]. Orange converges to the origin [0,0]. White means it didn't converge to any of those but didn't go wildly careening off in some direction (diverge). Black means it did diverge, though I actually came up with that late in the game so some of these plots might not be totally accurate according to that legend.

In other news, some progress on the laser cutter but that's about it.

Sunday, August 7, 2011

My First PCB

Welp, I've always wanted to try getting my own pcb fabricated with BatchPCB and it is about time I did so. First things first though--I need a circuit. I found this current limiter on instructables, and I really like it.

While breadboarding this project I ran into some difficulties...This comic I made documents the trouble:

So then it was time to make a permanent version. However I suck at perfboard and my soldering iron is about ten times too hot and has no knobs or anything. So I brushed up on my EAGLE skills.

Hopefully that doesn't look too terrible! Venture Industries is just me paying homage to the Venture Brothers, which is only the best animated TV show ever.

In short, it does this:
  • I put it in between my experiments and my power source (usually for me, the 5V line from the USB port of my computer).
  • During normal usage, the current my experiments draw is underneath some threshold value. The green LED is lit.
  • When my experiment goes awry and the current draw is above that threshold, the green LED turns off and the red LED turns on and the current drops down something small (for example no more than 5V/.47kohm = 25mA).
  • My computer doesn't have to shut off the USB ports as a safety measure! +1 to laptop longevity.

Of course, I'm not about to send it off to BatchPCB right now...It's almost 5am. I don't trust myself so much at this hour. So I will error check again after sleep and then send it off. You have something like 12 hours of the posting time to warn me if you see a mistake! GO!

Anecdote: I was seeing a small (.05 or so) drop in voltage from the input to the output. I replaced what looked like a kind of thin, kind of old breadboard wire. The drop disappeared. Science FTW.

Sunday, July 17, 2011

Mid-project update: You give a mouse a cookie...

You give Shira an old G4 computer, and...
  • She'll want to install Ubuntu 10.04 Server Edition on it.
  • She'll want to run the Minecraft server.
  • She'll want more than 400Mhz. She'll go on eBay to find replacement processors.
  • She'll want to install a Quicksilver proc in the Sawtooth (AGP graphics) machine.
  • She'll need to cut the aluminum heatsink to fit with a dremel.
  • She'll want some thermal paste.
  • She'll want to know why her processor doesn't run. She'll restore the old processor to its place.
  • She'll suspect it is the out of date firmware.
  • She'll need to reinstall Mac OS 9 to update the firmware.
  • But she cut the CD drive, so she'll need to rearrange everything in the case to make it reach the other IDE connection point.
  • She'll need to torrent Mac OS 9, because nobody owns or sells that anymore.
  • She'll need to format the drive as HFS+ so the installer can write on it...
  • She's tired now. She'll want to take a break to watch South Park at 2:30AM.
  • She'll need to run the Ubuntu LiveCD but it won't run anymore.
  • She'll want to try a new IDE cable (but it won't work)...
  • She'll finally format the drive with mac-fdisk and a utility on Mac OS 9
  • She'll install Mac OS 9
  • She'll find firmware update is a .bin and can't be opened without Stuffit Expander
  • She'll try to unpack the update on her OS X laptop, but the G4 won't run it like that
  • She'll try to install Stuffit Expander on the G4 from the install CD but it crashes the computer
  • She'll download a version that does install and use it to unpack the firmware update
  • She'll find that the firmware update requires at least Mac OS 9.1
  • She'll apply the 9.1 update.
  • She'll curse the name of the person who packaged the US UPDATES with incompatible UK SOFTWARE. ARGH.
  • She'll torrent 9.2.1 US English. God Bless America.
  • FINALLY! She will install 9.2.1, and run the firmware update. Firmware version updated!
  • She will swap the processor, cross her fingers, and press the power button...
  • She'll want to run some tests and install Ubuntu again, but the CD drive isn't powered, because she accidentally connected the fans in parallel with it...
  • She'll want to fix it but her soldering iron tip is burning through itself (and yes, this can happen. I have seen it happen twice). Time for a new one.
  • She'll go to the hated Radioshack. She will want to make this very clear: she hates Radioshack. But it is in walking distance, while Fry's is a thirty minute drive.
  • She'll find that Radioshack won't have the same type of tip, so she'll have to put down $10 on a new El-Cheapo iron...urgh.
  • She'll discover that the CD drive is powered but Chuck Norris himself couldn't get the LiveCD to boot off of it. The Debian LiveCD won't boot either. Just Mac CDs work. Weird.
  • She'll spend two hours reading about Open Firmware, trying to get something with any distro of Linux on it to boot.
  • She'll find the magical command: boot usb1/disk@1:1,\install\yaboot
  • She will shout in surprise and then sigh when something appears about corrupted Amiga block partition thingies, and presents a 'boot: _" prompt. However, the install will continue after about ten seconds.
  • Install complete! But what's this... "DriveReady SeekComplete uncorrectable error???"
  • She will listen to dying hard drive sounds and conclude that her IBM drive is almost dead. Unfortunately, nobody is selling hard drives at 2am.
  • She'll find a small family run electronics shop the next morning, where a very nice dude sells her a replacement drive (IBM Deskstar 20.5 GB) for $10, and throws in another drive (Western 40GB) for free. They are even formatted as HFS already!
  • She'll install Ubuntu again and run the Minecraft server.
So what's the verdict?

1) The Minecraft server and Java are resource hogs, so while the rig can run them, it does a terrible job. Clients connected to the Minecraft server experience severe lag and the game becomes completely unplayable.

2) Since there is nothing to be lost, I may eventually open it up again and mess with the bus speed and CPU multiplier.

3) I no longer think the CPU is the bottleneck. I'm not really a hardware person, and I don't know how all this works, but I get the sense that the 100Mhz bus speed isn't going to cut it. The G4 has a 100Mhz bus speed. My laptop has a 1.07Ghz bus speed. Oh well.

So...what kind of awesome, interesting things can I do with a dinosaur tower?

Wednesday, May 25, 2011

Macro Photography

I'm working on a reverse lens macro photography setup. My initial trials are done with a Canon EOS Rebel.

The plus side to film is the nostalgia. The down sides are everything else.

Anyway, I have the lens reversed and mounted at the end of a long cardboard tube (poster tube I essentially cut in half). I have a remote trigger and a tripod and a Ikea lamp that is focused by a magnifying glass so that it delivers a pinpoint of light to the object I am taking a picture of. The focusing is done by sticking a compass in a book and using the fine tuning wheel to raise and lower the book cover.

I'll spare you the details until I have my more finalize setup, which hopefully actually happens (I need a DSLR...).

Sugar vs. Splenda vs. Salt

Magazine Cover

Xacto blade

Saturday, February 19, 2011

Picking and Choosing Your Coeffecients: Playing with the DCT of an Image

Where have I been?
Junior year is a ton of work. I've been extremely busy.

What is the post about? (Super simple version)
Sometimes I want to make a salad.

For my definition of "salad" I have a set of ingredients with which I can make ANY salad I like, ingredients like lettuce, tomatoes, cucumbers...etc.

A recipe for any given salad is essentially a 'linear combination' of those ingredients, for example, 1 tomato, 2 heads lettuce, 4 drops vinegar, 1 lemon. I am scaling and adding things from my dictionary of salad ingredients to make my particular salad.

I may want to play with that list, deleting terms, scaling terms differently, or who knows what. I might just want to demonstrate to you how the salad begins to look more like the salad we want to have as we add more and more of the ingredients in.

I can do this with anything. Here, I do it with images, and I represent them as a linear combination of 'checkerboards.' For example, for one case, we have 64 different checkerboards, which look like this:

I could prepare any image if I had all of these 'checkerboard' ingredients. I could convince you that it was the same image even if I only had a few of those checkerboards available (specifically, imagine I ran out of the ones towards the bottom right...I really don't need them). That's the theory behind lossy image compression.

What is the post about? (Less simple version)
I'm taking the 2 dimensional DCT of 16x16 blocks of this image of a bunny rabbit, then picking and choosing which coefficients to keep before computing the inverse and reconstructing the image. Since M,N=16 so there are 256 basis images.

Some pdfs for your reading pleasure:
-"Lab 6: the Discrete Cosine Transform"
-JPEG Tutorial
-Image Compression and the Discrete Cosine Transform

Original Image:

DC Coefficient only
(the very first term, which is just the average value of the image part)

AC Coefficients only (everything else but the DC Coefficient)

Line Coefficients only (no 'checkerboards' -- 'stripe' coefficients only )

First Four 'Lowest Frequency' Coefficients
(the first 2x2 coefficients from top left)

No Horizontal Stripes

No Vertical Stripes

I'll Do it Later
1. To take the DCT of the whole image (not just a block at a time).
2. To make a animation showing the terms added in a sequential zig-zag, showing the reconstruction of the image from all basis vectors.

Time to start my homework.