Oscilloscope, Part 2 (PCB)

A few weeks and a few swearing sessions later…

Congratulations!!
The layout is complete and has no shorted nets.

board

2 layers PCB. Probably going to get it manufactured by Olimex.

This is my first board ever, so I’m guessing there are tons of errors everywhere. lol.

All the surface mount caps are the same type (0.1uF ceramic). I used through hole capacitors for the other few because SMD capacitors tend not to be labeled… the labels would be too small to see anyways.

2 connectors on the left are BNC (oscilloscope probe connection). Goes to analog frontend (the part without ground plane), then the programmable gain amplifier (U1), then 2 ADCs (U3 U4), then FPGA (U6). U10 is the 25MHz oscillator for the FPGA. U5 is the DAC used to set voltage offset. U7, U8, U12 are voltage regulators. U11 is charge pump doubling inverter to generate negative voltage for amplifiers. U9 is USB interface chip. The connector on the right is USB-B.

In case you are wondering, most of the holes (181 holes!) are vias (connections between the 2 layers), not for soldering components. So no, I won’t be spending the next 20 years of my life soldering this board =P.

Next step, throwing a pile of money at Digikey!! (very exciting)

Actually, I think I will solicit some feedback from random forums first.

The layout file in gEDA PCB format –
http://cyberfish.wecheer.com/tmp/board.pcb

Feel free to poke around.

On Debian/Ubuntu, do “apt-get install geda”, and “pcb board.pcb”.

I don’t think gEDA runs on Windows. Sorry. Some people reportedly have successfully built it on Windows, though.

Ooh, shiny!

A friend of mine, who prefers to stay anonymous for personal security (duck!), drew this.


(click for full image, or mouseover to be enlightened!)

She may not have her own exhibition at the art gallery yet (a post on my blog is almost as good), but this is very promising talent!

It’s the minor league for xkcd.

If you are the author of xkcd and wants her to join you, or wants to sponsor a young promising artist, or just want to have a good time, call her at
778-372-1287

Satisfaction guaranteed.

RIP, ><((((>

It’s not who I am underneath, but what I do that defines me.

– Batman

Nevertheless, I believe something that has been representing me for so many years deserves at least a blog post for its retirement.

2003 – 2010 (aged 7)
My registered trademark, the “><((((->” MSN display name, will be no more. So long, and thanks for all of the one fish.

It’s about time to move on.

It has been faithfully representing me on MSN ever since grade 7. Only the number of fins have ever changed, and that was accidental. I’ve also changed its swimming direction once, and exactly 1 person noticed =P (or at least told me they did).

I believe it was a modified version of some random ASCII art I found on the internet to match my online pseudonym (cyberfish), which has served me just as long.

I will probably change it in the next few days (I sign in from 4-5 places… so it takes a while to change them all). So take a picture with it, give it a hug, or even just a stare, while you still can :).

The pseudonym, though, is here to stay, fortunately (for me) unfortunately (for it). Probably for life.

I’m not sure where the “cyberfish” came from. I think I just grabbed 2 random words from a dictionary, and stuck them together, hoping it will give me a unique identifier, and after 50 years, I’ll be able to google it and see nothing but my own stuff. Nope, lots of people are using it too.

People have said it’s girly. And I agree.

Girls are cool. I like girls. They are pretty (the pretty ones are).

Beauty and the Beast

I may not be the beast, but she sure is the beauty =D.

Just got my Nexus One! It’s gorgeous.

Similar specs to iPhone 4 (5MP camera with auto-focus, a bunch of sensors, 512MB RAM, 1GHz ARM CPU, etc), without the Communist Apple touch.

Can change the battery, has SD card (instead of way overpriced internal memory), has native msn client, has flash, and you can actually decide what you want to run on it =P.

Going to use it with Wind’s cheap data plan =D ($35 total for 500MB/month is amazing)

Got it without contract for some big pile of money. The Xperia X10 can be had for almost free with Rogers 3 years contract, but I don’t like contracts, and I don’t like Rogers (or any of the big carriers for that matter). Wind may not have cute animals on their site, but their attitude sounds so much better. They actually make sense.

It’s funny that I’m into smartphones because I don’t really talk on the phone all that much. About 2 seconds a day calling my mom to pick me up, and a few hundred texts a month to my dear friend Cindy about… things that you wouldn’t want to hear about. And then there are the occasional tennis invitations that always end up nowhere for some reason… But otherwise not much at all!

I use my phone as anything but a phone. I’m thinking about using a phone without a plan… hmm. I wish they would just sell data =P. Otherwise it will just be an expensive ebook reader.

Trivia: Linus Torvald, the “inventor” of Linux, also got a Nexus One! He is very picky about phones, and only buy phones that run Linux.

Blogging about Blogging about Blagging

In my not so humble opinion, blogs are the second most significant invention in the history of mankind, after sliced bread.

When I first started blogging about 5 years ago (?), it was very different. It felt like an obligation. To readers. To “trends” (it was a trendy thing to do at that time, when everyone had Xanga, instead of Facebook).

I tried hard to be interesting, to not bore my readers to death, to have “something” to write. It wasn’t for myself. It was for “readers”. As if my blog really had any significance to anyone else.

Ended up writing about the weather every other day, and about how I have nothing to say the rest of the time, and things I pretended to care about, pretending to sound thoughtful or profound by copying and pasting quotes from nowhere. Then I pretended to be interested in some people’s blogs and leave comments hoping they will do the same because number of comments was a measure of personal worth, like how number of Facebook friends is now.

I’m not sure how I survived through that, but those were the dark days. That’s not the kind of blogging I am talking about.

As you can clearly see from this post, I have given up on trying to be interesting a long time ago (are you STILL reading?! =P). And obviously, my writing hasn’t improved one bit over the last few years.

It feels so much better. Now that I can write about what I really care about, and not worry about what people think (don’t count the number of “about”s in this sentence!). It almost feels like an extension of my consciousness (no, this is not an attempt to sound profound. Just a display of my confusion).

I don’t even proof-read my posts anymore.

I always feel a lot better when I put things down on paper (err. keyboard). Happy things, sad things, ugly things. Whether people read it doesn’t really matter.

And I just lied. If whether people read it or not doesn’t really matter, I could just write in a diary or something.

It does matter. It’s the feeling of sharing that brings relief and happiness. Knowing that someone somewhere on the internet is reading this post makes writing it so much more interesting.

And I know a few of my friends DO read my blog, instead of doing a million more interesting things they could be doing. And I would love to say I don’t care since that sounds so much cooler. But I do. I do get excited when I find out people read my blog.

So thank you 😀 :D. You have changed me. A little part of me is made out of you (how right does that sound?).

If you have never tried blogging, try it some time! (and remember to link me) It’s a whole new world.

Smoking marijuana would give you similar experience, but blogging is legal almost everywhere, not just in BC :). Equally addictive, though.

Why Apple Sucks

As promised, here is a post full of Apple-rant.

Why Apple sucks?

There is no more innovation.

Apple used to be an inventions powerhouse, with bright new inventions every other week, and everyone else trying to catch up.

The whole concept of GUI, the Mac OS (Windows was heavily influenced by it), desktop publishing, the PDA, the original iPod, etc.

I had quite a bit of respect for them back in the day, and even bought an iPod Nano (would’ve bought a Mac if I had the money).

But now, what have they been up to?

The iPad – a giant iPhone without the phone.

Or, in Apple-speak, “a magical and revolutionary product”.

I can assure you, it’s nothing revolutionary. Magical or not is up to you to decide.

http://h18000.www1.hp.com/products/quickspecs/11755_na/11755_na.html

circa 2004. I’m pretty sure they existed at least a few years before that, too.

Just because many people haven’t heard of tablets doesn’t mean they didn’t exist.

It even comes with a keyboard.

There were a few keyboard-less models as well, but they weren’t well received, and have always been heavily criticized in terms of practicality.

Curiously, when the iPad comes around, 10 years late, with absolutely no innovation compared to what tablets looked like years ago, with Steve Jobs lying blatantly that it’s this whole new idea that will forever change the history of computing, of how people use computers… people just seemed to accept it like some gospel.

At least enough people did for the rest to not matter.

If anything, the iPad packed way LESS features then tablet PCs did years ago.

Now they are just cashing on the existing fanboys that will buy ANYTHING Apple makes.

I bet if Steve Jobs announces a new type of shit sold in conveniently packaged small piles, guaranteed to be from healthy cows with balanced nutritions, people will line up to buy it.

It’s sickening to see how Apple can just roll out any overpriced crap and make millions. Doing business is not supposed to be THAT easy.

They have a great marketing department, but I guess the engineering department (do they even have one?!) has had one shot too many.

Innovations (or lack thereof) aside, they also now employ some very shady business practices.

Waging patent wars against everyone (guess they figured they finally have a big enough legal department to do that eh?) when they copy people’s ideas and label them their own as they wish.

And then there’s the draconian software censorship that says all programs you write must pass Apple’s censorship, must come from Apple’s site, and you must pay $99 upfront for your submissions to even be CONSIDERED. So no, you can’t just write some kickass app, and share it with your friends. Oh and it has to be in Objective-C (a language no one else uses), and the SDK only runs on a Mac.

And no, they didn’t ban Flash because of any of the reasons they listed. They did it because supporting Flash would allow YOU to decide what you want to run on your phone/iTouch. That is VERY bad.

I am actually shopping for a smartphone now. Not sure what I’ll get yet. Probably Android or Symbian based (both of which are open source). Maybe Windows Mobile if there’s a really good one (but the only SDK is Visual Studio, which I’m not a particularly big fan of). Anything but an iPhone. No communist Apple for me.

The Android looks really nice. Open source OS based on Linux, with flexible SDK that runs on Windows, Mac, AND Linux. Java and C/C++.

I’m craving for a Nexus One, but $500 is quite a big pile of money (~3 days of zombie killing!). Looking for cheaper alternatives. I really just need a big screen (for reading on the bus) and at least a half decent camera (>2MP). Any suggestions? =D

How to Make an Oscilloscope

Introducing… *suspense* the iScope!

No, just kidding. I hate Apple with a passion, due to the things they’ve done recently. But that’s for another time =P.

Oscilloscope design!
scope

I’ve been working on it for a few weeks. The schematics is all done, so I thought I would document it a bit.

Goals (where they came from will become clear later) –
100 million samples per second (Msps), 40MHz bandwidth
2 channels at full speed
USB interface (USB powered)
Compatible with regular 1x and 10x BNC oscilloscope probes (direct connection and 10:1 attenuation)
– meaning input characteristics of 1MΩ in parallel with ~20pF (to make sure the probe can compensate for it)
True range selection (apparently some cheap USB scopes don’t have this)
Flexible triggering (including pre-trigger data view)
Offset (true differential)
Protected (diode clamped) inputs

Nice to have –
Logic analyzer
Cheap (-er than ridiculously priced low end USB scopes at least)
Calibration output (1kHz square wave)
Internal attenuation to allow big input

Major design decisions –
How does the data get from ADC to computer?
Streaming over USB is not an option. USB (even 2.0) is too slow. Even if we can somehow run it at the theoretical maximum speed of 480Mbps (or 60MB/s), at 8-bits per sample, that’s only good for 60Msps. 40Msps more realistically. We need 2x100Msps.

So there has to be an onboard buffer.

Then there’s the choice of microcontroller vs CPLD vs FPGA.

Microcontrollers are too slow. It would take about 10 clocks minimum to get one sample from the ADCs (toggle ADC clock, read input, check overflow, check triggering, etc). Meaning we’ll need a microcontroller/processor that runs at about 1GHz. A Core 2 Duo in an oscilloscope, anyone?

Programmable logic (CPLDs and FPGAs) is a more sensible choice because they can do many things in parallel.

CPLDs are cheap, easy to wire up, and hand soldering-friendly, but they require a bunch of supporting chips – a microcontroller, SRAM chip, and PLL chip (or very high speed oscillators, which are bloody expensive).

An FPGA, on the other hand, can synthesize the microcontroller, memory (RAM blocks), and has internal clock manager (PLL).

I ultimately decided to go with the FPGA, since they are cheaper (if you count all the external chips saved), and bigger in case I decide to add other things later on.

It was a choice between Xilinx Spartan-3AN and Altera Cyclone. I like the Altera development software more… but the Xilinx chip is much more impressive. It has built-in flash memory (non-volatile, and no need for an external ROM), and is a little cheaper. So I went with Spartan-3AN (XC3S50AN in TQFP-144 package).

It’s easier to wire up than I thought. Just 2 voltage rails (3.3V and 1.2V), clock, and JTAG for programming. The rest are all I/O pins.

The USB interface chip is FT245 (USB to FIFO) instead of the more common FT232 (USB to UART) because I am too lazy to make a UART in VHDL =P. Drawing 6 more wires (parallel interface) is easier.

ADCs are a pair of AD9283 from Analog Devices. 100Msps, buffered input, parallel output, simple interface. What more can you ask for?

DAC chosen is AD5724. Quad bipolar output (output can go negative), 12-bit, SPI. Bipolar output is hard to find, but that saves 2 op amps to do level shifting. The DAC is used to generate offset voltages.

Now the interesting part – analog front end!

Input goes into a 1MΩ metal film resistor in parallel with 20pF ceramic cap (not sure about this). Buffered by a Texas Instruments OPA656 wideband op amp with JFET input (very high impedance, which we need, because the probe has high input impedance. Downside? bloody expensive).

The next stage is a Texas Instruments THS7002 dual programmable gain amplifier. Each channel consists of a pre-amplifier (regular high speed op amp) and a second amplifier with a gain selected by a 3-bit digital input.

I use the pre-amps as good old op amp summers to add offset to the signal.

The amplifiers have 70MHz bandwidth, way higher than what we need. Interestingly, that doesn’t depend on gain. Usually, voltage feedback amplifiers have a fixed gain-bandwidth product (GBW), so for example, the bandwidth at gain = 2 will be approx. half of the bandwidth at gain = 1. Not for this one. Cool stuff.

Power supplies –
5V is provided by USB. -5V is 5V doubled and inverted (by the LM2682 charge pump), then regulated down (up) to -5V. 3.3V and 1.2V are from linear regulators (MCP1825S-33 and MCP1825S-12). The FPGA can potentially consume a lot of current on the 1.2V line, so making it a switching regulator can make it a lot more efficient. I don’t think it’s necessary, though, and I don’t really want to deal with inductors (and their EMI noise).

Clock for the FPGA is from a 25MHz oscillator. Will be pumped up to 200MHz (x8) by the FPGA’s phase locked loop. Hopefully.

Any suggestions? 🙂

Bill of Material –

XC3S50AN Spartan 3AN FPGA, TQFP-144, Speed Grade 5 $11.82
THS7002 Programmable Amplifier, 70MHz $22.28
OPA656 500MHz Op Amp with JFET Input $13.04*2
AD9283 8-bit parallel ADC, 100Msps version $10.46*2
AD5724 12-bit SPI Bi-polar DAC $11.59
MCP1825S-33 3.3V Low-Dropout regulator $1.01
MCP1825S-12 1.2V Low-Dropout regulator $1.01
MC7905 -5V regulator $0.96
LM2682 Doubling Inverter (Charge Pump) $2.23
FT245RL USB to FIFO Interface chip $4.95
USB mini-b connector $1.05
BNC connector $1.84*2

Adds up to $107.58. All prices from Digikey, at single quantities.

However, if you are a university student, you can get most of the expensive chips for free from the manufacturers as samples. Most of them don’t mind giving samples to students. Don’t lie, that’s bad. Just ask nicely.

I got the amplifiers, the ADCs, and the DAC for free.

Even if you are paying for everything, you should be able to have the whole thing built for about $150 (passive components, and PCB). Cheaper than all comparable commercial scopes I could find.

If you are using free chips, aim for $50?

I haven’t started on the software yet, but it will most likely be open source (just like all the rest of the design) and cross-platform, using Qt.

I’m most worried about the hardware, since I know a little programming :).

Knowing myself, there are probably tons of mistakes/oversights in the circuitry. Help?