Submitted by Evan on
When we first started thinking about actually building the projects we wanted, we came to the conclusion that there wasn't a solid solution for controlling servos. There were quite a few commercial products and some roll-your-own project that were close, but not quite what we were looking for. What we were looking for just didn't exist on the market. We had planned to be using the controller quite often so, cost was also a factor. So we set out to build our own. We were looking for a system that was easily controlled by I2C or serial, yet quite small. The controller also had to be cheap to produce. The development cost dwarfed the cost of the just purchasing an available one, but we feel in the long run this was a solid idea.
 
Requirements
 
The first step of of any engineering project is defining the requirements. I'll save you the effort of having to read the formal draft and just give you the highlights.
 
  • - The Servo Controller shall be able to control at least eight standard RC servos.
  • - The Servo Controller shall be able to generate a RC servo pulse signal varying from one millisecond to two millisecond, at a rate of fifty Hertz.
  • - The Servo Controller shall be able to achieve a signal control resolution of at least eight bits.
  • - The Servo Controller shall be able to be commanded by either I2C or asynchronous serial communication.
  • - The Servo Controller shall allow communication protocol to be selected via physical interaction.
  • - The Servo Controller shall regulate and protect the input voltage for system components.
  • - The Servo Controller shall use standard 0.1 inch male headers to interface with servos.
  • - The Servo Controller shall not occupy a planar area greater than two square inches.
 
These requirements help us understand the scope of the design problems and where to focus during the development process. With these requirements in mind we can start the design.
 
Component Identification
 
 
Choosing components is a rather interesting task. Component selection is determined by a number a factors, such as cost, footprint, availability, function and much more. A great resource for this process is FindChips.com. It searches almost all major electronic distributors and reports current stock levels and prices. Availability is probably the most important issue when it comes to selection. Theres no point picking out a elegant and perfect device if you can't buy it anywhere.
 
 
Now for our choices. We selected the Microchip PIC16F690 as the chip of our choice. We know that many people default to the AVR chips because of the popularity of the Arduino, but the ATMEGAs just didn't meet our needs. We really didn't need a 28 pin DIP or a 32 pin QFN. The PIC16F690 offers a 20 pin DIP, great for prototyping, and a 20 pin QFN, which is really tiny. Having the smaller footprint saves us space on the PCB. Also the PIC has an internal 8MHz clock source, which reduces the amount of support components required to use the chip. The PICs also have a lower unit cost than the AVR chips. The other added benefit is that we have been working with PIC chips since the old days when FIRST Robotics still use them in the controllers.
 
 
The final product will be using surface mount components. These things are so much smaller than there through hole counterparts, that its ridiculous in some cases. We like to use 0804 sized components for our passives because its a good balance between saving space and having the product actually producible. We don't have a pick and place, so having components that can be picked up and placed by tweezers is important.
 
Prototyping
 
 
We usually start prototypes on a breadboard. The breadboard allows us to quickly build up a working design and allows for changes to be made instantly. We have a few connections on the PIC that are critical for its operation. We have the Vdd and Vss, which is going to be 5 volts and ground respectively. We also need to break out a connection for the In-ciruit Serial Programming pins. The ICSP pins are the ICSPDAT, which is RA0, and ISCPCLK, which is RA1. The ICSP also needs to use the MCLR pin to reset the chip. We are programming the chip via a PICKIT 2. The pins will be arranged so that they are compatible with the programmer. With these pins in mind we can draw up a schematic of the system.
 
 

This is the final version of the schematic. We had gone through several designs, until we got to this one. This schematic puts in some extra components to meet our requirements. Input voltage is supplied via a two pin screw terminal. We then have a voltage regulator, which accepts input voltage, that regulates the voltage to 5 volts to power our chip. Close to the regulator, we have a few decoupling capacitors to help keep the voltage clean. The voltage regulator has reverse polarity protection, but we put a diode at the Vdd of our chip just in case. Raw input voltage is used to power the servo rail. Most servos like voltage between 5 and 8 volts, with better performance as the voltage increases. With out setup, all you have to do is connect a 7.2 volt battery to the terminal and your ready to go.

To provide the servo control signal we have used the entirety of port C. If you look closely, the servo signals are not arranged the same as the port numbers. This is due to the fact that we are designing this to be routed on a PCB. For the 20 pin QFN chip, this layout gives us the ability to route the board quite easily. We have also broken out the pins used for serial and I2C communication. We have also put in a physical switch to select between the two serial modes. To round it all out we have some indicator LEDs and a reset switch. The LED will indicate power and which communication mode the controller is in. The MCLR pin of the PIC has to be pulled to 5 volts to prevent it from reseting. We do this by putting a resistor between the MCLR pin and a 5 volt source. For the reset button to work, all the switch does is pull the MCLR pin to ground. Voltage goes through the resistor and flows into ground. Its because of the resistor that the circuit does not short.

 
 
So we can now built the circuit on the breadboard. We are approximating the LEDS and other parts with generic parts since this is a breakboard design. Voltage is provided in regulated 5 volt form via our lab bench power supply. The switch is replaced with a set of jumpers. After we have the breadboard done, we can start developing the firmware which will make all this work. We will cover the firmware a little later in the article. We'll going to continue with the hardware development.
 
Hardware
 
 
1st Iteration
 
This was the very first incarnation of the servo controller. It was big, simple, and ugly. Despite all of these short commings, it did allow us to verify that the footprints were correct. Below you'll see the schematic for the early design.
 
 
As you can see, it doens't have any of the bells and whistles. The switch was just a jumper and the chip was not protected against reverse polarity.
 
 
Looking back on this board is a bit embarrassing. It contained a lot of errors and just wasn't a very good design. We were using BarebonesPCB.com to produce these boards so all the labels were in copper. There is a lot of empty space on the board, which is not good when your paying per square inch. DFM was done on the output gerber files to ensure that they were manufacturable. The price was around $30 per board for 3 boards.
 
 
To save some money, we calulated that if we panelized them into a 2 by 2 array we would get a better price per single PCB. It came out to around $10 per unit board. After sending them off to manufactuer, we paitently waited for about a week. Advanced Ciruits, which provides the BarebonesPCB service, is my all time favorite PCB company. The barebone orders have a one day turnaround time. If you account for shipping, it takes about a week to receive some very well made PCBs. As the name says, its barebones. No soldermask, no slikscreen, no routing. Its great for quick turn testing and verification. Best part is Advanced Circuits can also produce the full spec PCBs as well with out having to resubmit designs and having to go through DFM again.
 
 
After that one week, the shiny new PCBs arrived. As you can see, you get what you ask for. The PCB is etched exactly as you specified, to within about 1 mil. We used a band saw to cut apart the panels. This was not the greatest idea as we had not accounted for the material removed by the cutting process. We also had trouble keeping the board square with the blade. As a result, the board are kind of like trapezoids.
 
 
A laser cut stencil.
 
 
 
 
The boards were assembled by hand. A stencil was used to apply the solder paste and components were populated with a pair of tweezers. The whole thing was then baked in a toaster oven until the solder reflowed. It wasn't the most accurate process in the world but it worked. The horizonal headers are soldered to the ICSP pads. This was a easier way to permanantly allow easy connection with the PICKIT 2. As you can see in the photo, the green wire is briding a connection between the voltage regulator and the rest of the 5 volt bus. Opps. That was actually a really huge mistake.
 
2nd Iteration
 
Due to the size and errors on the previous design, we set out to try again. The previous design was 1.5 by 1.5 inches. Not exactly huge, but bigger than it needed to be.
 
 
This design is much closer to the final product than the last one. It has the reset and selector switch. Over all the layout was changed, but the connections remained the same.
 
 
The board was shrunk to 1.25 by 1.25 inches. This was a 30% space savings over the previous design. The board also used a ground plane, unlike the older design, which had a point to point grounding layout. This board was also designed to be manufactured in full spec. That means full labeling using the silkscreen. If you look closely, you can see it's labels with our old product numbering system. This board was designed around January of 2010. The dimensions of this board actually rub against the minimum size that the Barebonespcb service offers. I believe the unit cost would have been around $28 per board for 3 boards.
 
 
As with the previous design, there was a cost saving in panelizeing the design. This time we acounted for the material removed during the cutting process. The board were arranged in a 4 by 4 array, giving us 16 units per board. The price came out to something like $2 per unit. These board were cut apart on a CNC so the edges came out nice and perpendicular.
 
 
 
 
The PCBs arrived about a week after submission. The boards are much larger than the last design, but yield many more individual units.
 
 
 
 
These boards were also assembled by hand. A new stencil was made and used to apply solder paste. Like before, a tweezer was used to populate the parts. The united were then baked until done. These boards pretty much met our requirements, but after a week of testing we began to find problems. There were a few ergonomic issues with the design. But the more serious issue was that the boards began to fail after a few days of use. The PIC chips seemed to be unable to hold a stable clock rate. For example, an interrupt was setup to go every 20 milliseconds, but the resulting time was about 13 milliseconds. In the end we concluded that the chips may have been damaged. We were able to rule out damage by the oven, by assembling units with strict temperature and time control. This led us to believe that the chips were damaged by static discharge and the possibility of reversed polarity. Since the board are not soldermasked, the bare traced are in contact with who ever is handling them. Also we were powering the chips directly via the 5 volt pin and may have damaged the chips through negligence.
 
3rd Iteration
 
Fast forward to winter 2010, we had been distractacted by other projects, but we refocused on the Serial Servo Controller. Using everything we had learned, we started the design from scratch.
 
 
This design the the final design we have adopted. It features the same things as the easier design, but with a few additions and tweeks. The values of the capcitors was increased to offer better filtering of voltage. A diode was added to the design to protect the chip. Not much changed with the schematic, but the board design has changed significantly.
 
 
The most obvious thing is the giant logo in the middle of the board. We actually put that in place first and design around that. Something form can have some preferential treatment over function. The size and mounting hole place stayed the same. The switch and indicators have been moved to provide better and more intuitive access. Overall, the board looks and functions better.
 
 
 
For these boards, we opted to have them produced in full spec by BatchPCB. The monetary cost was on par with BareBonesPCB, but gave us the soldermask and silkscreen at the cost of turnaround time. They came out looking great. These board were routed by BatchPCB to a beautiful rounded square.
 
Coming Soon.
 
Firmware