zondag 9 november 2008

Servo controller

One of the more recent projects I did was a servo controller. In the past I already designed two (which undoubtedly will feature on this blog too) but because of the new Balloon Manor in Rochester this month I wanted to design one with a higher resolution. It was never used, and this was a very simple prototype, but it did increase the resolution to 512 steps, which is twice the number of the previous version.

As usual with servo controllers the tricky bit is the power supply. As this controller was only controlling a single servo I could suffice with a single 7805 (do not use the 78L05 or the 78M05, as these give too little power, 100mA and 500mA respectively). Again because this was a prototype I hooked it up with a 9V battery clip. As battery it is required to use a NiCd rechargeable battery, because those are the only batteries that would supply the power used by the servo motor. In the end product it is recommended to use either over 7.5V worth of AA batteries, or even D batteries, or use a wallwart to hook it up to mains. As you can see in the circuit board I put a 10uF capacitor (it doesn't hurt to make this bigger) over the input voltage, and a 0.1uF (tantalum is preferred for speed, but ceramic works well and is easier to use, as it doesn't have polarity) capacitor at both the servo motor connector as well as the microcontroller.

As microcontroller I used a PIC16F688, mostly because it is so nice and small, and modern, allowing it to be easily programmed using the PicKit 2 (you can even program it in the PicKit 2 demo board: even though it is made for the 16F690, it fits the 16F688 equally). I used the usual 6 pin programming connector, which, if mounted as displayed, is really easy to hook up: the three pins next to the PIC16F688 (pins 3-5) can be connected directly. The fourth pin (6) is left floating. 2 is connected to the top pin on the other side, as this is the other voltage, and 1 is connected to the reset line, which is the middle pin on the other side of the Microcontroller. For this I use a white wire, so it is quite recognizable on the board, so I can match the triangle of the PicKit 2 with the white wire and do not mistakingly connect it the wrong way.

The final two components are the potentiometer, which is connected to the analog port of the 16F688 and is used as input for the servo motor, and the servo output. On the servo output pins 1 and 2 are connected to the power directly, and 3 is connected to the output pin of the microcontroller that is used to control the servo. Obviously multiple servos can be attached using different pins of the microcontroller. Note that once you exceed two servos, a separate power circuit is needed for the next two. The ground will need to remain the same, to ensure proper functioning of the control line.

The software that I wrote for this servo controller is very basic: it measures the potentiometer and moves the servo motor accordingly. The plan was to include a system that registers the sequence of movements of the potentiometer in memory. This is not very difficult to develop, but the higher resolution of 512 values as well as the limited storage of 256 bytes inside the 16F688 made this trickier. I was contemplating using the difference between two settings and storing it in a 4 bit value, but never got to implement this.

Geen opmerkingen: