Wednesday, November 26, 2008

Of Scopes and SMDs

I've always loved electronics for its 'minuteness'. I'm fascinated, even today, by how small consumer electronics can get. Have you ever opened up your cell phone or iPod and seen the myriad tiny chips and resistors and capacitors and whatnot? And do you realize that what you see is actually not small; it is HUGE when compared to what is on the inside of those silicon chips.

With Intel, using the 45nm process to manufacture its current processors, now talking about switching to the 30nm, and progressing to the 10nm fab, everything is set to get very, very small. The SMD resistors on your Nokia motherboard seem gargantuan in comparison.

Anyway, I absolutely needed to get myself a piece of this deliciously small pie. So in the past few months I've stared working with surface mount devices. Naturally, if I've reached the level where I'm working with SMDs, I would also have reached the level where I would need the services of an oscilloscope. Problem is, an oscilloscope, even a government-office-used, second-hand, two channel, 100MHz scope - the minimum demanded by any respectable hobbyist - costs about 10 grand. 10 grand is something I would like to have, but sadly, I don't. A new plain-jane CRO-oscope is about 25-30K, while (drool) Agilent DSOs start at a prohibitive 70K. Even cheapo entry-level USB oscilloscopes are a minimum of 10K, and to make matters worse, they aren't available in India.

So, like any other respectable hobbyist (all respectable hobbyists have what is called 'electronics-ego' - some may call it a touch of madness, others, an obsession, and yet others, an incurable disease; to hell with you, you vile naysayers! May you all burn!). Umm, yes, where was I? Aah, as I was saying, like any other respectable hobbyist, I decided to go the DIY way, and build my own scope.

The advantages of building your own scope - it's dirt cheap, and you learn a ton of other stuff (analog layout design, ADC nitty-gritties, USB firmware coding, and host data-handling to name just a few).

The scope would follow this kind of layout:

(Analog front end) --> (Data packaging for USB, on the PIC) --> (Host data display)

(Buffer) --> (PGA) --> (Hardware AA) --> (High speed dual-channel parallel-out ADC from MAXIM/TI)

(PIC 18F4550)
-> (8Mbit memory from Cypress, for deep capture)
-> (External trigger sources)
-> (USB2.0 Full speed @ approx 1.2MBytes/sec bulk transfer)


(LabVIEW software frontend)

Upto now I've built, and tested various parts of the AFE - I still need to throw everything together, and see if I actually get the desired results (this, without a doubt, is the biggest thorn in any engineer's side; everything works perfect in the lab, it works well as individual modules, and then, when you try to put stuff together, it all just falls apart. You start swearing and tearing your hair out in frustration; that's the reason why I'm.....uuh, forget it).

Last night (in Sid's words, and CCS-C) I was on cloud [unsigned int8 cloud 0b00001001]. I got USB bulk transfers to work with LabVIEW, albeit, in a crude way. Nevertheless, it worked, pleasing me tremendously. LabVIEW makes development super-easy. Easy, in a way that makes you feel dumb. Amit Sabne, who I've been brain-storming with, puts it very concisely - "Yaar, feel hi nahi aati!" - which is kind of true. The chaps at NI have done a great job of making hardware interfacing a snap. Wait for your USB device to enumerate, enter its VID and PID (device/manufacturer specific 'serial numbers'), throw a few icons and VIs here and there, and voila! You have délicieux transferts de USB bulke, served hot! (yes, is most helpful). The NI engineers have robbed hardware-software hackers from the trials and tribulations of mind-messing driver-writing, back-breakingly long hours of prouring over hardware, and sleepless red-eye-rubbing nights. Damn! Where's the joy and satisfaction if you can do something in 10 minutes, what used to otherwise take hours?

Now that I've got a rough and dirty implementation of PIC to USB transfers to work, what remains is putting it all together. Gimme a few days, and I'll upload the PIC firmware in CCS-C, and the LabVIEW VI here for you to use, enjoy, redistribute!

Monday, November 17, 2008

My वायरलेस प्रेसेंटर

Wow! Hindi transliteration on blogspot! That's an interesting feature! :-) Useless, but interesting, nonetheless.

Just a small point to note: I'm typing these first few lines from 15 feet away, using my wireless presenter. (Big smile :-) )

Naturally, you scoff, "How can you do that? Oh! You have a wireless keyboard! Umm, hang on a sec! You said वायरलेस प्रेसेंटर . How are you typing text?" (Bigger, mysterious smile :-) )

Well, I made my own Wireless Presenter-cum-Keyboard-cum-Mouse. (Biggest smile yet :-) And, in Sheldon's words - TBBTS02E07 - Muaa-hah-hah). Here are the details.

This project originally started off beacuse I used to get exceedingly irritated with the abysmal lack of dexterity afforded by standard keyboards. This lack was / is felt, most painfully, when getting fragged in a fast-paced game of CoD. "I need my grenade! Where the hell is the 'G' key. Dratted keyboard." My rifle! My rifle! '1'! '1'! '1'. Shots fired! Duck! 'Q'! 'Q'! 'Qqqqqqq....!'. I'm sure you get the point. I also do a lot of 3D modelling in AutoCAD, and image editing in Photoshop. My mouse, which would ordinarily be considered reasonably good, fares pathetically at this zoom-in-zoom-out-click-to-do-this-tap-to-do-that kind of stuff. Wouldn't just be great to have an additional fully customizeable keyboard? It would have a zoom slider, a wonderfully sexy scroll wheel (much like the iPod's), multiple buttons, and special keys which have several keyboard buttons bound to one (so to press 'Ctrl-Alt-Del', I'd just need to press one key on this keyboard). The mouse would be integrated into this device, and would have similar useful features.

I can, of course, buy such a device, but that would mean shelling out absurd quantities of cash - something that I don't have much of! Making one would mean I'd save potloads of money. I have been reasonably successful; hence this post.

So far, I've only made a Wireless Presenter, but this same device can be adapted to do all the stuff I mentioned above. A little effort, some pain, and a couple of milk-and-cookies-filled all-nighters are all that are necessary.

Without going into the overly-technical details of the device I'll tell you what the system consists of:
- a full speed USB PICmicro (the 18F2550) (free from Microchip);
- a TSOP1738 IR detector (Rs.10);
- a cheap roadside SONY TV remote (Rs. 60);
- a USB cable (free from an old mouse), crystal (Rs. 4), capacitors (Rs. 4).

The SONY remote sends IR data to the TSOP, which is connected to the '2550. The PIC decodes the IR signals (which are in SONY's SIRC format). The '2550 then sends this data through USB to the PC. Now, I've programmed the PIC to enumerate as a USB keyboard-mouse combo device. So my PC, for all practical purposes, thinks that it has a second keyboard and mouse. I have mapped certain keys of my laptop keyboard to keys on the remote. So pressing the 'Program +' key on the remote, is equivalent to pressing the 'Right Arrow' key on my keyboard. Pressing the 'Power' button on the remote is like pressing 'Esc' on the keyboard.

This is the nice thing about putting software (firmware) onto a microcontroller - you can fiddle around, and map virtually any key combination to any remote key!

I use this device to control MS Powerpoint slides from upto 30 feet away. I've mapped most of the Powerpoint keyboard shortcuts to buttons on the remote. The 'Contrast' button is 'F5', the 'Program Jump' button is 'Enter', and so on.

For a full listing of the source code go here .

I've made this using a PIC, but if you get the logic and code right, I'm pretty sure you could use any processor.

Future modifications include adding an accelerometer to provide intuitive mouse support (right now I'm pressing 'Mute' and the 'Volume / Program +/-' buttons for mouse-like action). Maybe I'll even port the whole thing to RF (Zigbee, or MiWi); it's running IR now - the great thing about IR is that its laughably cheap and easy! RF would involve additional cost and effort (protocols, and other crazinesses). For now, this is good. Anyway, in the beginning you had asked (well, alright, I had made you ask) how I was typing out text using my वायरलेस प्रेसेंटर.....I think you have the answer now.

I will be, at some point in time, making the gaming device I talked about earlier, but until then, I'll have to amuse myself with this :-) If anyone is planning on building something similar drop me a mail - I'll be glad to help.

Thursday, November 6, 2008

I Don't Want To Forget

So I’ve been doing some thinking. About many different things. Things important to me, and things not so important to me. About family and friends. About electronics and cars. About my past and my future. Most of the time these thoughts have been narcissistic and self-glorifying. But there have been a few times I have thought along other lines as well.

There’s a lot playing on my mind of late, and applications (to universities for graduate programs) are not at all helping my case. There are so many confusing forms to fill out; so many queries in my mind. There are times when I feel like ditching the whole process – who cares! Aargh! I don’t want to study within the constraints of the system. I want to learn. How can someone tell me what to learn? Why should I follow a fixed and defined path? After all there’s so much more to life than text book knowledge, right?

Consider this - a friend of mine recently lost a relative. When someone loses another person close to them what do you say to them? Do you say anything? What does social protocol demand of you?

“Hey, I believe you lost so-and-so. I’m so sorry.”

Is that enough?

Are you really sorry? Or are you just doing what is customary?

Can you take away that person’s pain? And maybe I should have led with this – is it right to take away that person’s pain?

Maybe the mourner doesn’t want to forget. Maybe the mourner just wants to hold on to the beautiful memories a little longer.

Life’s tough. Hang in there buddy.