This is only a preview of the February 1997 issue of Silicon Chip. You can view 25 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Computer Controlled Dual Power Supply; Pt.2":
Items relevant to "Control Panel For Multiple Smoke Alarms; Pt.2":
Articles in this series:
Articles in this series:
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Pt.2: adding the parallel interface board
BY RICK WALTERS
Computer controlled
dual power supply
Last month, we presented the standalone
version of this power supply. By building &
fitting the interface board described here, you
will be able to control it from your computer.
The power supply interface board
connects via a 25-way cable to the
parallel port of your computer. The
interface allows your computer to
perform two functions.
The first is to set the required posi
tive and negative output voltages and
current limit which will be delivered
by the power supply. The second is to
display the actual voltage and current
from the power supply on the comput
er’s video monitor.
16 Silicon Chip
Normally the voltages set by the
computer will be the same as those
displayed but if the power supply
goes into current limit, the associated
output voltage will be reduced.
One good feature of the computer
control is the ability to use the settings
which were in use the last time the
supply was turned off. These settings
are stored in a file which is read each
time the software is run. This gives you
the option of using the same supply
values and printer port as previously
or selecting new values or a different
printer port.
Now let’s have a look at the circuit
of Fig.1 and even the most dyed-in-thewool computer hardware enthusiast
would have to admit that it’s not too
inspiring. However, before you turn
the page and give up, let’s note a few
key points.
First, if you refer to the circuit
presented last month, you will note
that there are four outputs labelled
IN1, IN2, IN3 & IN4 and three inputs
labelled D/A1, D/A2 & D/A3.
The outputs from the power supply
board become the four inputs for the
A/D converter on the interface board.
They are fed to IC7, a 74HC4051 1-of8 multiplexer. Depending on the BCD
data at its ABC inputs, it feeds the
selected IN value through to IC8, the
ADC0804 analog-to-digital converter.
The four IN values relate to the fol
Fig.1: the circuit allows data from the computer’s printer port to set the sup
ply’s voltage and current outputs. It also allows the voltage and current to be
monitored on the computer screen. Octal latches IC1, IC2 and IC3 are used as
D/A converters and are controlled by IC4, a 74HC137 latched one-of-eight
decoder.
February 1997 17
Fig.2: follow this parts layout diagram to assemble the interface board. The
assembly is straightforward but take care to ensure that the ICs are all correctly
oriented and that the correct IC is used at each location.
lowing four power supply parameters:
IN1 Positive output voltage (V+)
IN2 Output current (I+)
IN3 Negative output voltage (V-)
IN4 12V supply
All these IN values will be in the
range of 0-5V and will be converted
by the ADC0804 chip, IC8, to an 8-bit
word (a number between 0 and 255)
which is fed to the computer’s paral
lel port, on pins 10-17. Note that the
parallel port is bidirectional so it can
accept data on these pins, as well as
outputting data.
Three of the IN values, IN1, IN2 and
IN3, are displayed on the computer’s
screen.
As we just remarked, the parallel
port also outputs data and in this case
it delivers 8-bit data to control the volt
age and current settings on the power
supply. This 8-bit data is delivered on
pins 2-9 (D0-D7) of the 25-pin socket.
From there it is connected to the D0-D7
inputs of IC1, IC2 and IC3. These are
used as three D/A (digital to analog)
converters.
Digital to analog converters
IC1, IC2 and IC3 are octal (8-bit)
latches under the con
trol of IC4, a
74HC137 latched one-of-eight decod
18 Silicon Chip
er. Depending on the data fed to its
pins 1, 2 & 3, IC4 enables IC1, IC3 or
IC3 (via their latch enable pin 11 and
inverters IC5b, IC5e & IC5c) so that the
data on their input pins 2-9 is latched
onto their Q outputs, pins 19-12 (Q0
to Q7).
Each 74HC573 has a ladder network
consisting of 10kΩ and 20kΩ resistors
connected to the eight outputs. These
networks convert the 8-bit data at
the output to a voltage with a value
between zero and 5V. These analog
voltages are D/A1, D/A2 & D/A3,
corresponding to the positive volt
age setting Vo+, current limit setting
Io, and the negative voltage setting
Vo-.
We have just described the two main
functions of the interface board: first,
monitor the four IN values from the
power supply board and provide the
three control values for positive and
negative voltage and the current limit
setting. Apart from that, there is little
point in going further with the circuit
description since the interface board is
entirely under software control.
PC board assembly
The interface board measures 178
x 100mm (code 04101972) and has a
25-pin D socket mounted at one end.
Fig.2 shows the component layout on
the board.
The board assembly is reasonably
straightforward. In essence, you have
a few rows of equal value resistors
and eight ICs to install, and not
much else.
As usual, before starting assembly,
check the copper pat
tern for open
circuit or shorted tracks or undrilled
holes. Make any repairs required and
then fit and solder the 21 links and
10 PC stakes.
Next, fit the resistors and diodes,
followed by the IC sockets, capacitors
and finally, the D connector. Check
your soldering when you are finished
to make certain that no IC pads are
bridged.
Interconnecting wiring
Most of the interconnecting wires
should have been taped up when you
built the power supply. If you followed
the colour code that we suggested last
month, the brown wire will go to D/
A1, the red to D/A2 the orange to D/
A3 and the black to ground.
There should be four other loose
wires: the blue goes to IN1, grey to IN2,
brown to IN3 and white to IN4. Two
leads need to be run from the anode
of D3 to TP14 and from the remaining
PC stake to TP4 on the power supply
board.
Fig.3: the parallel port interface board is mounted at one end of the chassis,
with the DB25 connector protruding through the rear panel. Use this chassis
wiring diagram and the wiring table from last month’s issue to make the offboard connections. Because only low currents are involved, you can run the
connections to the interface board using rainbow cable
February 1997 19
to the positive output voltage.
If you set the front panel voltmeter
to read the positive supply voltage and
short the positive output, the current
reading on the computer should read
.05 and the digit colour should change
to red. Also the positive voltage should
read 0 or .1 and again should be red,
indicating that it is not the selected
value.
The current limit changes colour
as the limit setting is reached to let
you know that the power supply is in
current limit mode.
Voltage calibration
The interface board mounts vertically on one side of the case and is attached to
the rear panel via the rightangle 25-pin D connector.
Mount the PC board to the back pan
el using the hex head bolts to secure it,
with the components facing the power
transformer. We stuck a mounting foot
on the metal chassis to keep the board
parallel to the case, and another on the
plastic cover to keep the board firmly
in place.
Testing
You will need a 25-way D female to
25-way D male cable to connect the
computer to the power supply. This
done, load GW Basic and SCREG.BAS
and follow the on-screen instructions
(see Fig.5).
As there are no previous values
saved, you should enter 10V for the
positive voltage, 15V for the negative
voltage, .05 for the current limit, and
1 or 2 for whichever printer port you
plan to use. It is probably wise at
this stage to use LPT1, the parallel
port you have been using to drive
your printer, as you know that this
port works.
When you switch the power supply
to remote, the voltages you have set (or
values very close) should be displayed
as in Fig.5.
Pressing the plus key should in
crease the positive voltage and the
minus key should reduce it. If you
press the “T” key the negative volt
age should reduce to the same value
as the positive and follow it. This is
the “tracking” condition whereby the
negative output voltage is always equal
Software Features
Positive and negative voltage setting in 100mV steps from 0-25.5V
Individual output voltages or negative supply tracking positive supply
Current limit setting in 10mA steps from 0-2.55A for both supplies
simultaneously
Computer screen readout of positive and negative output voltages
Voltage reading changes from yellow to red for out of tolerance voltage
Computer screen readout of positive supply current
Current reading changes from yellow to red at current limit
Selection of printer port 1 or 2
All settings are saved and can be restored at program start
20 Silicon Chip
In spite of the fact that the power
supply will have already been cal
ibrated for standalone operation, it
needs to be recalibrated for computer
control.
The procedure is similar to that
outlined last month.
Set both supply rails for 24.5V out
put and with your DMM across the
negative output and ground, adjust
VR4 until the voltage reads exactly
-24.5V. Now set VR6 so that the posi
tive output voltage is identical.
If you can measure current with
your DMM, find a 10Ω 5W or 10W
resistor and connect it in series with
your ammeter across the positive sup
ply. Set the voltage to 22V and set the
current limit for 1.95A.
Disconnect your DMM, switch it
back to volts and with just the 10Ω
resistor for the load and using the
front panel meter to check that the
current is around 1.95A, adjust VR5
so that the voltage on TP8 is 3.82V
(1.96 x 1.95).
If your meter can’t measure current,
wire the 10Ω resistor across the pos
itive terminal and earth, then set the
positive voltage to 22V and the current
limit to 1.9A.
Measure the voltage across the 0.1Ω
resistor in the emitter of Q2, multiply
it by 1.96 and adjust VR5 until you
can measure this voltage at TP8. Be
careful as the resistor will get very
hot. This will not be quite as accurate
as the previous method as it assumes
that the resistor value is exactly 0.1Ω.
The linearity of the power supply
output voltage versus the computer
setting is excellent, with the DMM
reading precisely tracking the reading
on the computer screen.
The voltage fed back to the computer
is not quite as linear. There are slight
errors in the converted voltages due
Fig.4: actual size artwork for the PC board. Check your etched board carefully
against this artwork before installing any of the parts.
to A/D linearity around half scale,
resistor tolerances, etc.
We have made provision in the soft
ware to apply five correction factors to
these readings.
The first is for values between 0 and
5.5V, the next between 5.6V and 11V,
the third between 11.1V and 16.5V,
the fourth between 16.6V and 22V and
the last between 22.1V and 25.5V. This
will be explained later in the software
description.
Parallel port
Before we start discussing the soft
ware we should give a quick rundown
on the parallel printer port and its
peculiarities.
It was originally designed to drive
an 8-bit parallel printer, with suffi
cient additional lines to provide data
transfer in both directions, such as a
BUSY line to prevent the computer
feeding data to the printer faster than
it can process it and a PAPER OUT line
to allow an intelligent message to be
shown on the computer’s screen if this
should occur.
Because the original interface was
for a Centronics printer, some bits are
true high, others are true low.
These signal lines are split over
three addresses on the IBM interface.
For LPT1 which is the normal (and
often only) printer port supplied, the
addresses are 378H (hexadecimal, 888
in decimal) for the eight data lines,
379H for the next five lines and 380H
for the remaining four lines. These are
often called ports A, B and C.
The data lines of port A are unidi
rectional, capable only of sending data
to the printer. The other nine lines can
be used as inputs and those of port C
can be used as outputs. This gives us
the capability of sending and receiving
8-bit data from an external device to
the computer.
Port B has the highest bit inverted
and port C only has one of its four bits
true high. A subroutine in the software
(at line 3000) untwists the input value
Parts List
1 PC board, code 04101972, 178
x 105mm
1 rightangle 25 pin D male connector (COON1)
4 20-pin IC sockets
3 16-pin IC sockets
1 14-pin IC socket
10 PC stakes
2 3mm x 15mm machine screws
4 3mm x 10mm machine screws
6 3mm nuts
8 3mm flat washers
6 3mm spring washers
tinned copper wire
hookup wire
Semiconductors
3 74HC573 octal latch (IC1-3)
1 74HC137 latched 1-of-8 decoder (IC4)
1 74HC14 hex Schmitt trigger
(IC5)
1 74HC147 decimal-to-BCD encoder (IC6)
1 74HC4051 analog multiplexer
(IC7)
1 ADC0804 analog-to-digital converter (IC8)
4 1N914 diodes (D1-D4)
Capacitors
1 100µF 16VW electrolytic
4 0.1µF MKT polyester
1 .022µF MKT polyester
1 .001µF MKT polyester
1 150pF ceramic
Resistors (0.25W, 1%)
4 1MΩ
27 20kΩ
2 47kΩ
23 10kΩ
February 1997 21
Only a few connections need to be made from the interface board to the power
supply board. The wiring diagram (Fig.2) has the details.
which is the sum of port B and port
C and gives a true value (TIN) for any
data placed on these lines.
Software
The control program has been
written in GW Basic, using screen
9, the highest resolution (640 x 350
pixel) colour screen. Contrary to the
statement in last month’s issue, the
software will work with EGA and VGA
monitors, not just VGA types.
The software code is quite conven
tional and will run in QuickBasic if
lines 1-14 are removed. You will also
have to create a separate program
containing just lines 5100-5199 and
run it to create the file before you run
the main program.
Space does not allows us to present
the full software listing in this article
but we have included the main section
from lines 20-999.
Lines 20-70, as you can see from the
comments, define the functions to be
22 Silicon Chip
used, paint the introductory screen,
read the previous settings from the
hard disc and give you the option of
reusing them or entering new values.
Should you wish to retain an exist
ing value, just press ENTER. The value
will be accepted and the program will
step to the next item. This is useful
should you just wish to change the
printer port for example, but retain
the previous voltage settings.
The values you selected are now
written to the screen (line 60) then
sent to the power supply in line 70.
By structuring your program in this
way you can write and debug each
subroutine individually. Then if you
decide to include an additional fea
ture, it is only a matter of writing the
routine, debugging it, then adding a
gosub in the appropriate place.
Main program
The main program, after the initial
isation and preliminary housekeeping
(lines 20-70), consists of lines 80-160
which, while there is no keyboard key
pressed, will run lines 100 and 110
continuously. That is, read the data
from the power supply and write these
values to the computer screen.
As the standard 8x14 text numerals
look quite insignificant on the screen,
we produced some larger, chunkier
numerals using a rectangular block
(CHR$219), defined on line 1260 and
drawn by subroutine 4000.
Keyboard input
When a key is pressed the program
branches to line 10000 which is the
keyboard service subroutine. If a key
which it recognises is pressed it will
carry out the command and send a
new value to the power supply. If a
non-programmed key is pressed, it
will be ignored and the program will
return to running lines 100 and 110.
If you read the comments at lines
10021 to 10028 you will understand
which keys do what. We used both E
and V for the positive voltage and A
and I for current, accepting both upper
and lower case characters, just so you
don’t have to try to remember which
keys to use. When you are typing the
program there is no need to include
the comments but if you come back to
study it at a later date, they will help
your understanding.
As described previously we have
two functions, read from and write
(send) to the power supply. We
read the power supply voltages and
current and write values to the D/A
converters.
Writing to D/A converters
The write function is carried out
by first placing the value we wish to
write to a particular D/A converter
on PORTA, then writing its address to
PORTC. These addresses are listed in
lines 1330-1400. The address for the
first D/A converter ODA1 is 9. We can’t
call it DA1, as we have defined D as a
string in line 1030.
You will notice that all the addresses
are odd numbers, which indicates that
the strobe line will be low (as we have
explained previously, the logic for this
line is inverted).
When the address is written to
PORTC, pin 4 of IC4 (latch enable) will
be pulled low but after a short delay
will go high as the .001µF capacitor
charges through the 10kΩ resistor.
The strobe is then taken high again
to prevent the A/D converter being
enabled (see “reading power supply
values”) and placing data on the POR
TA bus. ODA1 is now deselected, as
any changes to PORTA data would be
transferred to IC1’s output.
Now the data which was present on
PORTA has been latched by IC1 and
is available as an analog voltage at D/
A1 output. The other converters are
loaded in a similar manner.
When we write to the D/As we al
ways update the three of them and this
is done in subroutine 8000.
Listing 1
20 GOSUB 1000 ‘Initialise
30 GOSUB 2000 ‘Write screen heading
40 GOSUB 5000 ‘Get previous saved values from file
50 GOSUB 6000 ‘Write old settings to screen with option to change
60 GOSUB 7000 ‘Write selected data to screen
70 GOSUB 8000 ‘Output data to power supply
75 ‘MAIN PROGRAM loop 80 - 160 starts here. Monitor power supply & keyboard
80 K$ = INKEY$
90 WHILE K$ = “”: K$ = INKEY$ ‘While no key is pressed
100 GOSUB 9000 ‘Read data from PSU
110 GOSUB 7000 ‘Write data to screen
120 WEND ‘A key has been pressed
130 GOSUB 10000 ‘Service keyboard
140 GOSUB 6360 ‘Update preset values
150 GOSUB 8000 ‘Write new values to power supply
160 GOTO 80 ‘Loop again
900 GOSUB 5100 ‘Save power supply settings
999 CLS: SYSTEM
Fig.5: the positive and negative output voltages are displayed on screen, along
with the output current. Also shown are the instructions for varying the output
voltages and for setting the current limit and tracking.
Reading power supply values
To read a value from the power
supply we latch its address into IC4.
This time we don’t take the strobe line
high as we did previously, as we want
to turn on the A/D converter, IC8.
After the delay introduced by the
resistor and capacitor between the
output of IC5a and the input of IC5f,
this will be the case as its chip select
(CS) will go low. This connects its
tri-stated output to the PORTB and
PORTC bus.
For the PORTB and PORTC lines to
be used as inputs they must all be set
high. Then they will either stay high
or be pulled low by the A/D. This
procedure is carried out by subrou
tine 9000.
The last area to cover is the line
arisation of the readings returned by
the power supply. Lines 1420-1440
list the correction factors we found
satisfactory for our supply. These are
implemented in subroutine 9000 on
lines 9140, 9210 and 9280. These have
been REMmed out and values of 1.0
substituted in lines 1411-1413.
The procedure is to make a table of
the output voltage at the terminals ver
sus the voltage shown on the screen.
You then cal
culate the adjustment
factor to give the correct reading for
each range. Once you have the values,
delete lines 1411-1413, remove the
REMs from lines 1420-1440 and enter
SC
your values.
February 1997 23
|