So now we’re getting into the nitty gritty: time to put this sucker together! I actually really like soldering. It’s kind of like knitting. You put your soldering iron on a TV tray, turn on the Price is Right and some soap operas, and make wonderful Christmas presents.
As promised, here’s the top side and bottom side of the 2-layer PCB returned from Sunstone Circuits. I usually go without silkscreen and solder mask (the green coating on PCBs) because it’s cheaper and a little more convenient to solder patches onto.
The best way to test a new circuit board is to assemble and test one section of the circuit at a time. Of course, I never do this. But you should. If you haven’t noticed so far, I have no issue using hypocrisy to control others actions. I’ll make a great politician someday.
The alternate method that I more typically use is that I will cut traces on the board using an Xacto knife and then put a dab of solder over the cut when I get ready to test it. Sometimes it works well, sometimes I end up doing a lot of cutting, fixing, cutting, and fixing … kind of a Michael Scott/Jan Levinson relationship goin on with my boards, snip snap, snip snap …
On this particular project I did a blended approach of the above – I did a few things at a time, and some cutting as necessary. The first thing you want to solder on is the voltage regulators and associated passives. Check to make sure you get the voltages you expect with a voltmeter, because if you don’t it could be the end for any chips attached to that voltage rail.
What’s that? VR4, you say? Where’s that on the schematic? Well, it turns out I didn’t do a great job of specing VR2. For a while, whenever the XBee transmitted a packet, it would reset the GPS. Undervoltage! It couldn’t source the current needed when transmitting. So I cut Vcc loose from the XBee and tacked on an extra LDO regulator to provide power for it since it draws more current than anything else. This seemed to fix the problem. Snip, snap, snip, snap…
The LCD datasheet recommends two separated 3.3V voltage rails, one shared with VCC and one for internal needs, on top of a 6.8V white LED backlight voltage. The TPS61040 boost regulator worked great for this source.
Next I soldered on the MCU, LEDs, the XBee module, the GPS connector, and all the associated passives. Touch bases with Starfleet Command by writing a quick program to test that the microcontroller is running. The best test is the “blinky” test. If you get the LED to turn on and off, you’ve got things going for you. If you don’t get a blink or if you notice your one second toggle is actually eight seconds, check the MCU fuse bits. Shorted crystal leads is typical if you fail to get anything, or check the “divide clock by 8” fuse bit if you get an 8-second “1-second” blink. Alternately, check that time has not been scaled by LHC tests.
I’ll mention some about the programming, etc., but if it feels like I’m talking about it briefly, it’s because I am. The next blog topic is programming, where I’ll dive into the programming details, fuse bits, chip communication protocols, etc.
The XBee was the first part to get going. It’s even easier than a MAX232 chip. Just connect the UART lines up and start sending bytes. Whatever you get on one end, you get on all the others (at least in out of the box configuration). So it’s really great for diagnosing problems early on. On the other end, I’ve got another XBee chip connected to my computer through an FTDI UART-USB chip.
After I got the XBee transmitting and receiving (transceiving?), I programmed a UART based bootl0ader into the Mega128. BASCOM-AVR provides a very easy to use and easy to modify bootloader that receives programs via XModem. It works like a charm with only slight modifications (baud rate set to 38400). A bootloader acts like a separate program whose sole function is to copy the main program into Flash memory. It runs at startup, or if called from the main program, and checks to see if it is receiving the a particular byte sequence. If yes, it does it’s thang. If not, then it just calls the main program. This speeds up development time a billion, because I can reprogram it anywhere. From across the house or across the street even. Kinda fancy, yeah?
Next, I checked reception on the GPS. Since the Mega128 has two UARTs, I used one for XBee and one for GPS. The GPS transmits NMEA strings, which provides localization information. This one was pretty straightforward, just parse the GPRMC sentence to extra heading, latitude, and longitude info. And it can be simplified if you assume it’s only used in the Northern hemisphere, which of course, I simplified. I did add a 2.2K pullup on the GPS Enable line which helped it ride through the power dips during XBee transmission.
Last but not least, the LCD display. This one took a little bit of soldering iron sorcery to get it to work. I forgot (gulp!) to connect the data and clock lines on the display. That makes it a beautiful blue PCB decoration with no function. If you look closely at the display connector (just north of the AVR), there are two little strands of wire that pull those signals off the 0.5mm pitched (spacing from center of one pin to the next). I soldered them to a couple of cut out vias and then soldered a strand of ribbon cable to suitable pins on the MCU. The screens are a little fragile because of this…
Last and, since I almost forgot about it probably least, the battery and charging circuit. The battery is an 1100 mAh Lithium polymer from SparkFun. According to my scope, the circuit drew about 250 mA, which if the circuit was optimized to draw all the juice out of the battery, would last for four hours. In reality, the Low Drop Out (LDO) regulators require about 0.3V about 3.3V to properly regulate, so they will source from 4.2V down to 3.6V properly, but without crunching a lot of math I should be able to get about an hour per charge. The MAX1555 is a super simple Lithium Polymer battery charger that can charge the battery through either USB or DC power sources. When the battery is full, it automatically goes into trickle charge mode to keep the battery topped off. It works perty good.
I just said perty. My redneck past is always nipping at my heels …
Anyway, the final physical appearance of the jobber looks like this, next to a couple of common objects for size comparison:
And just to make sure things would look right, I programmed in a quick and dirty static screen that represents what the game screen might look like:
Next post, we’ll dig into the firmware.
Have you ever wondered, if you were a cat, if you would have been one of those cats that would have chased the laser pointer mark across the wall, again and again and again? Eight hours a day? If yes, then there’s a promising career for you in circuit board layout!
Actually, it’s not quite that bad. I have to admit, though, if I were a cat … well, anyways, it’s kinda fun in a weird way to lay out a circuit board (which is probably what the cat would say too). You get to put all the components in correct positions, and it gets you outside of the flat earth of schematic-land and thinking a little in 3D. These parts have to fit in an enclosure, and that’s usually the trickiest part of board layout: How is this PCB going to fit in its final resting place? Will the charging plug fit? Where will the screen go? How will buttons make it outside the enclosure? Then you hope there’s enough space left on the surface of the PCB to connect them all together with flat copper wires.
I have to lay out a disclaimer here (hmmm … probably should have a few blog posts ago …) that I was working towards a proof of concept more than something that could actually be used. The approach I took led me to design a project that would absolutely shatter into a gooey, paintbally mess of plastic and electronic parts if it took a direct hit. That … actually makes it sound kind of fun … (No Brad! Don’t do it! Don’t go into the cave with your lightsaber!) I’ll explain later how I intend to make this thing field-hardened and able to withstand the worst abuse that even a cartoon Nelson (“Haw haw!”) could throw at it.
So here’s a list and short description of the approach I took for the enclosure and mechanical interfaces:
- ABS Plastic enclosure from Polycase.
- Edit: The case is actually a PacTec enclosure, from the PP series. Memory lapse caused this unfortunate mistake.
- This one from SparkFun is a little bulkier, but might work as a decent replacement (no guarantees!).
- 1/16″ Acrylic (Plexiglass) from a local hobby store.
- I carved into the case with a drill, flush cutters, and an Xacto knife to make a viewing hole for the LCD display.
- Cut the acrylic with scissors, and stuck over the viewport on with double sided tape.
- 3/8″ tall tact switches, with stiff contact force to prevent accidental presses.
- Drilled using a 1/8″ drill.
- 2.1mm Barrel jack (planned) for charging from a wall wart.
- Since I only charge it from my bench power supply, I decided to just leave it with male 0.1″ pin headers.
- I left the top plate off until I was sure things were working. Then I left it off because it was working – why rock the boat? The charging connector therefore required no drilling.
- An electrical component for sure, but a very large one with special placement considerations.
- Fits flat behind the PCB inside the enclosure.
- Again, an electrical component but it’s large and needs to be placed carefully.
- Originally, I mounted it flush to the back with foam tape. It seemed like this caused it to take way too long to get a good lock on the satellites…
- So I placed it perpendicular to the face of the enclosure heading out the back direction. Again, double-sided foam tape. It’s just about as important as a soldering iron for most projects I do.
- A simple slide switch was used.
- Just cut the positive terminal from the battery and soldered this in series. Again, no top plate makes installation easy.
So, on top of all the electrical connections, we’ve also got to worry about all the mechanical placement when it comes to board layout. So let’s get down to it. I chose a two-layer PCB, meaning you can put copper on top and on bottom with copper plated holes (vias) that connect signals from one side to the other. The red denotes where copper will be placed on the top side of the circuit board, and blue denotes where copper will be placed on the bottom side of the board. Without further ado, here it is:
The inverted looking silk screen helps show which parts are to be mounted on the back side instead of the front.
Eagle actually has an autorouter, which works OK even though the results are usually ugly as sin on Sundays and it’s generally hard to fix things if you add new connections post-autorouter. Nevertheless, on large boards it’s still a useful and time saving tool that’s worthwhile. I used it for this project, and then went through and thickened higher current wires and corrected a few other items of importance. I also laid out some large ground planes using polygons (see the big read lines that go around the perimeter?), which snap a large copper plane around existing traces without overlapping or shorting other traces.
That’s about it for the board layout process. I used Sunstone Circuits to fabricate the circuit boards, they are in-state to me and ship it the following day (free ground shipping, which is overnight to me). There are lots of other places that are probably cheaper, but I’ve never had a quality problem and I get them REALLY quick. Patience has never been a virtue of mine. In fact, it’s never been a virtue – that was a lie spread by the magical powers of ligers in the late 18th century.
Uh, I ordered a few extra boards (price breaks levels work solely to generate revenue), so if anyone wants one, feel free to request in the comments! They’re not perfect, but can be made to work.
Next time: I’ll go over what I found (and didn’t find!) during testing.
So here’s the start of the design section of the project. I’m releasing this project and related information under the BSD license. I’m not into the viral type of Open Source licenses, but if you make a buck let me know about it cuz I’d l0ve to hear about it. And maybe you can buy me some draft root beer … and if it’s a lot of money, maybe a Tesla …
I thought I’d put one of the many logos I made for it here. Amazing what a guy with a hamster wheel in place of right brain functionality can do with a few GiMP filters… Well, maybe not as amazing as I think, considering I am the one with the hamster wheel brain.
Before I dive in too deeply, lemme run over the development cycle that will ensue now that I’ve got my spec:
- Draw up a schematic
- Lay out a circuit board (e.g., place drawings of the parts on a printed circuit board document and draw metal wires between all of the parts that need to be there).
- Break piggy bank.
- Send the circuit board to a “board house” to get it fabricated.
- Purchase parts needed from online electronic component suppliers like DigiKey, SparkFun, and Mouser.
- Assemble the parts.
- Write the code.
- Field test the result at various steps along the way.
I’m definitely a bottom-up developer, meaning I take the skills and parts I know well and attack the given problem with those first, and only add in new skills/parts as my existing skills/parts set prove unsatisfactory. I’ve tried to break this habit, but it gets really cool results really fast and it’s hard to part with that (at the expense of a most likely higher quality project that might be achieved using a top-down approach).
I’ll hit you with a brief overview on the parts that I picked, and then I’ll show the schematic at the bottom:
- ATMega128 from Atmel
- 128KB Flash program space, 4KB RAM
- 54 I/O pins
- 8 ADC channels, for power monitoring and microphone reading
- Clocked at 8MHz and powered at 3.3V (because all cool components run at 3.3V ;)
- It’s one of the easiest microcontrollers to use these days, and ridiculously capable.
- Programmed in BASCOM-AVR. More on that later …
- EM-406 GPS module from SparkFun.
- 20 channel (e.g., can track up to 20 satellites simultaneously)
- 5m accuracy
- Small and works pretty standalone
- Connects through a UART to the Mega128
- Color LCD Nokia Knock-Off from SparkFun.
- 128×128 Pixels
- 4096 possible colors, but only 256 at a time in the palette
- Not that great, but it does the job about as good as an old cell phone LCD display would
- Digi XBee Pro, also available from SparkFun among many other vendors
- 1 mile line of sight range, 300yd urban range
- Easy as pie. And like Jack Handy says, “If you get the chance to choose between regular heaven and pie heaven, choose pie heaven. It might be a joke, but if not, mmm boy!” Mmm, XBee!
- Flexible addressing and self-healing mesh networking capabilities
- FM24C64 chip from Ramtron. I’ve only found it from Mouser.
- 64KB of high-speed, non-volatile RAM.
- Cheap (~$3.50)
- Used to store field and game information, along with user settings
- Every project with small non-volatile needs should use one of these. They’re fantastic.
- 1100 mAh Lithium Polymer battery from SparkFun.
- MAX1555 Li-Ion battery charger.
- This is a pretty good and easy to use combination, and I’ve had great luck with the crazy easy to use charging circuit in the MAX1555 datasheet.
Those are at least the main parts that drive all the primary functionality of the system. Drum roll ….
Schematic time! I use EagleCAD from CadSoft (http://www.cadsoftusa.com) for drawing schematics and laying out PCBs. They have a free version for non-commercial use, which is great for open source and hobby stuff. SparkFun releases EagleCAD libraries for almost all the parts they sell, which kicks development speed up to .5 past lightspeed. Eagle is also cross-platform compatible, for all you fellow penguins out there.
Sorry for the under-impressive image on this page. Click through to zoom in for readability. You’ll notice I organize my schematics by net names rather than running crazy lines all over the page. Please don’t ever make schematics like that. Every time you make a rats nest out of nets running all over the page, a devil gets his horns. Just don’t do it.
Instead, label the crap out of EVERYTHING. It’s best to not leave any nets with a default net name (e.g, N$42). You’ll notice that it’s usually fairly easy to follow the document this way, especially when you’re using a printout, PDF, or some lame JPEG on a blog instead of Eagle to view the schematic.
Rant time’s up. Anyways, I know I messed a few things up. I’ll make an errata list if I can remember what they are … Also, it’s OK if you don’t have a clue what’s going on. I’ll explain most of the connections in later posts, especially once I start talking about the software (because that’s where the pin functionalities and inter-IC signals really get defined).
Also, you may have noticed I like SparkFun (woot!). They’ve got some great stuff that hobbyists normally can’t source, like the GPS module, LCD display, and lithium ion batteries. They also have a lot of great tutorials for beginners, for everything from Arduino to basic soldering. Shameless plug: buy stuff from them. Every time you place an order, a devil gets his horns removed. (No, I don’t work for them … that’s a pipe dream …)
Next time, on Brad’s Projects: Board Layout! Yay!
To my wife’s great chagrin, I like playing video games on occasion. She equates it to the worst form of self-indulgence there is, and a complete waste of time, but it’s relaxing and I rarely (read: less often than not) let it interfere with things I’ve got to get done. All said and done, I go through spurts where I’ll play for a few hours for a couple days in a row maybe once a month.
My favorite game is Battlefront. Yes, the original – Upper management won’t approve expenditures on new video games so the ones I get are usually pretty old. Woot to the stormtrooper. Enough digression – One day I was playing and thought, “Wouldn’t it be cool to have the enemy radar in real life?” To which I responded casually to myself, “Heck yes, it would.”
So I made one. Loosely based off of Halo and Battlefront radar, I designed one for the only acceptable (upper management required non-lethal) recreational war I could think of: Paintball!
I toyed around with the thought of actually making a product out of it for a while. I didn’t because paintballers I talked with just weren’t willing to part with $200 for what they considered a gimmick. But it did give me a reason to blow several hundred dollars on something my wife would marginally approve of. It’s all about working the system (erm, I mean, I love you honey!).
So I came up with a fancy project name, ZephyrEye, drew up a quick concept screen, and wrote up some project specs.
- Color LCD screen
- Should be able to monitor ammo levels by detecting shots fired using a microphone
- Must be hardened to survive a direct blow
- Uses GPS for localization
- Uses ZigBee mesh networking modules for up to 1 mile transmissions
- Must be reprogrammable via wireless bootloader.
- Must use an AVR processor.
- Battery must last at least an hour.
- Both friendly and opposing players can be identified by color and/or symbol.
- Visibility of friendly/opposing players can be user selected per game.
- “The Walking Dead” can be identified by color/symbol (so they don’t get shot again ;)
- Players can be “respawned” by waiting in a neutral “base” zone for a timeout period after being shot.
- Can keep score of different styles of games: Capture the Flag, Elimination, King of the Hill, etc.
- Players can report being hit, which removes them from play and shows others their location as they withdraw.
- Field objects (such as bunkers, bases, field boundaries, etc.) can be programmed in, saved, and restored.
I’m sure I’m forgetting something, but that’s more or less what I set out to create. Here’s what I came up with using a cross-platform compatible and open source 3D rendering software called Blender, with a few post-processing effects using GiMP. I’m really not an artist, but I think it gets the point across. I’ve never actually integrated a ZephyrEye into a hopper, but I thought it would be cool.
I should also note that while I’ve really enjoyed my paintballing experiences (heck, I went paintballing for prom one year ;), I don’t own any equipment and I don’t go very often. So, like almost all of my inventions, it’s a solution looking for a problem (bad Brad!). But even Sir Mix-A-Lot can’t deny the coolness factor. It’s there, baby.
Next: Schematics and design files. Hopefully by the third or fourth post on this topic, I’ll have some videos of the functioning prototypes (cause I still don’t have any that look decent…).
My name is Brad Nelson. I’ve been working on electronics ever since I blew up my Basic Stamp II Dec 25th, 1999 at the age of 16. It was a very confusing day. The purpose of this blog is to prove I’ve learned (albeit mostly from mistakes) over the years, and as evidence I’ll share some electronic projects. At first, the projects will be a bit older, but as I catch up into real time I’ll share more on current projects, and sprinkle in an occasional humorous or interesting post.
My station in life at this moment is … busy. I’ll list my habits in order of priority:
- I’m married to my wife Angie of three and a half years, and we have a 19 month old son Jason Kai. Family’s everything. I love ’em to pieces. However, on the blog, Angie will be frequently referred to as “upper management”, and Jason as the neighborhood bully.
- I’m an electrical and computer engineering student at Oregon State University. If I start spouting incessantly about filters and transforms, it’s probably near finals week.
- I work at a company called Skip-Line, Inc., where I make the dough that buys the bread that feeds the fam. It’s a great job – I get to design electronic products for the road construction industry. I was mostly trained on the job, which means I got to fry the first rounds of lots of fun ICs and modules and put it on the company tab!
- I’m also starting a robotics company. This is a modern form of purifying masochism…
I’ll be posting whenever I get a free moment. My humor is dry, lame, and might make you cry, but if you like it can stand it, make sure to subscribe!