Project: Create a graphic servo tester that lets you test your servos.
I had some servos that I needed to test. I had to see if they worked, and needed to see what the limits were for clockwise and counterclockwise operation. I needed to center the servo when fed with a 1500 microsecond pulse.
I used a CGMICROMITE as the brains and an LCD for the display. Buttons, voltage regulator, a few passives, and connectors are the only additional components mounted on the PCB.
Step 1: Servo Tester Parts
The LCD I picked is easy to interface and is rather common. They can be found on Ebay - http://ebay.com by searching for "84x48 Nokia LCD Module Blue Backlight Adapter PCB Nokia 5110 LCD For Arduino" or even just 5110. They are about $3.
The microcontroller is the CGMICROMITE is from http://www.circuitgizmos.com/products/cgmicromite2/cgmicromite2.shtml for $6.50. This chip has an advanced BASIC interpreter and on-board editor. It is a 28 pin DIP chip, so it is very easy to prototype with. Perfect for this project.
Other parts include a Prototype Circuit Board, seven small pushbuttons, a 28 pin socket, an 8 pin strip (for LCD), a right-angle 5 pin strip (for servo), a right angle 3 pin strip (serial interface for programming), a two-pin screw terminal, a 3.3V regulator (for the microcontroller), a couple of caps, and a couple of resistors.
The picture shows most of the parts.
Step 2: Servo Connection
One thing I wanted to be sure to do was use a 5 pin servo connection that has two servo negative and two servo positive connections. Arranged as they are in the photo above you can connect the 3 pin servo connector to the 5 pin header no matter how the connections are arranged on the 3 pin servo plug.
For example some servo connectors have servo negative in the middle, some have signal there. The one I have pictured that I tested has servo positive in the middle.
Step 3: Servo Tester Schematic
The brains of the project is the CGMICROMITE. It has ground and Vcc (3.3V) connections. It also needs a 47uF tant cap in order to operate correctly.
The PC interface uses two "console" pins that are the main programming connection to the PC. These pins connected to my PC during development through a USB to TTL connection. 38400 was the baud rate for the interface. The PC ran a program that provided a terminal interface for the CGMICROMITE. The program was transmitted to the CGMICROMITE in this way. Program is stored in flash on the microcontroller. Once the program has been written and debugged the CGMICROMITE can be instructed to automatically run the program on power up with no user intervention.
The SPI serial port of the CGMICROMITE is used to control the 84x48 LCD display. The display is easiest to control as regions that are 8 by 84. Each region becomes a text line. The LCD is graphic, so the CGMICROMITE has to store a font for the LCD.
The buttons are treated by the program as if they were part of a 3 by 4 matrix-type of keypad. Obviously with some holes in it, since there are only 7 buttons and not 12. But it still works pretty much the same.
Step 4: LCD and Button Layout
The LCD is placed at the top of the PCB and the buttons are arranged in the same pattern that they are shown on the schematic.
The center button, painted green, centers the servo by setting the servo control pulse to 1500 microseconds. The top black and red buttons swing the servo to one side or another with commands of 800 and 2200 microseconds respectively.
The lower black buttons reduce the pulse by 10 or 100. The lower red buttons increase the pulse by 10 or 100.
The LCD displays the pulse width numerically. At center position that is 1500 microseconds.
There is a graphic indication of the servo position at the bottom part of the display. There are 100 microsecond tic marks and above that a pointer that moves right as the pulse width decreases and left as it increases.
Step 5: Wiring/Soldering
Point-to-point wiring was used. That is a 26 guage wire going from point to point. On the back you can see the resistor that was picked (470 ohm) rather than the 1k on the schematic for LED brightness.
The other resistor is the 10k that is needed to pull the serial data in line to ground.
Step 6: Program
The control program was written in the BASIC that the CGMICROMITE can run. A very powerful BASIC compared to other single chips with BASIC.
The program starts by setting lines as outputs where they are needed. The KEYpad command sets the lines that will be used for the button input. A button press causes an interrupt and a subroutine (Key.Int) is run to decide what to do with the key.
The SPI port is opened for communication with the LCD display. Font information is read from DATA statements into RAM.
The LCD is initialized (reference the 5110 data sheet) and then cleared. That is all control bytes that are sent. The DC line is set to 0 for that. Setting DC to 1 is for loading data to the display.
Each line to be displayed is translated from a series of characters to the six bytes that represent the font for that character. The text line is "drawn" much like an old-style dot matrix printer - a byte of vertical pixels 8 dots tall starting on the left side moves byte by byte to the right. All six lines of 14 characters (84 dots wide, 8 tall) are written to the display.
The variable "servo.val" holds the current pulse width in microseconds for servo control. When a button press changes that value the servo is updated as well as the number and graphic on the display.
Step 7: Complete
When done writing the program a command of OPTION AUTORUN ON will set the program to run when the device is powered up, without the need for the PC.
A 4.8 to 6.0 Volt supply is all you then need for testing servos.