- Published: Monday, 15 March 2010
- Written by Jon Chandler
- Hits: 10486
The first servo clock was built using a name-brand servo known for its linearity. The second iteration was built using a low-cost mini-servo. Its linearity was not as good; uncorrected, the time readout was not acceptable.In the ideal case, locating the delay value at the starting and ending points would be enough for the clock to read properly across the range. The angle of rotation would vary linearly across the scale. If the servo is not extremely linear, the pointer will not always point to correct location in the scale. As an example, if the actual time was 6:05, a non-linear servo might point at 5:55.
The low cost servo has some areas that are highly non-linear. At one point in the scale, the difference between quarter-hour marks was a 20 ms change in pulse width. At a different point in the scale, the change was over 40 ms.
It's most important that the servo clock pointer line up correctly with the scale marks at quarter-hour intervals. The exact position between the marks isn't as important. This improved method calibrates each quarter-hour mark, and linearly interpolates between the marks. A look-up table approach is used to set the position at each of the 720 minutes across the span.
The hardware used for this clock is the TAP-28 board with an 18F242 microcontroller. The hardware is not critical and other implementations can be used. This code was developed using Swordfish.
A potentiometer is used to set the servo position to read the calibration values. I used a 10-turn pot but a regular single turn pot or a multi-turn trim pot could be used. The value of the pot isn't critical - anything between 1k and 100k ohms will work fine. Make sure the pot is linear taper.
1. Mount the servo in position behind the clock scale but do not install the pointer yet.
2. Connect the pot to PORTA.0. The wiper terminal goes to the port pin. The ends of the pot are connected to +5V and ground.
4. Load the calibration code to the PIC.
5. Connect a PICkit2 to the UART connector and launch the PICkit UART tool on a PC. Alternatively, use a UART (5V TTL) - RS232 converter or a UART - USB converter and terminal software on the PC. Set the baud rate to 9600/N/1.
6. Power the board using the PICkit or connect a 5V power supply.
7. Adjust the pot and verify that the servo turns. Adjust the pot until the position readout on the PC is 1500. This is the middle of the servo's range.
8. Install the pointer on the servo's splined shaft, as close as possible to midscale on the clock face.
9. Adjust the pot to position the pointer over the left hand 12. Read the position on the PC and record the position in the spreadsheet.
10 Adjust the pot to position the pointer over the next mark on the clock face and record the position. Continue the process for each mark on the clock face.
This completes the calibration measurements.
Using The Results
Now, open the clock program in Swordfish. Select the spreadsheet region from D2 - R13. Press <CTRL> C to copy this region. Paste this tabular data into the constant data in Swordfish, replacing the existing data.
Compile the program and load it into the PIC.
This picture shows the servo clock being calibrated. The 10-turn pot is in the gray box at the bottom, and is connected to PORTA.1 on the TAP-28 board. The servo cable is the yellow/orange/brown cable disappearing at the top right, connected to the PORTC.2 connector on the TAP-28 board. The only thing better than one PICkit-2 is two PICkit-2s. The lower one with the white cable is connected to the ICSP connector on the TAP-28 and the upper one is connected to the UART connector to monitor position readings. The TAP-28 board is powered by one of the PICkit-2s. A single PICkit-2 could be switched between connectors also.
This is a closeup of the TAP-28 board. This board is completely stuffed with a full set of parts. The TAP-28 board that will be inside the clock won't need the LEDs, the USB connector or the sockets for the daughter board, I2C/SPI or even UART, keeping the cost to a minimum. A salvaged 5V cell-phone power supply will be hard-wired to the TAP-28 to power the clock.
This is the TAP-28 board to be included in the clock. It has the minimum components for this application. Other than the micro and support components, it has switches to set the time, along with their pullup resistors and connectors for ICSP, the servo and the pot if needed for future calibration.