When I set out to build a
display for the system parameters
in my electric truck conversion,
the PIC16F819's peripherals
made for a very compact and
unit (Figure 1). I realized this was
a very specific application for
what could be a simple general-purpose process monitor and
display for analog and pulsed
Potential applications include
alternative energy systems such as solar photovoltaic or
thermal, wind turbines, or geothermal; backup power
systems for your home or RV; keeping tabs on your
aquarium or fish pond water quality; or maybe just
building your own weather station from scratch.
This process monitor can accept three analog signals
either as continuously variable voltages or pulse-width
modulated signals, as well as one digital pulse input for a
frequency counter. The software includes a conversion
formula for each input with user-defined variables to turn
raw signal data into scaled numeric values.
The software also accepts user-defined names for
each value, and displays the four values and their names
on a 2x20 (or larger) character LCD in real time. The
user-defined variables and names are entered with a
simple three-button interface and are retained in non-volatile memory.
The three analog signal inputs are converted to raw
data by the PIC's built-in analog-to-digital converter
(ADC) at 10-bit resolution, representing a range of zero
to five volts (assuming a five volt supply voltage to the
PIC). The conversion formula to turn this raw ADC data
Scaled value = ((raw data value from ADC
* variable1) / variable2) + variable3
Variables 1 and 2 allow the raw data
to be scaled to represent larger or smaller
voltage ranges than five volts if you are
using a voltage divider on the ADC input.
This is what I had to do in my application,
where the electric motor controller
outputs were 12 volt signals. If you don't
need to use one or both of these
variables to scale your data, they can be
set to one.
Variable 3 allows offsetting the scaled
value to allow measuring and displaying
small changes in a large voltage, for example. If no offset
is needed, this variable can be set to zero.
The scaled values are calculated as word-sized
integers. While a lack of a decimal point appears to be a
significant drawback, the formula above also allows us to
work around this limitation in many cases. If you need to
measure zero to five volts with a resolution of 10 mV, for
example, adjust the variables accordingly and change the
name of this reading from volts to millivolts (Figure 2).
When the process monitor is powered up, it will
default to using the last set of variables and input names
that were saved. To change these, hold the enter button as
prompted on the start-up display. Each name can be up to
three characters which are selected with the up and down
buttons. Any ASCII character can be entered, including
blank spaces if you don't need all three characters. Input 1
corresponds to the PIC's ADC channel 0; input 2 to ADC
channel 1; input 3 to ADC channel 3 (not a misprint!); and
input 4 to the timer1 counter/timer input on portB. 6.
This somewhat odd numbering scheme results from
the limited set of choices available for configuring the
PIC's portA pins as digital or analog; since we need some
of both, the best choice available gives us three analog
and five digital pins on portA. Due to a limitation of the
method the software uses to store the input names
(solving one problem with EEPROM writes but creating a
January 2014 35
■ FIGURE 2. Operating display after names and variables are entered.
■ FIGURE 3. Display showing entry of the fourth input name;
previous names are also visible.