Friday 26 October 2012

Designing the PCB

Because I've never designed a PCB before, I first needed software (free, of course) to do this! After a little research, I figured Eagle CAD was the best to do this as there are extensive libraries available. The one that would be the most useful for me was, and currently is the SparkFun library, as they have the schematic and footprint of many of the parts I needed to use. They even have a special 'locking' footprint that is designed to hold pins in place upside down with friction so you can solder with ease! However, I didn't dare try anything fancy, since this is my first board. Eagle CAD, and the SparkFun library can be downloaded here:


However, the free version of Eagle does have some restrictions. You can't have a schematic that spans multiple pages, and the maximum board size is 100mm x 80mm. Also, you can't have more than 2 layers of copper (no internal layers). Bummer, but a great program nonetheless.

After watching a few videos on YouTube to learn how to design a PCB and schematic in Eagle, I got started! After much work, and FOUR revisions, I got something I was happy with!







Then, I got cracking on placing the components and routing the board (I avoided the autorouter as much as possible, until the very end, where I got bored...). This was by far the hardest and most tedious part of the process! Some of my early designs looked like this (they don't follow the above schematic, that was my final one):
First attempt. Tried to make it as small as possible, but sticking the LCD out like that is just asking for trouble! Hadn't thought of adding the FT232RL yet.

Rev 2. Much better. In fact, I probably would have sent this board to be made, had I not considered surface mount technology (SMT).


 Much better! I used the SparkFun library for more of the things here, and added space for a heat sink (for the L298N). Still a few bugs though, especially in the silkscreen. When I moved the USB receptacle out so it sticks out of the board (so the plug will actually fit), I forgot to move the silkscreen outline with it! Also, the text at the bottom would have been covered by the LCD once the board is populated (duh!). I changed most of my extra components (resistors, LEDs, capacitors, etc) to surface mount, mostly of an 0805 (2012 metric) size package. This makes the board look much neater and more professional.






A through-hole board. Yuck!
Actually, it's pretty impressive, but nothing compared to a surface mount board.












A much neater looking board!








I was quite happy with the final design, once the bugs were worked out. "This could be the one", I said to myself!

Anyway, for the newbies trying out Eagle for the first time (I'm probably still in that phase), here are some excellent tutorials:

Jeremy Blum has a couple of nice videos explaining how to use Eagle Cad:

Part 1 (Schematic Design)


Part 2 (Board Layout)

Also, SparkFun has a nice page on a similar thing, using an FT232RL breakout as an example (Yay!! I needed to know how to wire up the thing and they have a whole tutorial doing it step by step!!!!)


Finally, there's also a 12-part series (no, I'm not going to embed all the videos here) on youtube. Just search up (on YT) "eagle cad lesson", and you should find a series by a user called rpcelectronics.

-nanohex





























The (tiny) first steps to a deadly weapon...

It all begins with an evil laugh:

MWAHAHAHAHA!

...and so I embarked on a quest to design a mini sumo robot to annihilate its opponents (victims)! This evil genius doesn't work alone, though. I'm responsible for the circuitry and the intelligence of the thing, and my partner's supposed to get the mechanical stuff done. I decided, gone are the days of point to point wiring on a $2.00 prototyping board (although these can turn out quite well, if done right), like in some of my early circuits.

This was a simple board that controlled a small obstacle avoiding robot with two modified servos. The MCU has been ripped out (it was either that or wait a couple of days for one to come in the mail, and I'm not the patient type!). I tried to make a more advanced platform with a set of (expensive) SparkFun mecanum wheels, which failed miserably. However, the circuit worked great!
Despite the ugly soldering and a design that sort of built itself as I went along, the thing worked! In both the boards, I couldn't be bothered to add a simple 7HC595 shift register to drive the LED displays, so I just hooked them up to standard output pins.

The rat's nest below. Imagine trying to stick a soldering iron in there.... I still shudder at the memories of cold joints and singed plastic.

I decided for this project, I'm going pro. Yep, that means a proper PCB. And to make it even more awesome, I added some surface mount components in there too, chiefly an FTDI FT232RL chip to add some USB functionality to the thing, because that's just cool. I planned to make it Arduino based (yes, that means AVR), and I thought instead of just buying an Arduino and a bunch of 'shields' (what's up with their stupid names, anyway?) I'm going to make a nice all-in-one board! I still wanted to use the Arduino programming environment for this project, as it's just seamless to work with, but I enjoy programming in straight-up C (with AVR-GCC), so I decided to make something not too Arduino-specific (so I'm not going to confine the board to the idea of having 'set' PWM pins, and having D0 to D13). Of course, any self-respecting board, Arduino or otherwise has some sort of serial communication, hence the FTDI chip. Since this was my first my first SMD experience, I took a crack at some surface mount soldering, which required a soldering iron upgrade.

This was my old soldering iron, and was surprisingly good, despite the nasty mean things people say about gun type irons like this. However, with SMD work, and lead-free solder (lead scares me), I needed one of those fancy temperature-adjustable machines, so I got one fairly cheap off element14, (around $120, with a giant 500g spool of lead-free solder and a brass sponge to clean the tip). 



I could feel the difference right away, soldering with my shiny new iron! It was just so much easier, especially since all the heat didn't wick away the second it touched a pad. The results of my first SMD work were actually pretty good, even though I started with a tiny SSOP-28 package.


I did heat the thing too much though, as I tried to remove a couple of jumpers without solder wick (forgot to buy it!), but everything went better than expected.

Another thing I had to use was some sort of motor driver. Since the robot's probably going to have tank treads (or some other form of differential drive), two motors should be just right. However, I wanted to stray away from the motor driver I'm used to:














The Toshiba TB6612FNG! It's an amazing little thing, and it's dead simple to use: pull the standby (enable) high, pull either IN1 or IN2 high to set the direction, and sprinkle a little PWM! However, it can only supply a measly 1A per motor, and no deadly robot can run on these tiny motors:













So, I decided it's time for a little hardware upgrade...











...the L298N! This guy can give not 1, but 2 amps of current per motor! Okay, it's still not mind-blowing, but it's something, right? And the some of the boards I've seen with this look sexy! I tried to figure out why they looked so cool, and I figured out it's the big heat sink that really stands out.















The final 'big' part I absolutely had to include was a 16x2 alphanumeric LCD display (standard HD44780 controller). These things just look amazing when hooked up right, and can be quite useful for debugging purposes, especially for a robotics competition, where hooking up the board to a computer for serial debugging can be impractical. So, for just around $2.50, including shipping, I picked up one of these from eBay:


It works perfectly, and comes in a cool blue colour! I saw literally the exact same thing in a local store selling for $20.00, and I almost bought it. Good thing I didn't! Came to my doorstep in just under 2 weeks (from Hong Kong). I also picked up a couple of smaller 8x2 screens, but those are a little too tiny for my taste.

Now for the next challenge... drawing up a schematic and designing a board!

-nanohex