voltage of the two batteries ranges between 8.8V and
5.5V. To measure this with the PIC, I use a voltage divider
consisting of two 75K 1% resistors (shown in Figure 3).
If the combined battery voltage is for example, 7.75V,
this gets presented to the analog-to-digital converter (ADC) as
approximately 3.84V. The ADC, in turn, returns a value of
approximately 787 which is — again approximately — 100
times the battery voltage. I reformat this number by inserting
a decimal point and sending the result to the display.
I keep saying “approximately” because of accumulated
inaccuracies from the actual reference voltage, the voltage
divider, and the rounding of 1024 to 1000. Since I’m just
interested in a low battery warning rather than a precise
voltage measurement, this is good enough. If the measured
voltage is below 6V, I display it in red instead of green,
which provides a warning that it’s time to charge the
batteries.
I recently built my own 3D printer which I used to
produce a custom enclosure for this project. The bottom
cover slides on, so no screws are needed for fastening it. I
finished the printer just a few months before I started this
project, so this was my first custom enclosure.
Creating custom enclosures was one of the main
reasons for getting the 3D printer, and I was pleased to see
that it worked out. The partially assembled results are
shown in Figure 4. The STL files for printing the case are
included in the project files at the article link. This was
printed using a 0.4 mm nozzle, with 0.2 mm layers and
40% infill. Total print time for top and bottom was six and
a half hours.
Software
The heavy lifting for this project is done in software.
The user interface is handled by the intelligent display, and
the application logic is handled by the PIC processor. 4D
Systems provides a free integrated development
environment (IDE) called Workshop 4, which I’ll just refer to
as the 4D IDE.
You have the option of using one of four development
tools which vary in flexibility and ease of use. I chose to use
the easiest one — Visi-Genie — since it met my needs, and
would get me up and running the fastest. With this tool,
you design the user interface by dragging various prebuilt
objects such as switches, gauges, and text displays onto a
template that matches the size and orientation of your
physical display. Once the design is complete, you can test
it with the 4D IDE.
The 4D IDE test tools display the hexadecimal data
signals that come from the screen when you operate the
controls. You can emulate sending instructions from the
processor by entering the corresponding hexadecimal
sequences. As you go through this testing process, you can
make note of the data sent each direction and include that
in your application logic.
4D Systems has a number of detailed tutorials and
demo projects to help new users get started. The current
user interface design for the Deluxe Servo Tester is shown in
Figure 5. The buttons are all large enough to be activated
individually by my fingers. However, I’ve found that using an
old Palm Pilot stylus works better, and keeps the display
smudge-free. The display hardware includes a small speaker
which I enlist to provide user feedback by playing a “click”
sound whenever a button is pressed. The application
software that runs on the PIC consists of a loop that:
• Checks for a message from the display.
• Translates this message into a new servo parameter.
• Updates the servo signal.
• Periodically checks the battery level.
• Sends data to the display.
• Starts over.
The 4D IDE project files and the CCS C source files are
SERVO 12.2015 33
Figure 5. UI design. Figure 4. Assembly.