Final Project
Abstract
A
data acquisition system was developed as a final project for the
microcontroller design course at UW-Platteville. This system was developed to
monitor power supplies and aid as a development tool for the design of a 200 W
switch-mode power supply. A PIC microcontroller from Microchip was used as the
heart of the data collection system. Internal analog to digital converters acquired
data from an analog interface. The analog subsystem gathered data from
temperature, voltage, and current sensors. Data was recorded through
HyperTerminal in Windows. Once the data was gathered MS Excel was used to
convert, scale, and plot the data.
Introduction
Measurement
of the three basic quantities: voltage, temperature, and current can provide
enough information to allow for debugging of almost any electrical circuit.
During the development of a switch-mode power supply it was determined that
some sort of data logging was necessary to protect the supply and determine if
the supply was operating properly. Out of this need a data acquisition system
was developed. The data acquisition system measures one channel of voltage from
0 to 20 volts, one channel of current from –50 to +50 amps, and two channels of
temperature (one ambient and one load). This amount of data is enough to
determine supply efficiency and temperature rise. With additional channels or
faster sampling rates it would be possible to measure and calculate inrush
current, supply stability, and transient response.
Implementation
options
|
Two options were initially considered to implement the data logger. First, adding an outboard analog to digital converter (ADC) to the 8052 board used for development in class was considered. This approach had the advantage of allowing me to use a known good development system, software toolset, and the ability to get support from teachers and other students. Unfortunately, I had a difficult time finding multi-channel ADC converters featuring parallel interfaces to 8-bit busses that could resolve more than 8 bits. Most modern ADCs found used a serial interface. This was a problem on the 8052 board as the serial port was tied up for communication to the PC. Also fully developing a software-based serial protocol on a relatively slow processor like the 8052 could be difficult. Figure 1 shows the proposed block diagram for the 8052 based data acquisition system.
Figure 1, data acquisition system using 8052 board
The
second option considered the use of an altogether different processor, the
Microchip PIC controller. PICs are self-contained microcontrollers often
including clock, I/O, and a host of peripherals on-chip. The great advantage
seen by adopting the PIC was a chip with onboard analog to digital converters
was available in a small 14-pin DIP package. In addition a serial port, and
multiple timer/counters were available. A low-cost ($35) development kit is
available from Microchip to try out any of the 14-pin series of
micrcontrollers. Additionally, for the intended application a low-power small
form factor device was a plus. Essentially all the PIC needs to create the
system is the analog interface and a voltage regulator. Just the 8052 board requires
2 to 3 times the space of the board designed for the PIC controller and analog
board. The downside of this approach hinged around learning a new assembly
language for the PIC microcontroller and learning a new development environment
and device programmer. Figure 2 shows the block diagram for the PIC data
acquisition system.
Figure 2, PIC processor based data acquisition system
PIC
selection and setup
There
are literally hundreds of PIC microcontrollers to pick from. The programmer I
had already purchased narrowed this selection down to 8 or 14 pin devices. At
minimum 4 ADC channels, a UART, and one counter timer were needed. The first
device found to meet these specifications was the PIC16F688. The ‘688 contains
8 channels of 10-bit AD converters, an enhanced UART, two timer counters,
analog input comparison modules, an internal 32kHz to 8MHz clock, and flash
program memory.
In
order to use the PIC, settings for all the internal registers needed to be
determined or calculated via the datasheet. The internal oscillator was used
and set to 4MHz. Next, the serial port was configured. The enhanced UART
(EUSART) has an internal baud rate generator (no external timer is needed). The
EUSART was setup to communicate at 9600 bps, 1 stop bit, 8 data bits, and no
parity. This seemed to be a common serial data rate that was easily achieved
with little error in bit-rate on the PIC (about 0.16%). The commonly used baud
rates were all available in tables in the ‘688 datasheet. After the serial port
was configured the analog to digital converter was set-up. A conversion time of
4.0us as dictated by the datasheet was selected. Then, registers were set up to
use the positive supply as the ADC reference voltage along with selecting the
location of the most significant bit of the result. Finally, a timer was set up
to control the rate of data sampling. The timer values were set to allow for
maximum delay that turned out to be around ¾ of a second. The timer overflow
bit was checked via polling. This approach was used because exact time
intervals were not needed and quick response was not necessary.
Microchip
provides an integrated development environment (IDE) called MPLAB for coding,
compiling, setting up, and controlling programmers for the PIC series of
microcontrollers. Included in the IDE is a debugger and compiler. The debugger
worked well until additional peripherals were initialized and used which then
caused the debugger to crash the IDE. Thus, all further testing needed to be
conducted on actual hardware. A simple USB powered programmer interfaced to the
IDE and reprogrammed the flash program memory in PIC controllers.
Microcontroller
Firmware
After
configuration of peripherals the microcontroller firmware consisted of a simple
loop that acquired samples, converted them to a format acceptable to
HyperTerminal, and echoed them to the serial port. Code is attached to the end
of this document in listing 1. Peripherals were first initialized as described
in the previous section. Following this a timer set to approximately one second
would overflow triggering a capture event. The capture event consists of
setting ADC registers, then waiting for the conversion to be completed. These
events are repeated four times to cover all the input channels. The results are
then converted to a three digit octal number via shifts and bit masks. Only 8
bits of the 10-bit result are converted to octal, as it appeared the lower
value bits only added noise to the acquired signal. Finally, the converted
values were output on the serial port to HyperTerminal in ASCII format
delimited with commas. Figure 3 shows the block diagram for the microcontroller
firmware.
Figure 3, A block diagram of the PIC’s firmware
Hardware
The high
integration of the PIC controller leads to a very simple hardware solution. On
the digital side the PIC controller is connected to a MAX232, RS-232 to
logic-level converter. A 5 V power supply and some supply decoupling capacitors
round out the digital section of the hardware. Figure 4 shows the
implementation of the digital board that was constructed on the PICKit-1
development board.
Figure 4, the digital section of the data acquisition system
Highly integrated sensors reduced the difficulty of implementing an
analog interface board. The LM35 temperature sensor features a conditioned
output with a 10mV/C output slope. It was decided to use the LM35’s output
directly, without amplification, with slightly reduced resolution. A
hall-effect current sensor the ASC750SCA-050 made by Allegro was chosen as an
easy integrated solution for current sensing. The current sensor is capable of
resolving –50 to +50 A and outputs a 0 to 5 V signal corresponding to the
current through the device. In the original application it was expected to see
load currents up to 30 A. However, when demonstrating the device it was not
possible to find power supplies capable of supplying more than 2.5A, thus the
captured waveforms appear very noisy due to the small currents measured. Figure
5 shows the schematic of the analog board.
Figure 5, analog interface section of the data acquisition system
The
physical hardware is shown in photo 1. Two LM35 temperature sensors are
attached via twisted cable, enabling them to be clamped onto heatsinks to
measure power supply temperatures. A set of binding posts is provided for
voltage measurement and current measurement input. The 9 pin serial port hangs
off the left side of the development board (black PCB on top). Unregulated (9
to 37 VDC) DC input is supplied via two wires exiting the back of the board.
Photo 1, physical realization of the data acquisition
system
Results
To
test the data acquisition system an unregulated power supply was used. Real
power supplies have internal resistance that can be demonstrated if the load of
the supply is varied. The circuit in figure 6 was built to show the effect of
loading the supply under various conditions.
Figure 6, an unregulated power supply loaded with various power resistors
The output voltage, current, ambient temperature, and
temperature of the load resistor were all monitored via the data acquisition
system. After logging the octal numbers to a text file via HyperTerminal, the
data was scaled and plotted in MS Excel.