Issue
144 July 2002
An
80C31-Controlled Power Supply
by
Noel Rios
Circuit
Description
The
brain of the circuit is the popular 80C31 microcontroller,
which is the version of the 80C51 without ROM. The 80C31
is a widely available (it’s produced by several manufacturers)
and high-quality microcontroller for embedded design
considering its instruction set and price.
The
80C31 has 128 bytes of RAM, two external interrupt pins,
two timer/counters, and serial ports (see Figure 1).
It has 32 I/O pins, but doesn’t have ROM, so some of
the ports (namely ports 0 and 2) are used for the address
bus and data bus. A few of the pins of port 3 are also
used to interface to other devices like ADCs and DACs.
The pins serve as read and write signals for proper
bus operation like the read cycle and write cycle. So,
after interfacing the ROM, ADCs, and DACs, you’re left
with 14 I/O pins.
|

(Click
here to enlarge)
|
Figure
1—The 80C31 has 128 bytes of RAM, two external interrupt
pins, two timer/counters, and serial ports. |
Port
1 is used to interface and read the keypad. Some of
the pins in port 3 are used for the Set Voltage and
Set Current buttons, while others are used to control
the relay and analog switches to read the voltage and
current to be fed to the ADC.
U2
74HC373 is a transparent latch (see Figure 2). It’s
used to obtain the address because the address bus and
data bus are multiplexed on port 0 to conserve pins
coming out of the IC. The address is obtained after
the address latch enable, or ALE, is asserted. U3 is
an 8 KB × 8 UV EPROM (27C64) that stores the program
that sets the voltage and current and reads the ADC.
I chose the 27C64 EPROM because it’s inexpensive, available,
and the firmware will fit in it. You can actually use
larger EPROMs like the 27C512, but they’re a waste of
space, money, and time because you’ll have to wire the
added address pins. The 4K × 8 EPROM can also be used
but it’s hard to obtain.
|

(Click
here to enlarge)
|
Figure
2—In the digital portion of the power supply, U2
74HC373 is a transparent latch used to obtain the
address. |
U4
ADC0820 is a successive approximation analog-to-digital
converter that converts an analog input voltage to an
8-bit equivalent value. It’s fast and provides the necessary
handshaking pins to interface to the three-bus architecture
without glue logic. U4 ADC0820 also converts the analog
voltage to an 8-bit equivalent value.
U7
CD4053 is a triple one-of-two switch. It is used to
select between the voltage and current. Wondering why
I said current? Using a high-side current detector,
the current flowing through a sense resistor is converted
into a suitable voltage to be read by the ADC.
U5
and U6 AD7524 are digital-to-analog converters. They
convert a digital value to an equivalent analog current.
They’re chosen because they provide the hardware needed
to interface to the system bus. In addition, they’re
fast and behave like RAM memory.
U9
LM358 and the adjustable resistors form a pair of current-to-voltage
converters. U8 74HC138 is an address decoder that’s
used to access the ADC, DAC, and LCD. The MOVX memory
space is divided into 8 parts of 8 KB each. I used this
scheme so that you can also insert an 8-KB RAM just
in case it’s needed. Actually, the MOVX instruction
generates the read and write signals whenever it’s executed,
so you can read and write to external devices connected
to the bus.
LCD1
is an LCD module based on the popular HD44780. It’s
interfaced to the three-bus system using four NAND gates.
Because the LCD is slow, the busy flag is read after
an operation to see if it is busy or not. Failing to
poll the busy flag will result in erratic operation
or no display at all. In order to interface the LCD
properly, you’ll often need two signals at one time
to perform an operation. Namely, the decoded signal
like a chip select signal and the read signal for a
read operation. The two signals must be turned on at
the same time for a proper read operation. The same
principle applies to the write cycle.
C9
and R4 form the RC time delay for proper reset. The
specifications require several clock cycles during which
the reset is high until the clock generator is stable.
D2 serves to discharge the capacitor after the power
is removed. C5 to C14 serve as an immediate source of
voltage because the supply rail drops as a result of
the internal switching of the transistors. The voltage
drop is caused by the inductances in the wire or traces
of the PCB. And as you know, the current cannot change
immediately when there is an inductor present in the
circuit.
Rectifier
diodes D2, D3, D5, and D7 1N5400 convert alternating
current to pulsating DC (see Figure 3). C1 filters the
pulsating DC to smooth DC. C7, C8, D17, and D18 are
configured as a charge pump that serves as a source
for the negative voltage needed by the high-side current
detector.
|

(Click
here to enlarge)
|
Figure
3—When looking at the analog portion of the power
supply, you notice that the rectifier diodes convert
alternating current to pulsating DC. |
Zener
diode D1, R1, R6, and Q1 provide a constant current
source for the thermal sensor. Q8 serves as a thermal
sensor and limits the base current to the series pass
transistor after it reaches a certain temperature. The
collector current increases as the junction temperature
increases even if the base current is constant. This
works in theory, but it has not been tested because
I don’t have a themocouple themometer. I did use, however,
a 4² × 4² heavy-duty heatsink.
D12,
D13, C4, and C5 form a split supply power source that’s
used to power the logic circuit, ADC reference, and
the negative supply for the DAC reference. U1 78L05
and U3 79L05 serve as pre-regulators for the voltage
references. U2 7805 is the voltage regulator for the
logic circuit. Note that the 1-A variety is used because
this also powered the EPROM emulator used during development
of the firmware, which consumed a great amount of electricity.
C2,
C3, and C6 are filter capacitors used to make the regulators
more stable. R5, R27, and D4 LM336-2.5 form the ADC
voltage reference. The variable resistor R27 trims the
voltage to 2.55 V. R20 and D14 LM336-2.5 form the voltage
reference needed by the DAC ICs. R26 is used to bias
the Darlington transistor, which is a series pass element
comprised of Q5 and Q6, which form the Darlington transistor.
The series pass element acts as a variable resistor
to change the output of the power supply.
R10,
R21, R22, R23, R24, and U7 MC4741 act as a high-side
current detector. Essentially, it’s a subtractor that
gives a voltage in proportion to the ratio of the resistor
and voltage difference. The current moving across R10
produces a voltage drop that’s detected by the subtractor,
and then it’s amplified according to the ratio of the
resistances. A 2.5-A current produces a 2.5-V potential.
This potential is compared to the voltage generated
by the DAC. The comparator U5 LM358 controls the series
pass element in order to regulate the current output
of the power supply. R11 and R15 are a sampling element
of the output voltage. The two resistors form a voltage
divider and scale the voltage by 10. Thus, a 23-V potential
becomes 2.3 V. The comparator U5 LM358 compares this
potential to the voltage generated by the DAC and in
addition to controlling the series pass element, which
regulates the output voltage of the power supply.
D15
and D16 isolate the two op-amps. D8, D9, D10, and D11
protect the analog switch and ADC when there is an error
and the sampled voltage or current rises above 5 V or
drops below zero. C10 and C11 serve as filter caps to
smooth the sampled voltages. R14 and R18 limit the current
from the sampling points. R28, R29, D19, and D20 act
as a regulator to limit the voltage going to U7 MC4741.
If the circuit is unloaded, the B+ potential can reach
as high as 31 V. And if this reaches U7, it will suffer
electrical overstress, or EOS.
The
firmware, which can be downloaded from the Circuit Cellar
web site, is written in assembly language using a Metalink
assembler. One thing to note is why the reference is
2.55 V. The reason is that the ADC and DAC values go
from zero to 255. Therefore, if you use 2.55 V you won’t
need to compute the values needed to obtain a desirable
voltage or the reading obtained by the ADC. With this
scheme, you can simply read the ADC and move the decimal
point. For example, a 100 reading from the ADC is equivalent
to a 10-V potential. And with an 8-bit value, the resolution
of the voltage is 100 mV and the resolution of the current
is 10 mA. To program a 1-A current you can send 100
to the current DAC. To program 1 V, simply send 10 to
the voltage DAC.