Home USB NerdKit

Login



 

USB NerdKit

DIY microcontroller kit
Category: ReviewPosted by Fallingwater on 06 August 2011

Original article date: 15th December 2008

I think of myself as a pretty good McGyver-ish hardware hacker, but that's not actually a very hard thing to be. Know how to rewire a circuit, splice in a LED or a switch or something, hack up a battery pack, and other similarly basic things, and you're well on the way. Throw in a practical mind and the ability to put things together in such a way that they don't fall apart if you look at them too hard, and you're pretty much set.

But whenever I show some of my creations to, um, electronically unenlightened people, they always assume that I'm an electronic genius, and invariably proceed to ask me all sorts of complicated (and often amusing) questions on the subject.

They are often disappointed.

I know some of the theory about electronics, and I'm pretty knowledgeable in the fields of batteries and LEDs, and I know what basic components do (resistors, capacitors, the like), but I never bothered learning electronics properly, because the degree of knowledge needed for my usual hacks does not require much specialization.

So if you give me the necessary parts and a diagram I'll build you a working circuit, but I'll have absolutely no idea why the parts go where they go. It's like Lego: anyone can build the most complicated designs given the instruction booklet, the bricks and enough time, but it takes much more than that to design and build a project from scratch.

This used to suit me just fine, but recently I started feeling the desire to expand my knowledge. Hardware hacks are all well and good, but I was getting curious about more elaborate designs - specifically, components that could be programmed and instructed to do all sorts of interesting things. I wanted to know what made them tick, and how I could bend them to my will.

The HackedGadgets blog and DutchForce electronics forum might have had something to do with this.

It didn't take long to figure out that what I was really interested in were microcontrollers. It took a lot longer before I found the learning kit I wanted.

Buying a microcontroller is simplicity itself; just open up eBay and there are a million and one sellers ready to sell you microcontrollers of all kinds. Buying the support components is also easy, as they are generally common enough that you don't even need to order online.

But you need to know what system you want, and then you need the building instructions, and you need to learn some form of programming language, and you need the spec sheets and examples and whatnot.

Information about all of this is all available online for free, but I was having trouble finding a guide for any microcontroller system that was easy to understand and didn't assume pre-existing knowledge on my part.

Given enough patience you could probably put together enough information to get you from starting point to a working project without hurting your brain too much; I, however, don't have nearly enough patience.

So when I was contacted by the good people at NerdKits who had read my threads on the DutchForce board, knew I was looking for an easy starter kit and asked me if I wanted to review one of theirs, I was very happy indeed.

The NerdKit promised to be exactly what I needed. Simple construction, basic but functional operation, and a guide that explains everything you need to know. Most importantly, the kit is meant explicitly for people who don't know the first thing about microcontrollers, and want to learn from the basics.

So, does it deliver?

Let's find out.


Microcontrollers and you



Microcontrollers are basically tiny computers on a chip. While normal computers have separate components and a motherboard that lets them all talk to each other, a MCU (MicroController Unit) comes with everything it needs. Processor, RAM, flash storage and input/output peripherals are all integrated in the same chip package.

When you consider how much stuff is in them, it's surprising MCUs are so cheap, both to buy (they only cost a few bucks) and to run (they draw very little power even when compared to the least power-hungry computer CPUs).

You don't get anything like the performance of a modular microprocessor design, but you don't need it: most practical appliances only require very little processing power.

To put things in perspective, the processing power needed to kill Korean soldiers in a beautifully rendered landscape is about a zillion times more than it takes to run the International Space Station or control the Space Shuttle.

The things MCUs are normally used for (remote controls, toys, low-performance electronic gadgets and the like) require a lot less power than even that, so you can make do with processors running at clock frequencies as low as a few kilohertz. Which is good, because the average home probably contains several dozen of them. Anything you own that has a circuit board in it is very likely to be ran by at least one microcontroller, and probably more. The difference inbetween those and the general-purpose MCUs that hobbiysts and electronics enthusiasts use is that industrial ones are custom-made and tailored very specifically to the one job they have to do, and so can't be easily (or often at all) used for anything else.

General purpose MCUs, in contrast, can be used for a variety of purposes. Surf sites such as the aforementioned HackedGadgets or Make Blog and you're likely to see them used in such things as LED arrays, stepper motor drivers, robots, audio appliances, vehicle models, electronic pens, displays of all kinds, and yes, even videogames (don't expect anything resembling current-generation graphics).

So, they are nifty little things. But how do you make them useful? Well, that's what the Nerdkit teaches you.


The kit



The kit came in a large box filled for most of its volume by crumpled newspaper. This annoyed me, because large boxes are far more likely to be inspected and taxed by customs (as indeed mine was). Since everything inside the kit is entirely soild state, it'd be smarter to provide some sort of hard cover for the shock-sensitive items (the LCD display and the CD) and ship the kit in a padded envelope instead.

Contents of the box


I could list the contents of the box, but the NerdKits people have kindly done that already. Note that this is a USB NerdKit, not a serial one, so it comes with a serial-usb converter, a piezoelectric buzzer and a more powerful Atmel ATmega168 microcontroller (as opposed to the ATtiny26L in the serial version). The serial NerdKit has been out of stock for a while, so I'm not sure if it's ever going to be sold again. Not that it matters - unless it costs significantly less, there really isn't any reason to prefer it over the more performing USB one.

The first thing that caught my eye was the home-burned no-brand CD with its contents scribbled on with a marker. It doesn't exactly scream "professional product", but frankly I don't give two hoots what the CD looks like as long as its contents are good. The battery, in contrast, didn't please me. After paying $80 for the NerdKit you'd think it wouldn't kill them to give you a proper alkaline nine-volter instead of the carbon-zinc cheapie you get. Aside from that, the only other thing I think could be improved are the clip-on connectors. You're given two rubbery ones, but the hard ones made from tough plastic are easier to unplug. I happen to have a bag full of those, so I used mine instead.

Despite what the NerdKits page says, the LCD display does in fact have a backlight. The side connector doesn't get mentioned anywhere; when I asked about it to the NerdKits support service they confirmed it to be the wiring for the backlight, but they consider it an undocumented feature because apparently not all displays they send out have it. The backlight needs a dedicated power supply, but there isn't one on the LCD board; you have to build one yourself, following these instructions. I didn't bother.

The collective value of the hardware is, of course, a fraction of the actual price of the kit. But the true value of the NerdKit is not in the hardware itself: it's partly in having everything you need in one single order, and mostly in the teaching process.

The CD contains everything you need to set up your computer to work with the NerdKit, whether you use Windows, MacOS or Linux. It also contains pre-written code files for a few basic programs, "learning" versions of the same files that need to be filled in, and most importantly the PDF guide.

The guide is the key component of the Nerdkit. It has clear descriptions of everything you need to know, and teaches you all you need to go from zero to writing and running programs on your shiny new microcontroller.


Building it



Starting to build the NerdKit


Building the hardware part of the kit is relatively simple. The guide tells you everything very clearly; you simply cannot get a connection wrong if you follow it to the letter. It even explains how to strip wires. You aren't required to have an EeePC, by the way, but I find mine damn handy for this sort of stuff.

The solderless breadboard is a handy thing, making it possible to - in theory - build the kit without even knowing which end of a soldering iron to hold. The main chip comes pre-connected; everything else you simply need to push in the correct holes, and it'll stay in place.

The first components go in


The first step is to put on the board the power regulator (the small vertical chip on the right), whose task is to take anything it's given (from about 7 to 20 volts) and lower the voltage so the MCU is happy.

The ATMega168 can run from anywhere between 2.7 to 5.5 volts, so it would in principle be possible to just wire three AA cells and dispense with the regulator altogether. But since the rest of the components, and the guide, expect the circuit to be powered by the output from the regulator, screwups and malfunctions might occur if that's not the case. So just use it, OK?

Next the guide tells you to connect the oscillator (silver oval thing in the middle), which gives the MCU its working frequency (in this case 14 point something MHz). Then you connect the LCD display.

Since the LCD needs several connections to non-adjacent points on the breadboard, you don't get a simple plug-in connector for it. You get a rectangular plug instead, in which you poke the wires that then need to be inserted in the breadboard.

The guide tells you to tape the flat cable of the LCD to the bottom of the board, so it doesn't move around and you can do the connections without worrying about a sudden movement nullifying a lot of work. Tape, however, won't stick to the bottom of the board. There's a large piece of adhesive paper there, so you could peel off the protection and tape to the adhesive paper underneath, but then you'd be left with a large area of sticky paper with nothing on it that would catch dust and dirt and become a mess.

So I said "screw it" and applied my favourite part-fixing solution: liberal amounts of melt glue.

Attaching the LCD cable to the board


That cable is not coming off anytime soon. I melt-glued the power wires in place as well for added reliability, and then I carefully peeled the wires and made the connections as per the guide. Once the LCD is connected the MCU is capable of displaying output; to test that it works, there's a small program preloaded whose task is to display a "Congratulations! Your NerdKit hardware is OK" message. All you have to do is apply power.

So I did that, and waited for something to appear on the display. And waited some more, and some more still. After about a minute it was clear that something was amiss, as the LCD was displaying nothing at all.

So I double- and triple-checked all connections, pulled all the components and wires and reinserted them, tried another 9V battery on the off chance mine was a dud, and finally sacrificed a young virgin, painted in her blood a black-candle-tipped pentagon around the NerdKit and performed an elaborate satanic ritual. Through all that the kit stubbornly refused to work, causing me to repeatedly lapse into profanity.

Then I ran the NerdKit from my bench power supply, and its integrated ammeter gave a reading of 10 mA or so. This meant that the MCU was working, otherwise it wouldn't have drawn any power at all, so the fault was likely in the LCD. I disconnected the flat cable from the display and proceeded to probe all connections with a multimeter. Sure enough one of them was bad, and another one marginal.

Some wobbling of wires showed that two of the contacts inside the plug weren't snug enough, and one of them was so loose that the wire would not connect no matter how much I wiggled it around.

I solved the problem by thickening the affected wires with small blobs of solder and pushing the result inside the plug with pliers and considerable force. Now the display worked and indeed displayed the "congratulations" message...



...but the claim that the NerdKit was buildable without a soldering iron went out of the window.

This is not actually a serious problem, and I surmise anyone even mildly used to electronics work would eventually find the solution by themselves; however, anyone who isn't used (I remind you that the NerdKit is supposed to be buildable even by people who haven't so much as touched a wire stripper in their whole lives) would undoubtedly check the connections on the breadboard, determine they are all OK and then proceed to mail NerdKits support and ask for a replacement kit.

Next up comes enabling the MCU to be programmed. In order to do this you connect to the breadboard the programming header and a small switch, which depending on its position tells the MCU to execute the stored program or wait for a new program to be uploaded. You can then presumably connect the header straight to a serial port, but you're meant to use the supplied converter and connect it to a USB port.

Since I already had a usb-serial cable based on the same chipset as the one provided, I opted to use that instead, because it has a cord built-in. This allows me to avoid using the exceedingly crappy extension cord the provided converter comes with.



And that's pretty much it, as far as the hardware part is concerned.


The software



The NerdKit is programmed using the C programming language. You can't, of course, just send saved text files containing C programs to the MCU and expect it to understand them; they need to first be turned from human-undestandable text into processor-understandable machine code machine code. You do this by compiling them, the programs to do which are included in the NerdKits CD.

The NerdKit is more friendly to Linux than to the other operating systems. This was a good thing for me, because my work computer and EeePC both run Linux exclusively (as opposed to the gaming rig), but it's going to be a bit more fiddly for Windows users.

In Windows and Mac you need to install the cable drivers, then several programs from the CD (the mac package weighs several tens of megabytes), then open up the makefiles (files containing configuration data for the compiler) and change the settings so that the sender program sees the programming header and sends data to the correct port. You also need to use specific programs (again, provided in the CD) to edit the code. You can edit code on notepad, but the lines won't get colour-coded.

In Linux you just apt-get-install three tiny packages, edit the program in whatever prepackaged code-friendly editor comes with your distribution (if your distro is KDE-based KWrite works perfectly), then you position yourself in the folder containing the code and give the "make" command from the shell. And presto, the NerdKit gets reprogrammed.

Or not.

When I attempted that the first time the lights on the programming header didn't blink, I got an error message and then the NerdKit only displayed a single line of blank characters on the LCD (it does this when the MCU's memory doesn't contain a working program). At first I thought maybe the custom Linux distribution on my EeePC was doing something weird with the USB ports, so I tried with my notebook. No change.

Checking the connections and trying different ports also had no result, but strangely enough placing my hand on top of the programming header caused one of the lights to turn on, and the error I got on the computer changed.

This suggested RF interference problems. I was powering the kit off my lab power supply, but it didn't occur to me that that might have been a problem. Later on I was using the lab supply to power something else, so I had to use the battery to power the MCU as it got reprogrammed, and lo - it worked perfectly.

My power supply is a cheapo chinese unit whose build quality is low enough that the main panel is a bit skewed, so it doesn't surprise me that it's emitting awful amounts of RF interference; the wires probably act as antennas. Powering the NerdKit off a standard plugpack would probably not cause this issue.

Once I'd managed to get the MCU to accept new programs, it was time to write some programs to run on it.


Programming



C is a relatively intuitive programming language. Given enough time and enough source code, it's not inconceivable that one could learn the language by just analyzing the code line by line. Simple things like text messages can be changed just by modifying the relevant lines and saving the file, even if you know nothing about the rest of the program.



Heh heh.

But C is not BASIC; if you don't want to spend a whole lot of time scratching your head at stuff you don't understand, you want someone to teach you.

I was expecting the NerdKits guide to include an extensive tutorial about this; instead, it sends you over to the HowStuffWorks page about C.

The NerdKits guide covers many of the same topics later on...

The guide


...but I recommend reading the HSW guide regardless, since it's pretty good and programming is a complicated enough process that it can't hurt to read some of the concepts twice.

After you read the HSW guide and, presumably, learn the basics about C, the guide introduces you to bitwise operation, and then goes on to explain how to set up the analog-to-digital converter in the ATmega MCU, telling you to read the datasheet if you're curious to know more and providing a few links to online pages that explain some of the involved concepts in more detail.

I hit a bit of a snag on this. The guide tells you that if you have trouble understanding this stuff you can go on with the first program and read the more deatailed explanation later on, but I was determined not to let my capable mind be intimidated by all of that, and learn everything I could as soon as possible.

A significant amount of time spent poring over the datasheet and pages about analog-to-digital conversion and bitwise logic and whatnot convinced me that maybe intimidation wasn't so bad. My ego resized, I skipped the bitwise theory and went on with the program.

The first thing the guide teaches you to do is to turn the kit into a thermometer. To do this you install on the breadboard a tiny temperature sensor, then you write the program that tells the MCU to take the analog reading from said sensor and turn it into a digital temperature readout on the LCD.

The guide tells you not to copy-paste the code, but rather to write it yourself. I think this is a good idea; if you're serious about learning about MCUs and/or C you're gonna have to write a hell of a lot, so you might as well get used to it, and learn something in the process.

After writing about a hundred lines of code, while struggling every step of the way to understand the reason of every line I typed in, I finally had a finished program and at least a moderate understanding of how it worked.

I still had to fight with the code some more to catch a typo (of my doing) that was causing it to report bad values, and then it finally worked. The original program has a problem, though: it shows temperature in degrees Fahrenheit. Having measured temperature in degrees Celsius all my life, I of course have absolutely no idea what temperature a given Fahrenheit number represents. Yes, Google helps, but keeping a webpage with Google permanently opened near your digital themometer is not my idea of practicality.

So I used my newfound knowledge of C to solve the problem at the source.

I added a variable that converted the existing value into Celsius, and modified the rest of the program so that it printed that on the LCD instead. I could have just changed the way the original value is calculated and obtained slightly more efficient code; however, I wanted to leave open the possibility of adding a switch to select °F or °C at will. In the end I never bothered doing that because I have no use for °F readings, but the possibility is there.



I was quite proud of myself when the kit showed the temperature in degrees Celsius. The modification I did is only slightly trickier than just changing lines of text, but it's not simply a find-the-text-and-change-it proposition. The temperature conversion requires you to understand how the variables work, or you're not going to know what to change.

In case you too want a Celsius thermo-NerdKit, here's the modified program. Don't just upload it - have a look at it to learn how I modified it.

After the thermometer project the guide goes on to the bit adder, whose main purpose is to teach you bitwise arithmetic and registers on the MCU. You need to add to the breadboard the block of seven dip switches that you're given with the NerdKit, then back to programming you go.

Programming the bit adder is significantly harder than the thermometer. This is because you're required to learn a fair bit about the aforementioned subjects, which are sadly not at all easy to understand. Well, not for me, anyway; a more mathematically inclined person would probably have significantly less trouble grasping the basic concepts.

The guide really has no fault in this; the concepts themselves are tricky (a fact that's explicitly stated in the guide, by the way), and you can't expect to learn them without your brain hurting a bit (or a lot, as the case may be).

After all this struggling, the end result basically allows you to set two 3-bit numbers using the dip switches, and the MCU will add them for you. Unimpressive, you say? Well, yeah, it's entirely useless from a practical point of view; however, once you've learned to program the bit adder and make it work, you've learned how to let the MCU talk to other components by setting and reading pins, which is absolutely essential in working with microcontrollers.

At this point the guide goes on a bit more about registers, and then is pretty much done. As it should be; by this time you should know enough to figure out the last program (which lights six coloured LEDs with a "traffic lights" pattern) by yourself, and then to start creating programs on your own.

I should probably mention that I haven't yet gotten to that point myself; my skull is proving thicker than I'd foreseen, with the result that I'm still struggling with bitwise arithmetic. I'll repeat that this is not a fault of the guide; I've Googled pages upon pages about the subject, and none of them has quickened the painfully slow learning process that seems all my brain is capable of when maths is concerned.

However, in the interest of completing the review before the coming of the next ice age, I've decided to leave it at that. I'll update the review when if I manage to unstick my brain and actually write some interesting programs by myself.


Uses of a NerdKit



Some of you may be wondering what good is a thermometer made up of a mix of discrete components and controlled by a general-purpose MCU when you can get a dedicated one for a few bucks in any pharmacy.

The answer lays in the versatility of the general-purpose system. Want the thermometer to sound a buzzer if the temperature goes over (or under) a certain degree? Can do (you can in fact do this with the parts you get in the NerdKit). Want to stick it in the fridge so if the temperature goes too high it warns you of your dangerously warming beer with an air raid siren and a HID-based bat-sign-like beam of light in the sky? Well, you'd need to spend a whole lot of money for the signalers and heavy-duty relais switches, but then the resulting contraption could easily be controlled by a small MCU system such as a NerdKit.

Not that I recommend waking up your entire city and dazzling passing jetliners just so you can notice the alarm from your office, of course, but you get the idea.

Not many other things can be done with the parts from the nerdkits alone; you can build a random number generator (as seen here), data displays and small-scale decorative lightning things/mood lights (using the available six coloured LEDs), but that's pretty much it.

It doesn't take much to vastly increase the kit's potential, though. Add a few high-intensity white 5mm LEDs, for instance, and you can build a portable light source with as many modes of operation as you want. You can't use high-flux LEDs such as Crees or SSCs without MOSFETs and a dedicated power source (because the MCU cannot by itself deliver enough current), but if you get those you can build something like a Philips LivingColors lamp with the features and power limited only by your imagination (and the amount of money you're willing to spend on it).

Got a bunch of hard drive motors sitting around that you can't use for anything since their driving circuitry has long died, or won't work without a data connection? Build yourself a NerdKit brushless driver. Pulse the laser module from a cheap pointer for medium-distance data transmission (you'd need another rig with a sensor for the receiver though). Connect a few aquarium pumps and a few humidity sensors and design your own plant irrigation system. Wire up a high-flux IR LED behind an aspheric lens and build a universal IR remote that can control appliances on the other side of your city block (yes, I am thinking of a mammoth TV-B-Gone). And this is without going into the field of amateur robotics; everything is controlled by MCUs there.


Should you need more ideas, a vast amount of information on all sorts of microcontroller projects is just a Google search away.

Given enough practice and experience, both of which you'll eventually achieve if you're serious about learning MCUs, your imagination's the only limit.


Conclusions



If you don't want to, or aren't able to, understand mathematics, do not attempt to get into microcontrollers.

I'm serious. There is no completely painless way of doing this; it's not one of those things that you try and try until you eventually get a bright flash of realization and it's all plain sailing from there.

Do not expect a NerdKit, or any other kit for that matter, to get you programming in no time after just a quick read of the guide. Learning microcontrollers is hard and requires time, and whatever help you get you still need to apply a fair amount of brain power if you hope to accomplish anything.

But if you are willing to let your neurons work, then a NerdKit is a very good introduction to the world of MCUs. The basic components give you enough to do useful things, it takes very little additional hardware to do a lot more than that, and I'm fairly sure the guide simplifies the learning process as much as humanly possible.

Also, the guide is liberally interspersed with invitations to contact the support service if you have any questions or suggestions, and when I did their replies were quite speedy. This shows a willingness to improve the guide and help the users that I've seldom seen in other products, and is a significant point in their favour.

As far as I'm concerned, even though I haven't yet fully grasped bitwise arithmetic, I've still learned a lot about programming, MCUs and how they work. I'm pretty sure I'm not over the "too mathematically dumb to ever accomplish anything with MCUs" limit (though probably dangerously close), so I intend to keep banging my head against the necessary notions until I eventually manage to get the critical bits inside. If this ever results in me coming up with a program that does something useful and that I think other people might want, I'll be sure to add it to this page.

So, now you have the whole picture. The NerdKit isn't a great deal for everybody, but for those who have the right mindset it's really quite good. If you're in that category, you should go and get one.


COMMENTS Add yours
No comments for this article