Saturday, January 28 2012

News

From the Trenches: Embedded Platform Work

I’m tinkering with a new platform for my embedded projects, based on the NXP LPC1768, which is an ARM Cortex-M3 chip.

I picked up an eval board (the Blueboard LPC1768-H) back in late 2010.  The board is nothing to write home about, and has some design choices that I seriously question (like non-0.100″ aligned headers… Really guys?  I thought it was just the Arduino that made this foolish error).  However, it was cheap, and it has the basics for getting something up and running easily with fewer unknowns that diving right into a custom design.

When I first got the board, I got a basic build environment running on Windows using the CodeSourcery Lite GNU compiler port, with Eclipse as an IDE.  At the time, I had no debugging capabilities, but the LPC17xx series has a built in serial bootloader, which allows one to program the flash memory (but not debug) over a plain old serial port.  You use a tool like FlashMagic to speak the bootloader protocol, which is fine, but you’re basically stuck in burn-and-learn mode with this kind of setup unless you integrate a debugger/monitor into your code.  If you have some working examples to start with, a lot of patience, and don’t venture too far off the beaten path, you can make this work.  However, ARMs are complicated processors, at least when compared to good old 8-bit microcontrollers.  Just to give you some idea, the LPC17xx user manual is over 800 pages long.  Good bedtime reading.

So, the project got thrown onto the back burner shortly after I got code compiling and running, but hit a wall with an interrupt vector issue, and I had no way to debug it easily.  I ran out of patience and moved on.  Flash forward to now, when I have a rekindled interest in spinning PC boards and tinkering with electronics stuff in my spare time.  A bit of luck turned up a JTAGkey in-circuit debugger from Amontec sitting unused in a box at work.  A quick check confirmed it should work with the LPC17xx.

The last time I did anything serious on a smaller-scale ARM (i.e., not the big-boy ARM micros like the Sitara Cortex A8, on which running Linux is possible), I was using the commercial Keil MDK.  This includes everything in one package: compiler, IDE, debugger hardware, RTOS, etc. This is fine for a commercial project, but it’s cost-prohibitive for hobbyists.  As mentioned before, I had found some good free alternatives for the compiler and an IDE (though a text editor and Makefiles work just fine too).  The final piece of the puzzle came not only with finding the JTAGkey hardware, but also running across OpenOCD, which is an open source package that actually drives various JTAG interfaces and lets you do gdb style debugging either via command line or through Eclipse.

So I’ve been working on putting all of the bits and pieces of software together to make a working build and debug environment.  It’s not easy – it’s definitely not plug and play by any means.  After a bunch of pretty intense hours, I have partially working environments on both Linux and Windows, but I’m still sorting out details.  As of this evening I’m finally able to see the first signs of life working through the debugger, and have stepped through a handful of lines of code through the Eclipse debug interface, before it explodes and faults in a libc setup routine.  I *can* program the flash chip on the part and run the code just fine without a debugger.  Baby steps, I guess.

In working on this stuff so far, I’ve tried out a couple of different pre-built toolchains for ARM.  One was Yagarto, which did seem to build code, but is not available for Linux.  I find this a bit weird, since the GNU toolchain originated in a Unix environment, and to have something that is repackaged GNU code be Windows-only is just strange.  In my quest to find something more Linux-friendly, I found out that newer versions of Ubuntu have access to gcc-arm-linux-gnueabi packages. Unfortunately, I also discovered that these packages were not available directly in Ubuntu 10.04 LTS (long-term-support), but there were backports available from Linaro.   Unfortunately, gdb seemed to be missing in action, so that pushed me back to CodeSourcery, which is probably where I should have started to begin with.  I briefly tried Ubuntu 11 to see if the newer packages were any better, Unity made my skin crawl. I deleted that virtual machine with extreme prejudice.

Another headache was dealing with the FTDI USB driver situation to get OpenOCD running on Linux.  Many of the available JTAG debuggers are based around this chip, but the drivers from FTDI are only free-as-in-beer, but not free-as-in-speech.  This of course irks the open source people to no end, so there’s an open source alternative that’s perhaps not fully baked that is available.  I tried running with the open-source drivers, the closed-source drivers, and probably accidentally, combinations in between.  Currently, my best working setup is running OpenOCD on my Windows host, with the open source libusb layer drivers replacing the FTDI drivers.  Because OpenOCD works over a TCP/IP socket (more or less just like regular old remote gdb debugging if you’ve ever done that), I can connect the tools running in my virtual machine back up to the host over the network with no problems.  However, I have at least had some success with various combinations, and it all deserves more attention as the project progresses.

I’ve currently got it working the furthest on a Windows 7 host with a Windows XP virtual machine guest. My ultimate hope is to be able to get it all running under Linux, so I can make a virtual machine image with everything needed on it and hand it out to some of my closer programmer friends who might want to give embedded development a try on something a little more “real” than an Arduino.  And you can bet that I have some plans brewing for some new PC board designs centered around this (or similar) ARM processors.

More as it happens!


2 comments

The Hammer

I thought I’d try to get one more design into the January 23 Laen PCB order.  For the new CNC electronics setup, I’m going to be using a 3.5″ form factor Atom PC motherboard.  It unfortunately does not have a parallel port, which I need to talk to the FPGA card.  However, the board does have a PCI Express connector, so an add-in parallel card can be used.  Unfortunately, there are two issues: I don’t want the add-in card to be vertical (perpendicular), and also also I don’t want the rear panel connector to actually poke out the back of the enclosure like a normal add-in card would.

There are commercial riser cards that would solve the vertical board issue, but they don’t solve the rear panel issue.  Hmm.  Poking around in my box of parts samples, I noticed I had a few PCI Express connectors.  With cheap PCB layout available to me, why not try to make my own riser card?

PCI Express differs from old school PCI in that it’s based on high speed differential signalling instead of parallel buses.  The upside is that the connectors are much smaller and there are fewer lines to route.  The downside is that they’re critical lines, and need to be routed carefully.  Now, to be honest I’m out of my electrical engineering depth a bit with this stuff – it’s beyond anything I’ve done in my studies, for work, or for fun.  However, I’m somewhat bolstered by having tried a cheap $5 PCI express extender that used 6″ ribbon cables, and it ran my card just fine.  I figured if I at least pay some attention to the critical PCIe lane signals, it should work reasonably well.

In a 1X PCIe connector, there are three differential signal pairs to pay attention to.  I used the differential routing tools in my PCB layout package, which guide you in keeping the pairs routed equidistant from one another according to rules you set up.  I also used the tools to match the lengths of the differential pairs.  This produces something you may have seen on PC motherboards and other modern equipment:  the crazy looking wiggly traces.

So, I present a bit of an experiment.  I call it “THE HAMMER” because of its shape.  It’s a PCIe 1x riser card with a “layback” to pull the rear of board away from the back panel of the motherboard.


Leave a comment

Final PCB for the CNC Done (for now…)

Finished my fourth board in as many weeks, finishing off the bare minimum of boards I need to get the CNC mill back up and running.

This board mounts inside the machine itself, and connects via a cable back to the main PCB in the control. This board connects via screw terminals to the various homing and index sensors inside the mill, provides a little bit of signal conditioning, and converts to differential signalling for transmission over a long cable run near noisy stepper drive cables.

I expect this will not be the last board I do for the conversion, since there are other projects to tackle like the control pendant and spindle index sensor, but these four boards should at least allow me to get the mill back up and running, using my fancy new FPGA driver board, and with proper emergency stop capability!  It’ll be nice to tidy up the wiring and finally bolt down the components inside of the control box as well.


Leave a comment

New Song Demo

Since this is ostensibly an audio blog, I figured maybe it’d be good to occasionally post some audio.  Here’s a rough song demo that I recorded over the weekend that I call Stratagem Fourteen.  I play drums/bass/guitar.  Mix is rough and mastering is nonexistent, but you’ll get the idea.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.


Leave a comment

Soldering Techniques from Youtube

Ran across this:


4 comments

First pcb.laen.org PCBs Received!

Three boards.  The side with the serial # field is the top. A sparkly purple metallic bubble wrap package was waiting for me in the mailbox this evening when I arrived home.  I knew that it had to be the boards that I sent out back on January 2, arriving just a few days over the ~2 week time generally predicted by Laen.  The quality of the boards is excellent!  As promised, three boards of my design were delivered, and as an extra gift, Laen has thrown in one of his clever SMT-to-DIP adapter boards, which I’m sure will come in handy for some future prototyping project.  Thanks, Laen!  The boards are gold plated, deep purple soldermask (his “trademark”), and do have some leftover tabs which I can easily sand off with the belt sander.

Unfortunately this design is seriously boring in terms of function – it’s just a wiring adapter.  However, it represents the first PCB that I’ve had made in about ten years, and no matter what, it’s always cool to hold in your hand something that previously existed only on the computer screen.

My second board should follow along in about another week.  The third, and large board is a bit of a mystery, as I haven’t been able to get in touch with Laen to verify the board is in the next order, or pay him.  And, of course, today the dorkbotpdx site is black in protest of SOPA/PIPA.  Hopefully he’ll catch up on his email soon!


Leave a comment

CNC Breakout Board Done

My latest board is designed, laid out, and hopefully safely in the hands of Laen over at Dorkbot PDX.

This is the main “breakout” board for the CNC electronics cleanup.  It connects to my fancy new Mesa Anything I/O FPGA interface card, and provides some protection and signal conditioning before connecting to the myriad of things that are needed to run the CNC mill: stepper drivers, spindle motor control, homing switches and other sensors, and the emergency stop circuits.

The size of this board is 4.000″ x 4.000″, and at Laen’s rates, it’s still fairly cheap – $80 – but it starts to be “real money” instead of $5 or $20.  Still, other than the other batch fabricators (most of which manufacture in China, under considerably less strict environmental regulations), you can’t get boards done this cheaply.  I think this is probably nearing the knee in the curve in terms of board area/cost for Laen’s service.  It’s a total no-brainer for small boards – there is pretty much no longer any excuse to hand-wire small stuff these days unless you really need it right that minute.  Laen’s service also has a lot of high end options that are hard to get at an affordable price from elsewhere: any board shape you want (routing), RoHS lead-free, ENIG gold plating (much of the time, apparently), 6/6 trace/space, 13 mil minimum hole size, high quality fab process, silk and solder mask top and bottom, etc.

Here it is in all of its technicolor glory.  I forgot how much of a pain it is to route 2 layer boards, especially power distribution.  With some creativity I managed to do it with some copper pours: the bottom of the board is all GND, and the top has an “L” shape of GND pour and the rest is VCC.  Will it perform as well as a 4 layer board?  Heck no.


Leave a comment

Another PCB Sent to Fab

I’ve completed the design and layout for another PC board, all part of the CNC milling machine electronics cleanup project.  This one is a nicer version of the isolated PWM to +/-10VDC output circuit, which I had prototyped on perfboard a couple weeks ago.  This circuit is used to drive a fancy KBMG-212D DC motor driver that I scored off of Ebay, and replaces the junky controller that runs the spindle of the milling machine.

The circuit allows the controlling PC to control spindle speed and direction by outputting three signals.  The first two are a “bipolar” PWM signal – one signal is active when the spindle speed value is negative, and the other is active when it’s positive.  The other output is simply an enable output that turns the spindle on and off.  The whole circuit has to be isolated because the DC motor drive is at a high voltage potential with respect to ground, and direct connection to electronics connected to a PC would make “exciting” things happen.  It’s annoying that they don’t just include some isolation on the motor drive, but it seems to be common practice not to.

The circuit is fairly simple.  An isolated DC-DC converter brick is used to generate +/-12V rails from 9-18VDC input.  Schmitt output optisolators are used to isolate the PC control signals from the rest of the circuit.  On the isolated side, the PWM signals are each filtered with a simple R-C filter and buffered by an op-amp follower circuit.  The “negative” filtered PWM goes through another op amp in inverting configuration to flip the signal around.  Finally, the “positive” buffered/filtered PWM is mixed with the output of the inverting op amp to add in the “negative” signal.  A couple of trimmers are used to adjust offsets.

The prototype design isn’t perfect, especially in terms of accuracy, but since I’m planning to put the spindle speed into a servo loop controlled by EMC, I don’t think it will matter very much.  I chalk it up mostly to my rusty skills and lack of experience doing analog design.  I did a nice compact PCB layout which stuffs components onto both sides, and is intended to plug directly into the control terminal block on the motor drive.  I sent it off to the DorkBot guy, and it cost a whopping $16.25 to have three of them made.  For small board sizes, it’s just incredible to get professional boards done for this kind of price.

The actual size is a bit smaller than a business card.  Here’s a picture of the artwork: red is the top side, blue is the bottom side.

Spindle Drive PDF file with schematic.


Leave a comment

2012… A New Year of Collaboration?

The new year is upon us, and the hangover from seeing 2011 in the rear view mirror is still tenaciously clinging on.  The new year is a good excuse to think about goals that have been met in the last year, and to dream up new ones for the coming year and beyond.  This post is about the latter.

Most anyone that knows me knows that I keep myself busy with a lot of different creative interests and self-guided learning.  This is so woven into my being that I consider it to be one of the most important aspects of my personality.  However, most of my endeavors tend to be solo efforts these days.  Sometimes that is by choice, but not always.  The older I get, the more I have begun to appreciate that I know a lot of very bright people, and that I don’t (and can’t, and won’t) know everything there is to know about everything.  I know a lot of stuff about a lot of random things, and I have varying amounts of skills and abilities in random areas as well.  I think this is true of most of you.

I’ve come to realize that something I’m missing in my life is collaboration.  It’s all well and good that I pursue my interests solo some of the time, but I am now aware that there is a critical piece missing, and that’s working together with others on projects and endeavors.  There was ample and frequent opportunity for collaboration in the college theater days, when many of us would come together with complementary skill sets, and pull off the seemingly impossible in a short period of time.  I’ve been in bands in the past, where the creative musical output was beyond the sum of its parts.  I miss these things.

So, my door is open.  Let’s talk about interesting things that you want to do.  It might involve CNC machining, or wood working, or electronics, or software, or making music or videos.  Maybe it’s something totally different.  Share your ideas and let’s see if we can make something happen.

I know many of you have schedules that are packed full.  You have family and career obligations, many of you have kids, and there just are not a lot of hours in the day left over after all of that.   It may seem impossible to collaborate on projects due to schedule conflicts and a million other things that need to be done.  However, I know this creative and collaborative urge is there within many of you, and I am willing to bet it hasn’t gone away just because your lives have become busier.  So let’s use our significant combined brainpower, as well as the variety of technologies that are now available to us (e.g. blogs, forums, email, YouTube, Skype, Google Plus Hangouts etc.) and think outside of the box. Let’s do something. Anything.  We can start small, and see where it goes.

A big source of inspiration has been immersing myself in the video feeds from The Geek Group, who are a sort of hackerspace on steroids.  They claim that they are the world’s largest group of their kind, and that they have members in all 50 states and a whole slew of countries around the world.  They exist in impressive physical form in their fourth iteration facility in Grand Rapids, MI, in an old YMCA building that they have since bought and have been renovating themselves for just over a year.  Their facility is a mix of CNC machine shop, auto shop, wood shop, high voltage experimentation lab, electronics lab, computer science lab, video production facility, music studio, etc.  It’s cool stuff, and they’ve got a pretty cool charter, allowing people to learn stuff they’re sincerely interested in learning.

You can check out their main YouTube channel, or the personal daily video blog channel of their founder and president, Chris Boden, who is a bit of a character as you’ll see.  Below you can check out a recent video of them giving a tour of their building.


1 comment

Shaking off the Rust

It’s been a long, long time since I’ve done a PC board layout.  Like, probably on the order of ten years.  I think I may have done one design for work somewhere in the last ten years, but as far as I remember, the last thing I did for my own edification was the 6-layer CAVE MP3 player main control board.

It’s winter time now, and my attentions have turned from being outside on the bike to tinkering in the shop again.  The CNC milling machine conversion has long since had a very temporary and ratty wiring situation.  It was good enough to get it up and running, but it’s kind of an embarassment.  It’s time to clean it up and do it properly, and also implement some new stuff along the way.

One cool thing that has changed in recent years is the availability of so-called “batch PCB” outfits, which are aimed at hobbyists.  They take a bunch of hobbyist PCB designs, stick them all together on one pallet and send them out to be made.  Generally for smaller boards, this ends up being very inexpensive, even compared to the formerly affordable prices that companies like Advanced Circuits pioneered a decade ago.

These batch PCB places tend not to have setup fees, and are optimized for simple, low-tech 2 layer boards.  Many of them send out the boards to China to be made, and it ends up taking several weeks to get them back.  Ladyada has a nice list of different places that are available, with a review of each.  I decided to give the Dorkbot batch PCB service a try, since the boards are domestically made and look to be of high quality.

Since it’s been ages since I’ve done a layout, I figured I should start with something dirt simple and small to make sure I remember the workflow and can still produce valid Gerber output.  So, here I present the first small utility board in getting the CNC wiring under control: a small breakout that connects to the low voltage control terminals on the GeckoDrive stepper drivers that I use, and converts to a 10 pin dual header with lots of interspersed grounds.  When I design the breakout board which will contain the bulk of the electronics, it will have several of these 10 pin headers on it, for connecting to up to 6 (probably) stepper drivers.  My hope is to be able to run the mill with accessories like a rotary table or a tool changer, or possibly also run the lathe from the same control.

So this board is tiny. It’s just a hair over 1 square inch, which means it’ll cost me a whopping $5.25 to have 3 of these boards made.  It’ll take a couple weeks, but what the heck?

Note: trying out an embedded Gerber viewer from Circuit People below!


3 comments