Archive

Archive for the ‘Tools’ Category

Swift Language Quick Reference

June 16th, 2014 4 comments

Swift is the programming language that Apple introduced two weeks ago at WWDC14. ¬†I’ve spent the last week pouring over the language guide, condensing (almost) all of the facts into a double-sided 8.5◊11″ quick reference sheet. ¬†I invite feedback, and hope that it’s useful to others. ¬†I recommend at least going through the Swift tour before diving in.

Swift QuickRef

Swift QuickRef



Skyworks 65116 update

January 9th, 2014 No comments

It has been a while since I played with the Sky65116 amplifier boards that I built and wrote about. ¬†Since getting my own spectrum analyzer, I’m now able to make much better absolute measurements. ¬†The DSA-815-TG analyzer is specified as having 1dB of uncertainly across the span, and the SA that I have at work is essentially uncalibrated.

Video modulator output

Video modulator output (click for enlargement)

Not only do I now know that the absolute power out of the video transmitter at the fundamental frequency is about 5.5dBm, I can also see the first and second harmonics. ¬†I don’t know why I didn’t see them with the other analyzer, but they are disturbingly large. ¬†I believe the FCC requirement is that these harmonics should be more than 40dB below the fundamental. ¬†By this criterion, the transmitter should not even be sold in the US.

The SKY65116 amplifier has close to 36dB of gain, and a 1dB compression point of 32.5dB. ¬†The 1dB compression point is specified as the output power level at which the gain is reduced by 1dB. ¬†The easiest way to show this is with the graph from the Sky65116 data sheet, shown below. ¬†You can see that as the output power begins to approach 32dB gain drops quickly. ¬†The goal is to not force the amplifier to operate in this region. ¬†If you do, you’re likely introduce harmonic distortion and other nasty nonlinear effects (i.e. intermodulation products).

Gain vs. Pout curve

Gain vs. Pout curve

So, knowing that the output is +5.5dBm, and we want about +30dBm out of an amplifier with a gain of 36dB, we need to introduce 11.5dB of attenuation (30dBm – 36dB – 5.5dBm = -11.5dB) between the transmitter and the amplifier, at a minimum. ¬†It’s easy to make 14dB attenuators with standard value resistors (4◊150 ohm and 1◊120). ¬†I’ve been playing around with QUCS a lot lately, so I’ve provided a model for the attenuator. ¬†It’s just about the most boring S-parameter model you’ll ever see… ¬†Perfectly flat response at -14dB, but that’s what we’re after.

Simple 14dB attenuator model

Simple 14dB attenuator model

A while back, I had a bunch of these simple 5-pole filter PCBs made up. ¬†I just left them blank until I needed them, and I made two of them into 14dB attenuators using the circuit above. ¬†I had two extra poles, so I filled one with a 0 ohm resistor and the other with a 1uF DC-blocking capacitor. ¬†The capacitor reduces the low frequency performance, but only less than about 1.5MHz. ¬†It’s worthy the trade-off in my mind.

Constructed attenuators

Constructed attenuators

I went ahead and covered one of the attenuators with copper sheet just to make it more of a completed package. ¬†I’m sure I’ll need to use it many times in the future. ¬†I left the other open so I could unsolder it and make it something else if needed. ¬†An interesting thing happened when I installed the cover. ¬†The small ripple in the attenuation (around 500 MHz, see below) occurred only after I installed the cover. ¬†I assume this is due to parasitic capacitance between the components and the copper covering. ¬†It’s still only about 1dB of ripple, so I’m satisfied with it.

14dB attenuator performance

14dB attenuator performance

Anyway, back to the amplifier. ¬†I’ve now got about -8.5dBm going into the amp ( +5.5dBm – 14dB), so with its 36dB of gain, I should expect to see +27.5dBm out of the amp. ¬†That’s getting very close to the maximum input power on my SA (+30dBm). ¬†It’s always better to be safe with these things, so I used the other 14dB attenuator between the amp and the SA. ¬†Now, I should expect to see +13.5dBm on the input. ¬†I maxed-out the input attenuation on the analyzer (another 30dB) and gave it a shot. ¬†Note that the internal attenuation is calibrated out of what’s shown on the display, and I told the SA about the other 14dB of attenuation, so the power values shown on the display are referencing the amplifier’s output.

Transmitter after amplification

Transmitter after amplification

In the above image, you can see that we’re getting 27.5dBm out of the amplifier! ¬†I love it when a plan comes together! ¬†This is the value I calculated, right on the nose. ¬†I promise that I didn’t work the math backward! :) ¬†Again, it’s so painfully obvious that the transmitter is AM, rather than the VSB signal that it should be.

Close-up of the signal

Close-up of the signal

Now, just for fun, let’s dive back into the video signal coming out of the transmitter. ¬†In the image above, I’ve put some markers on the various carriers present in the signal. ¬†The luma carrier is in the center at 433.85MHz, which is where we expect it to be. ¬†Marker 2 is at 437.45MHz, which is 3.6 (let’s call it 3.57) MHz away, matching exactly where the chroma carrier is supposed to be. ¬†There’s no audio carrier, which isn’t a surprise because there’s no audio, though I wouldn’t be surprised to see the carrier. ¬†Marker 3 is 19 MHz away; I have no idea what this is or why it’s there. ¬†It’s not supposed to be. ¬†Same with marker 4. ¬†Oh, well… ¬†that’s what you get with a shitty transmitter.

amplifier gain v. frequency

amplifier gain v. frequency

Now, what about those pesky harmonics? ¬†The Sky65116 is a 390-500 MHz amplifier, so my hope is that the reduced gain by the first harmonic will attenuate the harmonics enough to bring them into compliance. ¬†The graph above is the gain v. frequency graph from the data sheet. ¬†It’s neither encouraging nor discouraging. ¬†It’s difficult to infer what’s going to happen at 800 MHz when the graph stops at 500 MHz. ¬†In the image below, it appears that I lucked out. ¬†The first harmonic is 42dB down from the fundamental. ¬†If I were selling a product, there’s no way I would send this out for compliance testing. ¬†It would just be too risky, I’m not that confident in my measurements. ¬†By my math, it would cost less than $2 in parts (single unit quantities) to make a decent low pass filter. ¬†That’s the right thing to do. ¬†When I modeled it (in QUCS, again), I calculated that the harmonics would be within compliance even without the rolloff of the amplifier. ¬†With the rolloff, the harmonics would be well below the noise floor.

Harmonics after amplification

Harmonics after amplification

I’ve had a ton of fun redoing this experiment with my new spectrum analyzer. ¬†I’m going to write lots more about the analyzer in the future, and I’m really looking forward to it. ¬†Coming soon is an exploration of the skyworks low noise amplifiers. ¬†Between these two products, I expect to have a solid video link over 1000 feet or so.

3D Printering

January 6th, 2014 No comments

Ok, confession time. ¬†I succumbed to the 3D printing fad thing. ¬†I know. ¬†I made fun of 3D printer fanbois in the past, but we got one at work. ¬†Using it for a bit forced me to realize that they’re actually pretty cool.

My kit of reprap parts!

My kit of reprap parts!

I asked my whole family to chip in for a¬†RepRap Prusa i3 kit¬†for my birthday (in September, to give you an idea of how behind I am). ¬†It came relatively quickly, but there were certainly some issues. ¬†For one, everything smelled –very strongly– of cigarette smoke. ¬†Luckily, it was mostly isolated to the outside of the packaging. ¬†Once I unpacked everything, it went away.

Aaaarg!  Two sets of threaded rods!

Aaaarg! Two sets of threaded rods!

Then, I discovered that I got two sets of threaded rods!! ¬†That wouldn’t be so bad, except that I didn’t get any smooth rods! ¬†I emailed the company, and they got a replacement set of smooth rods in the mail right away, but I still had to wait a while. ¬†In the mean time, I figured that 5/16″ is awfully close to 8mm. ¬†I bought some 5/16″ stainless steel rods from the hardware store to keep working on the printer. ¬†The 5/16″ rods are undersized for the LM8UU linear bearings (they’re designed for 8mm rods), so there was extra slop in all the axes. ¬†Eventually, the 8mm rods came in the mail, and I installed them.

There were a few other minor issues. ¬†For one, the melamine material that was used for the main frame was thicker than the laser-cut slots. ¬†I had to carefully trim the tabs so that they would fit. ¬†It may be difficult to understand what I’m talking about without photos, but all that’s important to understand is that there were some attention to detail issues.

After printing for a while, I noticed another problem with the melamine. ¬†It’s also used in the frame that holds the build platform to the Y axis bearings. ¬†The frame material wasn’t strong enough to level the platform. ¬†When I lengthened the screws on the low sides, the frame would just bend downward rather than moving the platform. ¬†I found a place in town that sold me a sheet of 3/16″x1’x2′ aluminum for $5, from which I cut out a replacement frame with my scroll saw.

Other than those problems, everything went together smoothly. ¬†One interesting thing about RepRaps (the models that I know about, anyway) is that they don’t really include something to hold your spool on. ¬†I almost think it’s to give people something to design and print out of the chute. ¬†My solution was to build a frame using aluminum channel stock. ¬†I started with just the upright part of the spool holder. ¬†Then, the spool spun a bit too easily, and it would unspool and catch on things. ¬†The angled portion holds a dry sponge with a hole in it. ¬†This has the dual purpose of wiping the dust off of the filament and providing a small amount of friction.

The reprap is all finished.

The reprap is all finished.

The green adapters on the spool ends are just bearing holders that help the spool turn more easily. ¬†It was the first thing that I printed. ¬†Here’s a very short video of it working:

¬†The final issue I had was with the GFCI circuit in my office. ¬†I can’t figure out why I have GFCI there, but I do. ¬†To add insult to injury, my firewall/router/server is on the same circuit. ¬†So, every time the printer trips my GFCI, it takes down the internet and generally causes havoc. ¬†I pulled my hair out over this one. ¬†I replaced my (very expensive) GFCI circuit breaker and the printers power supply.

Trying to measure GFCI current

Trying to measure GFCI current

In the photo above, I’m trying to measure the peak ground current from the printer. ¬†The fluke is on the mA setting with peak hold. ¬†This is the highest reading I ever got, and the circuit didn’t trip. ¬†It’s my understanding that GFCI trips when there’s about 30mA on the ground circuit. ¬†My assumption at this point was that the shunt resistance in the DMM was limiting the peak current, therefore no 30mA spike and no trip.

The problem persisted for sometime, and I began to suspect the GFCI breaker. ¬†I went to an electrician store, and the guy said that they can wear out.¬† After I replaced the circuit breaker, and $50 later, the problem got worse! ¬†It would trip even when the printer wasn’t plugged in! ¬†At least then, it was no longer an¬†intermittent¬†fault. ¬†Now that I could reliably cause the fault, I at least had hope for isolating it. ¬†I unplugged everything on the circuit and plugged in things one-by-one. ¬†I turned out that a cheap power strip (the same kind as in the above photo) was the culprit. ¬†Boooo.

Any way, I’m now a 3D printing convert. ¬†But I promise I won’t be annoying about it. :)



Emma’s Red Dresser

January 3rd, 2014 No comments

Katie and I needed to get a dresser/changing table for Emma.  We decided to find an antique dresser to redo rather than the pressed-wood pieces of crap you can buy today.  We found one at the Corvallis ARC that fit the bill nicely.  Unfortunately, I neglected to take photos of it before attacking it with the sander.  The following two photos are during the sanding process, though.

Starting to sand off the stain

Starting to sand off the stain

Some of the drawers before sanding

Some of the drawers before sanding

The stain and finish that they used was nasty to sand off.  When it got hot from the friction, it would melt, kinda, and gum up the sand paper.  Eventually, and after many sheets, we got it all off.  In the process, I bought a Ryobi Corner Cat which I like O.K.  I had to replace the velcro pad that holds the sand paper because it wore out.  Shipping took a bit, but the replacements were only a dollar or two.

Once I got all the stain off, I could assess the level of wear the dresser had accumulated over the years. ¬†In total, it wasn’t bad. ¬†It was pretty interesting to see how construction methods have changes over the years.

Slightly distressed corner

Slightly distressed corner

In getting ready to paint, I masked off the inside of the chest openings.  In this view, you can see the construction.  Lots of random sizes of lumber, everything is mortised, etc.

ready to paint the chest

ready to paint the chest

It took a ton of coats to adequately paint the dresser. ¬†It didn’t help that we did this at the height of summer, and it was HOT. ¬†The paint was practically drying as soon as it left the pail. ¬†This left a very poor finish, and honestly, I’m a bit disappointed in it.

The chest is painted

The chest is painted

Eventually, it got to a point that I could live with, and we reassembled everything. ¬†I chucked the knobs into the drill to sand the finish off. ¬†I’d like to eventually get some antique porcelain knobs. ¬†I think that would look really nice.

One extra thing we had to do, that I don’t have pictures of, is replace the drawer bottoms. ¬†Most of them were in really bad shape, and weren’t even square! ¬†I just bought some plywood at the store and had my friend Tom cut them to size on his table saw.

Painting and reassembling all finished

Painting and reassembling all finished

We’re all finished! ¬†Here’s the dresser in its new home, complete with changing pad. ¬†Hopefully, as Emma grows up, she’ll like and appreciate it!



Compiling GnuRadio 3.3.0 on Mountain Lion

July 25th, 2012 6 comments

Fixing all the little issues with this process took me days, so I apologize if it’s a complicated and multi-step process. ¬†These steps worked for me, hopefully they work for you too, but YMMV.

First of all, it is vital that you don’t have the macports boost 1.50 installed. ¬†There is a problem with that version where the x86_64 version of the library isn’t compiled. ¬†This is mentioned in an earlier post, and the mac ports trac entry is here.

The easiest way to begin is to install boost 1.49 then run “sudo port install gnuradio-core” and let macports install all of the pre-requisite packages (you may need to perform the fix I mentioned in that earlier post to fix netpbm) . ¬†When it finally gets to gnuradio-core, it will fail. ¬†Now, what you need to do is:

$sudo port edit gnuradio-core

Follow the instructions, again in that earlier post (update 2).

$sudo port clean gnuradio-core
$sudo port -n install gnuradio-core
---> Computing dependencies for gnuradio-core
---> Fetching archive for gnuradio-core
---> Attempting to fetch gnuradio-core-3.3.0_0+python26.darwin_12.x86_64.tbz2 from http://packages.macports.org/gnuradio-core
---> Fetching distfiles for gnuradio-core
---> Verifying checksum(s) for gnuradio-core
---> Extracting gnuradio-core
---> Applying patches to gnuradio-core
---> Configuring gnuradio-core

THIS IS IMPORTANT!: Cancel (control-c) when it says “Configuring gnuradio-core.” ¬†At this point, we need to hand-edit the configure script in the gnuradio source directory. ¬†The reason for this is because some of the assembler code in gnuradio uses 32-bit only opcodes. ¬†When compiling for 64-bit machines they generate errors. ¬†It’s necessary for them to be compiled differently. ¬†Luckily, when Lion was released, a fix was devised and added to macports. ¬†The same exact fix (in principle) should work for Mountain Lion. ¬†But, in the configure script, the change looks for Lion and doesn’t detect Mountain Lion. ¬†We just need to change the test to detect Mountain Lion. ¬†The difference is only the version of darwin used. ¬†This information is in this trac.

$cd /opt/local/var/macports/build/
$ls

$cd gnuradio-core/work/gnuradio-3.3.0
$sudo vi configure

Once editing the configure script, search for “darwin*10*” or “darwin*11*”. ¬†This is easy if you hit the forward slash and type “darwin\*1″:

/darwin\*1

The region of interest should look like this (the numbers are the line numbers):

20154     *darwin*11*) 
20155 # The cast to long int works around a bug in the HP C Compiler 
20156 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects 
20157 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. 
20158 # This bug is HP SR number 8606223364.

Change the *darwin*11* (or *darwin*10*) to: *darwin*12*

Close the vi session by hitting <esc> then : then type wq and enter.

Now, run “sudo port -n install gnuradio-core”. ¬†Make sure that you DO NOT clean the package. ¬†This will destroy our edited configure script.

When that finishes (hopefully it does!) you should be all set! ¬†You’ll probably want to install gnuradio-companion as well as gnuradio-audio-osx.

If you have any problems or questions, let me know in the comments.