I DID IT!
Well, almost. Because it blew up when the ICs and caps rage quit hardcore. :c
Here's how it happened:
I began the design of TinyArmTroller, a board containing six unipolar stepper drive circuits, six digital limit switches, and an atmel microcontroller to process it all. It will communicate with a computer via USB so a python program can provide high-level logic.
Designing around a microcontroller has been the huge hurdle for me, and has lead me to both love and hate circuit design. There are so many components necessary to make the microcontroller happy that I nearly gave up altogether, but I pushed through, asking fellow MITERS-folk questions at a frequency comprable to the clock speed of my Micro.
Speaking of microcontrollers, it was recommended that I use an atmega16u4 or an atxmega16a4u because each board contained built-in ftdi drivers for USB interfacing. Normally some seperate external circuitry is necessary for a micro to communicate via USB. Getting one of these cuts down on the BOM and the board's overall complexity.
Besides, talking vith zee german accent make everysing more legit.
Das Micro!
The atmega16u4 runs off 5V, has 26 IO pins, and can be programmed via USB right from the factory with its DFU bootloader.
The atxmega16a4u runs off 3.3V, has 34 IO pins, and can be programmed via USB with the proper Bootloader installed, but it does not come with the bootloader factory preprogrammed. Atmel will factory preprogram their XMegas special order, but only if you order a few thousand. Given that I don't wish to be a sketchy third party ebay reseller of xmegas, I'll pass!
Now, which board should I take?
Number of I/O:
(6 stepper drivers * 4 channels per stepper) + 6 limit switches = 30 I/O channels. Unless I want to deal with (de)multiplexers...
The atXmega16a4u wins Round 1!
Power:
I want to utilize the 5V from the USB port as well as (uh oh) the 12V motor power (NOOOO!). The atxmega16a4u uses up to 3.6V, wheras the atmega16u4 uses up to 5V. Either way I would need a regulator and smoothing capacitor to clean the output to the board power. Taking a shaky 5V from USB to power a 5V board just will not give me the power I need, while taking the shaky 5V and turning it into a steady 3.3V is more reasonable.
What can possibly go wrong? =] (NONONONO)
Round 2: AtXmega16a4u
Oscillator:
The XMega has an internal 32MHz oscillator, and as *zee above video from zee Atmel company* states, no external oscillator is needed! The atMega16u4 has an 8MHz internal clock, which is plenty fast for my needs, but doesn't have zee video!
Round 3: Draw, or AtXmega16a4u (because of zee video)
Programming:
The Xmega requires an AVRISPmkII programmer with a firmware upgrade to support PDI programming through USB, its own DFU firmware upgrade, as well as some additional hardware on the board to support traditional programming through a 6-pin JTAG connection. The atMega16u4 only requires USB with its factory-preset firmware. As BOM goes up, my happiness goes down, so...
Round 4: atMega16u4
WINNER: atxmega16a4u!
Board Design and Etching
Here's the huge schematic, click to get a better view.
It's a pretty simple board. I scrubbed through the datasheets until I found the example circuitry I needed for USB, programming, and reset. I had one bus capacitor for each motor, as well as one smoothing capacitor per board power input. I purchased surface mount voltage regulators that could step down up to 20V to 3.3V. To prevent the regulators from killing eachother, I put diodes in series with their output (not knowing that they each had about a 1.5V drop: they were soon replaced with wires).
And the routed board! I did most of the routing by hand, and only autoroute for the power components (Dumb, I know. Next one will be all me, I swear!)
Now that I've routed the board, it was time to etch it. I used the same techniques as how I made SingleStepperTroller, this time flipping the top layer so when the toner transferred it would be right-side-up.
The new trick, though, was getting the two-sided thing working. I taped the bottom layer to a computer screen, put some tape on the backside so I could fold it over the front when i was ready, and set forth aligning every hole.
When I thought I got it perfect, I got a friend to fold the piece of tape carefully over the top layer, creasing it at the right spot. I then shoved the 2-layer copper board between the sheets, taped the top layer and the board in place, and put the whole thing in the laminator (making sure some board was sticking out on the sides for traction). A paper-removal scrub rub and Ferric Chloride bath later:
It came out nice on the first try!
AWWWW HELL YEAH!
Here's a closeup of some of the holes from the bottom, after drilling them from the top. You can see where they are ever-so-slightly misaligned, but it's certainly tolerable. Some would harm small animals to get a two-sided board this good on the first try ever. Note the trace clearance tolerances, however: it's a tight fit. I went through the whole board under a Jeweler's Eye-Thing and cut some possible shorts with a Xacto knife.
Now it's time so populate the board!
Here's some general guidelines from my soldermonkey job last summer I found useful to take when I started populating:
0. MAKE SURE THE DAMN POWER SUPPLY ISN'T AC OUT!
- Solder Power regulation circuitry and bus capacitors, including power connectors.
- Try powering the circuit up with each individual power source and check voltage levels. Make sure there is no short circuit. MAKE SURE THE POWER SUPPLIES ARE NOT FREAKIN' AC! Unless, of course, your circuit expects this. Which mine didn't when it rage quit its ICs and caps.
- Solder Microcontroller and anything necessary for micro operation (Resonator, Programming Header, Reset Switch and resistor, Indicator LED, etc.). Then don't solder everything else (like I did) until you've successfully programmed the thing.
- As you go along, constantly check with an audible continuity setting on a multimeter to make sure connections are solid where they should be, and that no shorts exist.
The LED lit up with USB power! Hooray!
Then I blew it up.
After the USB power lit up the board power LED, It was time to test if motor power would do it. I connected the 13.5V power supply, which would totally be fine through my regulator, right? It can handle up to 20V and step it down to 3.3V, so it'll be just fine. If I could just find the barrel connector...
The board kindly and audibly let me know that the power supply I used was AC, not DC output.
Me after realizing I had to make a whole new board. After all that soldering...
Shit I learned:
- When using USB or other thru-hole connectors that cover the top of the board, make sure the traces are all on the other side of the connector.
- Diodes have a voltage drop! Know this before doing things.
- MAKE DAMN SURE YOUR POWER SUPPLY OUTPUT IS WHAT YOU NEED. As in DC, not AC. Use a scope, meter, or something, it takes 2 seconds.
- Routing boards is fun. Watching Autoroute make nice boards is fun, too.
- Use 16 mil logic traces, 24 mil, 32 mil, or greater traces for high power stuff to let high current pass.
- When smoking ICS happen, UNPLUG THE POWER SUPPLY FROM THE WALL, don't try to unplug the board from the power supply via the barrel connector, or face the fury of possible exploding capacitors.
- Don't solder most of the board before testing the sensitive shit like microcontrollers.
- Heat guns are useful for de-soldering surfacemount components from your chicken-fried circuitboard. So are friends!
- Try not to require, but always welcome, a redesign.
Oh well. Next one will be great! No more issues with the USB lines being covered by the connector, no more exploding boards due to AC power, no more shorts in need of Xacto cutting. Just wait and see...
I'm off to sleep. -_-
Thanks for sending this message. Polish girls
ReplyDelete