Tuesday, March 27, 2012


I have a new favorite microcontroller: the LPC2368. It programs similar to the LPC2148 but is much more "digital" and much less "analog". It has four UARTs, three SPI ports, three I2C ports, something called I2S, two CAN ports (maybe I can talk to my car, or more like listen to it), two USBs, an ethernet port(!) and so on and so on. One big deal is a hardware SD/MMC port. My previous new love was the 2468, but that one has 208 pins and probably wouldn't fit on the Logomatic footprint, much less the stick IMUinator.

This guy has exactly 100 pins. The one big feature that the 2368 lacks is an external memory interface. That and a lot more GPIO pins. For two main reasons, the 2368 is more convenient to work with than the 2148:
  1. More pins means less overlap between functions. Several of the peripherals have dedicated pins (Ethernet, one I2C) so there is no problem with overlap. PWM and UART still overlap, but there are enough pins and two choices for each overlap that you can use all 6 PWMs and all of the UARTS.
  2. Fewer analog inputs, so those don't take as many pins.
The last is the only place where a 2148 is superior. The '2368 has six A/D inputs, but I use one of them for battery voltage, one for current, one for reference, and one is covered up by the USB Vbus input, leaving only two for use. You can sacrifice the voltage reference to get another channel, and I should think about doing the same for battery level and current sensing. It may also be possible to use another plain GPIO pin as Vbus, freeing up another A/D.

All the sensors I plan on using now and in the future are digital anyway, so to me, losing A/D is no big loss.

Also, all the peripherals except I2C have DMA, which I think means you can hand them a big block of data (or tell them to listen for a big block of data) and then the peripheral will take care of itself, while the core continues its programs. No more busy waits for the SD card.

I am working on a Loginator2368 which is increasingly less pin-compatible with the Loginator, but still roughly the same shape and size. Who knows if it can be made to fit on a Stick IMUinator?

Friday, March 2, 2012


I lifted, or burned up and buried in burnt rosin is more like, one of the pads that I needed to connect one of the short green wires to, across U601, so that the USB could listen to the ATmega. Double drat. I NEED that connection.

Well, I start doing an inventory in my mind... I have an extra copy of this board, enough of almost all the parts I need, and a hot air rework to pull parts off of the old board. I have everything I need to build a new copy of the top board (with all the logic on it, not the LEDs yet). The only thing I lack is another FT232, and that is easy enough to get from Sparkfun. I don't buy them out this time (and they restocked their ATmega's the same day).

A little of this, a smidgen of that, find the old parts template, and boom. No, it didn't explode, it in fact worked after I changed the software to use the right lines.

Here's what I have learned so far about surface mount soldering:

  1. It is possible! Really, you can do it.
  2. It's harder than it looks.
My process is as follows. First, design the board, send the .brd file to Laen and send a gerber of the cream layer to Pololu. Yes, you want a stencil. Yes, even for one board. Also make sure you have all the electronics you are going to use.

After the parts arrive, including the components you are going to place, gather everything up. I like to make two sets of paper documents. One is a placement sheet, showing where each component goes. I make Eagle make me an .svg file, then suck it into Inkscape. A bit of cleanup, then highlight all of one kind of component, say all the 100nF 0402 capacitors. Then, make a copy of the drawing, lowlight the highlighted parts from the previous step, then highlight the parts from the next step. There were 24 steps on the Loginator, and each part went from gray to white to black in turn, until all the parts were black.

The other one I do by hand with a pencil. I draw a grid on a clean sheet paper, with the same number of cells as there are steps above. I then get the right number of each component from my stores, and put them in the right square for the step.

For stores, I have one of those plastic boxes with lots of little drawers. It has 6 columns and 10 rows, for a total of 60. Each drawer has a divider, so I could store up to 120 different kinds of parts. I number the drawers from 0 to 59, and label the front half A and the back half B. I have a spreadsheet inventory, but it is gradually going out of sync, mostly as I use parts.

Anyway, I number the boxes, and write the value, package, schematic part number, and drawer, in the corners of each box. The drawer is so that I know where to get another 0402 capacitor after one springs out of my tweezers on a magical voyage through space and time, never to be seen again.

After all the parts are out, it is time to stencil. Pololu stencils come as an 8.5x11 sheet of plastic. DO NOT cut the stencil! Big is OK. I made a mistake and cut the middle part out of the Precision stencil. Small sheets of plastic tend to curl and lift off the board, making things hard to work with.

Now, a tip from the guys at Sparkfun. Tape a couple of old circuit boards to your bench, such that your new board is framed and immobilized. Two is usually enough for a rectangle, but for the circular board for Precision, I used three rectangles. Now CAREFULLY lay your non-cut stencil on the board. I'm right handed, so I securely hold the stencil down with my left hand. Even with a transparent plastic stencil, it is easy to see when the stencil is perfectly lined up. Make sure that the stencil is lined up with the pads on diagonally opposite corners simultaneously. Also make sure that you are looking straight down on the stencil. Stand up if you have to.

I use a square-nose X-acto blade as my squeegee. It's about half an inch wide. I get my soldering paste in a syringe, but had no luck with the tips, so I just uncork the syringe and squeeze some out on one end of the stencil. Careful here, solder paste is so viscous that it keeps coming out for a little while after you stop squeezing it. Now I use the X-acto blade to spread the paste out. Press hard enough that most of the paste is carried along, and the stencil is mostly clean and transparent after the blade passes. Make sure that all the holes are filled. Sometimes they are easy to miss, and sometimes they are so big that one pass doesn't fill the holes. Don't be afraid to make multiple passes.

Now use your right hand to pull the stencil tight. This will lift it straight up off the board. Lift with your right hand until you are sure you are well clear of the board. Only then can you move your left hand. If everything went well, you should have a nice little square box of solder paste sitting on top of each pad. If not so well, use some rubbing alcohol to clean the board and do it again. The solder paste doesn't have to be exactly in the middle of each pad, but it isn't good to have a bridge either.

Now, use some sharp tweezers to place each part. For me, especially on the small 0402 parts, they invariably end up sticking to the tweezers, and I use this to my advantage. I can pick up a part, then let the tweezer tips separate. The part will stick to one and not fall off, so I use just that tip. I place the part all the way down, so that the solder paste sticks more to the part and pulls it off my tweezers.

For larger parts, I usually drop them from about 1mm up, then gently nudge the part as needed for accuracy. Precision counts! Align things up as well as you can, to avoid bridges.

Once all the parts are placed, it's time to bake. I am using a convection toaster oven which can get to 230°C (425°F) without turning on the broiler. That isn't really as hot as I wanted, but the EP256 solder paste I have has a peak of 210-225°C, so it's probably alright. I got convection because I really want to do the soldering with hot air, not direct radiation. Hot air will get heat sinks as hot as the boards, maybe hotter.

This is the exact procedure I use. Once a board is stuffed, it is put on top of the small cookie sheet that came with the oven. I put the rack in the middle, and put the board as close to the convection fan as I can. The temperature dial is set at 450°F and the timer is set to "Stay on" which turns the oven on.  So, I watch for the solder to melt, which is a very visible and sharp change from dull gray to quicksilver. I then count to 20, then open the door and turn the oven off. This consistently takes 5 minutes 20 seconds.

Now it's off to the microscope to check all the connections visually. This isn't conclusive, it finds bridges but not disconnects. So, I use the schematic and board layout to check continuity between each of the 32 ATmega pins and where they are supposed to be going. All the charlieplex pins should have 47 ohms from the ATmega to the Q signals, since they are going through one current limiting resistors.

Now for the green wires. One from D11 to P01, to the corner of one of the resistor packs. That is a very small target to solder, so I have to use the stiffness of the wire to hold it in the right spot (basically use the wire itself as the third hand to hold it). D13 goes to P16, also a corner. On this second copy, the 10k resistor pack didn't solder on one whole side, and I lifted the whole component (but not any pads) trying to fix it, so I put in PTH resistors between the through-holes on the side. Now that I think about it, it is good that part did lift, since D11 and D13 were being pulled up by those resistors. Only reset and D12 need to be pulled up now.

Do the same Arduino bootloader as last time. Oh drat, the red light doesn't blink. Not worth fixing, I probably got that one backwards.
I got the green wire soldered to the corner resistor P01... once. It was looking awful fragile and hanging-by-a-thread-like, so I smothered it with hot glue to hold it in place. Guess what... So, now I have two 100Ohm resistors twisted together to approximate 47 ohms, soldered directly from D11 to Q01. P16 is still hanging on, under it's blob of glue. It's ugly, and definitely does not have the Ipod-like  polish I am looking for, but it works, and confirms that the next spin of the board will work.

Once the software is ready to use the new pins, the charlieplex works! I think that these 17 60 lights excercise all of the signals, so everything is great! The little out-of-turn pulses I think will go away as I install more lights and complete the Charlieplex.