By Dirk Francois Raath Submitted in part fulfillment of the

By Dirk Francois Raath Submitted in part fulfillment of the
DEVELOPMENT OF AN INTELLIGENT NICKEL-CADMIUM BATTERY CHARGER
By Dirk Francois Raath
Submitted in part fulfillment of the requirements laid down
for the
Master's Diploma
in the School of Electrical Engineering
at the Cape Technikon
November 1991
Research And Development Centre
Department of Posts and Telecommunications
Declaration
I declare that the contents of this thesis represents my own
work and the opinions contained here are my own. It has not
been
submitted
before
for
any
examination
at
this
or any
other institute.
/';'7
D.F.Raath
,ll
J/ltCb~0-·
T"~-----------
(Signature)
Abstract
This thesis describes the control system as well as the
charge
and
discharge
circuitry
developed
to
efficiently
charge nickel-cadmium batteries. Due to incorrect usage and
charging
of
these
batteries
their
life-spans
and
output
capacities are drastically decreased. Efficiency is improved
by cycling the batteries which extends their life-span and
performance.
"Cycling"
refers
to
a
discharge
and
charge
process.
Opsomming
Hierdie verhandeling beskryf die beheereenheid sowel as
die laai en ontlaai kringe wat ontwerp is om nikkel-cadmium
batterye
effektief
te
laai.
As
gevolg
van
die verkeerde
gebruik en laaiproses van die batterye word hul lewensduurte
en
lev;eringsvermoe
verhoog
deur
die
drasties
beperk.
batterye
te
le,·;ensduurte en le\·;ering verbeter.
ontlaai en laai proses.
Doeltreffendheid word
" s irkuleer"
v;at
hul
"Sirkuleer" verwys na 'n
~~~~~~:~~~~~~~;~~~~::;~;~~::;~;~
;:;::.: ~ :; :.:~:~~~;;~:~~~;~~~;
i; ~;~~; i;:;;;;i
~ J::!~i!;:i!~ ]!;;:/!i!!;i!'
:.: :.: :.:
:.:
,.... .
:
:.:
'"
...... .. . . .. . ........ ..... .... .. ....
..
.
.
..
..
.
.
.,
.
.
..
.
..
.... .. .... . . . . .... . . .. .... ... .. ... ...
. . . ... . . .... ..,.. .. .. ..
.
,
,
...
•••
••
eO.
"
,
,
.,
•••
••
•
':':.' .':';
. ..
..
. .. .
.
..
'"
-
..
"-
"
.. . . . . .
-
..
..
.
,
eo'
.'
. ..
.
.
-----~/
INTELLIGENT NI-CAD CHARGER COUPLED TO PC FOR DATA LOGGING
INTELLIGENT NI-CAD CHARGER AS IT WOULD BE USED IN PRACTICE
CONTENTS
1. Objective.
1
2. Introduction.
2
2.1 The Batteries and Specifications.
2
2.2 Existing Charging System.
3
3. Use Of The Intelligent Battery Charger.
4
3.1 Operation Of The Charger.
4
3.2 Improved Efficiency.
5
3.3 Increased Life-Span.
6
4. Hardware Design.
4.1 The Main Power Supply.
4.2 The Charge/Discharge unit.
8
8
10
4.2.1 The Charge Circuit.
10
4.2.2 The Discharge Circuit.
11
4.2.3 The Voltage Converter.
12
4.3 The Processor Unit.
16
4.3.1 The Processor and Latch.
16
4.3.2 The Input/Output Port.
16
4.3.3 The Analog-Ta-Digital Converter.
16
4.3.4 The Hex Keyboard Encoder.
17
4.3.5 The Multiplexer.
17
4.3.6 The Real-Time Clock.
18
4.3.7 The Display.
18
4.3.8 The EPROM.
18
4.3.9 The RS-232 Port Facility.
19
4.3.10 The 3-To-8 Line Decoder.
19
5. Software Development.
5.1 Addressing and Control Words.
21
21
5.1.1 The EPROM
21
5.1.2 The Input/Output Port.
21
5.1.3 The Analog-To-Digital Converter.
22
5.1.4 The Display.
22
5.1.5 The Real-Time Clock.
23
5.1.6 The Hex Keyboard Encoder.
24
5.1.7 The RS-232 Serial Port.
25
5.2 Program Listings
25
5.3 Flowcharts
25
6. Problems Encountered.
53
6.1 Hardware.
53
6.2 Software.
53
7. Operating Instructions.
54
7.1 Initial Power-On.
54
7.2 Charging After Initial Power-On.
7.3 Charging Subsequent Batteries.
7.4 Using The RS-232 Serial Port
54
55
56
8. Test Results.
58
9. Bibliography.
63
10. Acknowledgments.
64
1
1.
Objective.
The
objective
of
this
project
is
to
improve
the
efficiency of nickel-cadmium (Ni-Cad) batteries which are
used by the Security section of the Department of Posts and
Telecommunications and others. These 12 volt batteries are
used to power two-way radio transceivers.
Limited
usage
of
these
radio
systems
causes
only a
slight discharge of the batteries. The batteries are not
allowed to discharge fully under normal conditions as they
are
too
frequently
charged.
If
a
battery
is
repeatedly
cycled shallowly it appears to lose its latent capacity. For
example,
if a battery is repeatedly cycled to a 20 percent
depth of discharge, the additional 80 percent of its
capacity will become unavailable to the user. This result is
called the "memory effect". A consequence of the memory
effect is that the batteries no longer function properly
when
used
extensively
before
being
charged
again.
It is
evident that the life-span of these batteries is shortened
due to this improper usage.
A further improvement, which is achieved as a result of
the first, is to increase the life-span of the batteries as
they are costly to replace.
2
2. Introduction.
The
Research
And
Development
Centre
undertakes
development of electronic circuitry (analog and digital) by
modifying existing equipment and building new systems.
specific proj ects like this one are usually requested by
various
sections
Telecommunications.
of
the
Department
of
Posts
and
2.1 The Batteries and Specifications.
A battery
nickel-cadmium
consists
cells
alkaline battery.
of
ten
connected
1. 25
in
volt
series.
Its electrolyte is a
sintered plate
A cell
is
an
neutral base which
does not react chemically with active materials. The
electrolyte acts only as a transfer medium for electrons.
The cell is constructed of nickel support plates which are
impregnated with the active materials in a powdered form.
These plates are then formed and assembled into a cell. The
case is made of nickel plated steel.
The use of powdered
active materials results in large surface areas which lowers
the internal resistance of the cell. This makes high rates
of discharge for short periods of time possible.
contain
a
one-shot
safety
vent
in
case
the
The cells
battery is
massively overcharged and produces gases. If the safety vent
is used, the cell's electrolyte quickly dries out and the
cell is effectively ruined.
The cell has a lifetime of up to 500 cycles. Since most
batteries are improperly charged, it is common to see them
fail after less than 100 cycles.
The battery specifications are:
Type: Sealed sintered Plate Nickel-Cadmium
Voltage: 12 V Nominal
Capacity: 600mA/Hr
3
2.2 Existing Charging System.
The batteries are charged regularly by inserting them
into a self contained charger unit. It automatically starts
to charge a battery when it is inserted and continues to do
so until the battery is removed. The charging time is not
controlled and the batteries may be over- or undercharged
when removed from the unit.
can
Referring to the circuit diagram shown in Fig. 1. it
be seen that there is no provision for current
regulation.
The charge current is therefore not constant
and varies depending on the battery's condition. The maximum
specified charge current (See Section 4.2.1)
is easily
exceeded and can cause damage to the cells.
current also drops
increases.
over
a
period
as
the
The charging
battery voltage
charging Voltage - Battery Voltage
I
(charge)
resistance
i
---l
220V
!
r----~
180
I
I
I
LED
i7;.r
r
25v
1
,
I
!6l BATTERY
I T(UNC=R
ChARGE
4
3. Use Of The Intelligent Battery Charger.
The operating instructions of the unit are described in
section 7.
3.1 Operation Of The Charger.
Refer to Fig. 3. Once the batteries have been inserted
and an 'F' entered via the keypad the process will start. A
status word is generated to indicate at which positions
batteries were inserted. This status word is ~otated through
the carry flag which will be set every time a battery is
detected. Since the condition of a battery is not known when
it
is
inserted
in
the
charger,
the
battery
voltage is
scanned and compared with the discharge cutoff voltage. When
under load the output voltage at which a cell is considered
to be empty is called the "discharge cutoff voltage" and
between 10 and 20 percent of the capacity remains at this
point. Figure 2 gives the cutoff voltages for the various
discharge rates. using the C/3 rate the battery voltage is
therefore 10 Volts for 10 cells (C = capacity of battery in
AHrs; 3 = Charge time in Hrs). Discharging beyond this
point, ie. CID to C/2, lowers the battery's efficiency and
shortens its life.
If the battery voltage exceeds this cutoff voltage, the
battery will be discharged until the battery voltage has
dropped to the cutoff value. The discharge process will then
be stopped automatically.
If the battery voltage is smaller or equal to the
cutoff voltage the battery will be charged for 14 hours.
The
charging
process
discharge circuit is
is
started
switched
by
ensuring
that
the
off and by taking the time
from the real-time clock and adding 14 hours to it. This new
time
is
circuit
then
is
stored
activated.
as
an
''1hile
alarm
this
time
and
charging
the charging
process
is in
progress, the alarm time is regularly compared with the
5
real-time clock. When they are found to be equal, 14 hours
have passed and the charging process will be stopped.
Although the battery voltage rises above the cutoff value
during the charging process, the
disabled for that specific battery.
discharge
circuit
is
After completion of the charge process, the cycle
counter is decremented. If it is unequal to zero then the
battery will be discharged again until the cutoff value is
reached and then charged again for 14 hours. This cycling
will continue until all the cycles have been completed. A
flag-bit in the status word will then be reset to prevent
the battery from being cycled further. The process will
always stop at the end of a charge cycle. While the process
is in progress more batteries may be entered. When another
battery is entered the status word is changed (a flag-bit
will be set) to indicate its presence.
This cycling process will be performed simultaneously
and independently for all batteries entered. The status of
all batteries entered will be indicated on the display.
3.2 Improved Efficiency.
The
first
and
main
objective
is
to
improve
the
efficiency of the batteries. This is achieved by cycling the
batteries which ensures that the batteries do not build up a
memory effect or to erase the effect in batteries where it
exists already.
The
discharge
cycle
ensures
that
the
batteries
are
artificially loaded to simulate a normal discharge process.
This prevents the formation of a memory. The whole process
is
controlled
charged or
memory
and the
batteries
over-discharged.
effect
ensures
that
are not
over-
The
resultant
the
battery
required power over the full period.
or under-
absence
will
of
the
deliver the
6
3.3 Increased Life-Span.
As a
are
result of the
able to
period.
deliver the
improved efficiency the batteries
required
power over the expected
Previously a battery would fail
as soon as it was
used outside its memory capacity. This means that a battery
can now be used over a longer period before it needs to be
charged again.
The overall life-span is also
increased as
the batteries will last longer.
DISCHARGE CUTOFF VOLTAGE FOR NI-CADS
WITH SINTERED PLATES AT 78 DEG. F.
105
VOLTS
PER
CELL
1. 00
.~---------------------
0.95
0.90
0.85
I
I
I
I
I
C
C
C
C
C
3
4
5
6
7
DISCHARGE RATE
START
7
ENTEfl TIME
-,
r-
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
FINISH
I
I
I
"
ENTBUNG 6.1. TTERI£S
'"_JI
I
I
I
I
I
I
I
I
,
OETERIHNE:
STArus
il'1JH(]
I
,
I
I
"';T
'"
B.lTTEllY PHES8IT
HAS
YES
ST~P
OISCi-lARGE
DI~~:n!"T I
r___
~I
I
'"
,
i
t,
, rES
I
r
k
:EChfi£~,
:T::1.::
I
*'
"'" "'CC"')"
3E
~"TE;';B
,
;c
:O';NTE~
8
4. Hardware Design.
4.1 The Main Power Supply.
The processor unit requires a 5 volt supply. Testing
the unit under full load has shown that a current of about
150 mA is required. The 5 volt supply is also used to switch
the charge and discharge circuits on and off.
The processor,
input/output
port
and
EPROM
are
sensitive to supply voltage variations. A steady supply must
therefore be provided. Refer to Fig. 4. A rectifier bridge
is used for rectification. Capacitor C2 provides the first
stage of smoothing.
The voltage at this point is about 7.5
volts.
the
By
varying
variable
resistor
R2
the
output
voltage of the regulator REG2 can be adjusted to ensure a
voltage of 5V at the processor (Refer to section 6.1). The
output capacitor C3 acts as a further smoothing circuit to
filter any remaining ripple voltage.
The charge/discharge unit requires a supply voltage of
about 24 volt which is only used in the charging circuit.
Rectification
is
again
done
by
a
rectifier
bridge.
The
output thereof is smoothed by Cl giving an input voltage of
about 29.6 volt to the regulator.
This
24
volt regulator
requires a minimum input voltage of 27.1 volt.
The output
voltage was found to be a constant 23.2 volt. Further
smoothing is not required as no sensitive devices are
present in the charge circuit.
782~CTV
~
:~J
2/\
1_ .._
?20V
lI
11
-
1
REG}]i--=23
C\J
+ Cl
'-
+
2:"~'~ -:E
23V
_.~,.----_.-.--~--
7V
".-,,"----
~
2
1
~2_J--
3
1
III
2~O
1<13P2()~
1
+
.~C3 ~
'H)
(JL
"
2
1
2
rn
+
L..
5V
~
2 I 220uF/16V
?200uF/16V
C\J
Cl.!
er:
\ () 1<
--..-----1.,., ~L- -----L
le I G
~.
.-l
GND
'"
10
4.2 The Charge/Discharge unit.
4.2.1 The Charge Circuit.
Ni-cads left in a discharged state for extended periods
will become inefficient and short lived. It is important to
charge a battery at a constant current or else the charging
period is influenced. A good general rapid charge rate for
the sealed sintered plate battery is the C/IO rate for 12 to
15 hours (C = Capacity of battery in AHrs; 10 = Charge time
in Hrs). The use of a simple resistive network will cause
the current to vary depending on the condition of the
batteries as is the case with the existing charger.
Refer to Fig.
5
(Page 14). A 5 volt regulator Xl is
used and connected as indicated. The current is determined
by the value of R6.
across
R6
will
The output voltage of the regulator
always
be
kept
constant
at
5
volts,
regardless of the battery 's condition, which ensures that
the charging current stays constant. The required charge
current is determined as follows:
Charge Current
R6
=
=
Battery Capacity/lO
600mAhrs/lOHrs
=
60mA
(C/IO)
= Regulator output Voltage/Charge current
=
5V/60mA
=
83
ohm
- 82 ohm
The switching circuit consists
of transistors Tl and
T2. The values of resistors are determined as follows:
Tl
Ic
=
60mA (charge current)
Ib
=
lc/hfe
=
60mA/40
=
1.5mA (to switch Tl on fully)
11
R49 = (Vcc-Vbe)/lb
= (23-0.7) V/1. 5mA
= 14.367 K ohm
- 15 K ohm
T2
lc
lb (Tl)
lb
lc/hfe
= 1. 5mA/11 0
= 13.6 /LA
Rl = (switching voltage-Vbe)/lb
(5-0.7)V/13.6/LA
= 316 K ohm
The maximum
base current allowed for Tl is 2mA. A 10 K
ohm resistor is used to switch it on fully. The base current
is 0.43mA and well within the limit.
4.2.2 The Discharge Circuit.
Due to the low internal resistance of the battery it is
possible to discharge it very
rapidly.
between C/3 and C/20 are normally used.
Discharge
rates of
(C/3 is used in this
application) .
This circuit
charge circuit.
virtually
lS
the same as
that
of
the
to Fig. 5. Only the differences will
Refer
be discussed.
The battery
is
discharged
through
T3,
the
5
volt
regulator and R5. The current is determined as follows:
Discharge Current = Battery Capacity/3
(C/3)
= 600mAHrs/3Hrs
= 200mA
R5
=
RegUlator
current
Output
Voltage/Discharge
12
= 5Vj200mA
=
25 ohm (22 ohm used)
The switching circuit consists of T3 and T4. The value
of resistor R50 is determined as follows:
T3
Ic
Ib
R50
=
=
=
=
=
=
=
200mA (discharge current)
Icjhfe
200mAj40
5mA (to switch T3 on fully)
(Battery Voltage-VbeljIb
(13-0.7) Vj5mA
2.46 K ohm
2.7 Kohm
The maximum base current for T3 is 5mA (hfe = 40). A
maximum battery voltage of 13 volt is assumed. A value of
2.7 K
ohm is selected for R50 to prevent the base current
from exceeding the maximum allowed value.
R65 is required to ensure that the discharge circuit is
switched off during a power failure to the unit. It pulls
the base of T4 to ground and keeps it switched off. During
the discharge process a potential of 5 volt is applied to
the base of T4 via R2. The actual base voltage is:
base voltage
= switching voltage x R65/(R2 + R65)
= 5V x 4.7Kj(10K + 4.7K)
=
1.6 V
This voltage is adequate to switch T4 on fully.
4.2.3 The Voltage Converter.
Refer
to
Figure
5.
Before
a
battery
is
cycled
its
condition is checked by taking a voltage reading via the A 0
line. A simple voltage divider is used to scale the battery
13
voltage down to about 5 volt. In the idle condition (before
starting or after completing the cycling process) a minimum
current must be drawn from the battery. A current of 1mA and
a maximum battery voltage of 14 volts is assumed. R3 and R4
are determined as follows:
I = Battery Voltage/(R3 + R4)
1mA = 14V/ (R3 + R4)
R3 + R4 = 14V/1.mA
= 14 K ohm
5V = R4/ (R3 + R4) x Battery Voltage
= R4/14K x 14V
R4
=
5V/14V x 14K
= 5.0 K ohm
-
5.1 K ohm
R3 = 14K
= 14K
= 8.9
-
R4
5.1K
K ohm
9.1 K ohm
.".,
~,~~
.,,~
.. "
'"
~
ru
~
/JCf.a7J.
.,
14
_u
""
,."
~
_u
•
""
"
~
,~
-~
'"
~
~
.,..."
,--,-""",,,-~,Ta
,
,."
81:107"
-L ..
•
-l-
~
~
••
•=
"H
- .:fM ...
..
'·n
•
BClQ7A
'---"-t
4.2
a
~m
.".,
-
m
~
"""""
"
~,~
-LSNl
.;.&loT"
T
L.'J
'I~Th:-,,_~.~~;...c~
- >...,;:/
,
,
S!lcl«:~
2i'
)
JOM
~.7l
~~
F$
I>lolJ
::~~
~:-t.l<: ","~Y
'J.F ,~ .... '~
::;;e,,:r
:C>i'<iG
:35\
.=
~~
- .
.,,,,
~
-
~
,.
e
T
""""
;:
u
~
15
e
~
cc
9
1lt107/o
H
,~
W
-
~~
~
~
-..•
'.n
,,~
~
IICtD7A
,~
....,
~.
~"
11
-
"~
actOJ'"
""••
~
H-"
..
.",
T
gj
!~>-
nlll~'flo!
r---LJ X:5
Talt.l')
~
:1- ,.
1
O".N«O
~ '-~':;~""~---+--~
Pi
~
6<
,
-------'
I'-"'"~""~'-hv~ &cl~7~
-,--
.
l
.,'~_
J.
O;'~
2.7"0:
~"'l;"'0l:'J7'
(:)<
4.To(
,-
.~m
,I
~
16
4.3 The Processor Unit.
Refer
diagram.
to
Fig.
6
for
the
controller
card
processor
is
schematic
4.3.1 The Processor And Latch.
An
803~
8-Bit
Control
used
which
provides extensive on-chip support for one-bit variables as
a separate data type, allowing direct bit manipulation and
testing in control and logic systems that require Boolean
processing. The Address/Data is shared on Port 0 and the
lower address-byte is latched by the 74LS573. The processor
specifications are:
128 Bytes Internal Data Memory
32 I/O Lines (Four 8-Bit Ports) Providing 5 Interrupts
2 x 16-Bit Timers/Event Counters
64K
Program Memory
application)
5V Operating Voltage
(Only
8K
is
used
in
this
3.5 to 12.0 MHz Oscillator Freq. (external clock source
used)
4.3.2 The Input/Output Port.
The 8255A has
ports)
24
Programmable I/O pins
(three S-bit
and is used to interface the charge/discharge unit
with the processor system.
Port A is used to
switch the
charge circuits and port B to switch the discharge circuits.
The eight data pins (00-07) receive data from the processor
and send it to the appropriate output port. Port control is
done via the two address pins AD and Al. operating voltage
is 5V. The output port-voltage switches between OV and 5V.
4.3.3 The Analog-To-Digital Converter.
The ADCD804 is an a-bit successive approximation AID
17
converter. The TRI-STATE output latches drive the data bus
directly and no interfacing logic is needed. It converts the
battery voltage to a digital value varying between 0 and 255
ego OV = 0 (digital) and 5V = 255 (digital). The reference
vol tage, which is obtained by using a 2. 5V zener diode
(LM336-2.5), is doubled internally by the converter. The
battery voltage is compared with this reference voltage and
converted. The specifications are:
4.5 to 6.3V supply voltage (5V used)
o to 5V analog input voltage
lOOuS Conversion time
4.3.4 The Hex Keyboard Encoder.
The 74C922 l6-Key encoder has an internal debounce
circuit that needs only a single external capacitor. The
Data Available output is used as an interrupt to indicate
when a key is pressed. Key-values are encoded into digital
values from 0 to 15. The supply voltage may vary between 3
and l5V.
4.3.5 The Multiplexer.
The CD405lB is a single a-Channel analog mUltiplexer/
demultiplexer which is used as a multiplexer in this
application. It has three binary control inputs A, Band C
which gives an a-channel selection.
The output,
pin 3,
is
taken to the input of the analog-to-digital converter. The
specifications are:
5V to l5V Supply voltage (5V used)
-O.5V
to
l5.5V
Input
voltage
(analog)
on
the
channels (OV to 5V used)
-O.5V to l5.5V output voltage to the A/D converter.
(OV to 5V used)
8
18
4.3.6 The Real-Time Clock.
The MC146818A Real-Time Clock provides the oscillator
frequency for the processor via the CKOUT pin, which
eliminates the need for a crystal at the processor. It also
keeps the time. with the CKFS-pin tied to +5V, the CKOUT
frequency is the same as that of the crystal. The clocks I
main function however is to time the charging period of 14
hours. The specifications are:
Complete Time-of-the-day 12- to 24-Hour clock.
Alarm and one hundred year calendar.
Bus Compatible Interrupt.
Clock output to be used as Microprocessor Clock Input.
50 Bytes of lowpower static RAM.
3 to 6V Operation.
Only the
Time-of-the-day,
Interrupt
and
Clock Output are
used.
4.3.7 The Display.
The
LTN211
is
a
5x7
dot,
16-character,
2-line
dot
matrix LCD module, with driver and controller mounted on a
single printed circuit board. Contrast is adjusted (R9)
by
varying the voltage between 0 and 5V. It has a built-in 160
character generator. The supply voltage must be between 4.75
and 5.25V.
4.3.8 The EPROM.
The
Intel
erasable
and
(EPROM).
It
2764
is
a
electrically
has
a
5V only,
65,536-bit ultraviolet
programmable
standby
mode
read-only
which
consumption without increasing access time.
reduces
memory
power
It is selected
by applying a TTL-high signal to the Chip-Enable input (pin
20). The supply voltage may vary by approximately 5%.
19
4.3.9 The RS-232 Port Facility.
The levels for the serial port
analog circuit using two transistors,
are provided by an
one to transmit and
one to receive. The positive RS-232 transmit level
(aT) is
provided by using C2 as a voltage doubling capacitor. The
negative receive level (IR) is provided by the existing
serial port from the personal computer. The serial port
connections are:
IR to Transmit Pin (PC-side)
aT to Receive Pin
(PC-side)
Refer to PC manual for RS-232 connections.
4.3.10 The 3-To-8 Line Decoder.
The processor board is memory-mapped and selection of
the various
the 74LS138
C) provides
are used in
devices eg. RT-Clock, display etc. is done by
under processor control. Three inputs (A, Band
a selection of eight outputs. Only six outputs
this application. The specifications are:
2 to 6V supply voltage
o
to 6V input/output voltage
'U~
-~-1 ~
' " -----,l elfl"-,1--'~,---:
~" ' '" ,.::
- ~-+
±:; ~_-g: :1A~
t -~·
~~C~
""~
~~------,-- . ---"
'bV
"'1
~~:!' Ij',]: ;:
I"]
lOul!lOV 1:1
U1
flUit!
.. ONO
,--,1c
l'_
L--
3D
'", L
. ...
-
-
CW
PO.O
1'...ADlL._
.....•.X.l
"2'
P2.2
jit ,,,-,,,,,
t\:AU6~
l'~.o
~_~.
~~'~
~'liV
~j"L""'J
l L.. _~
i.i·!' ~, "'"u
-~~j"r _..A15_
jl.
~T
1'17
Xl All
A
B
~'l
f-'~
P3. 7
--'-,
.1!i ...111.2
...... ....._.,03lAH
T1
fll.
1
I,V
QII'I'I.Y
;;i """"
II'"
, ["
1~;H1n
~.
· ,"
t1
--
1 'v'VV'-")-
114
I~~";']J I~'~II
[:[:].
IH
.
1'6
liM)
lN~
-1 .
\4fl
fJI);'
lK
"
fl~
".
I
1.
"'t_
"r"
IDLJI/lOV
If
r.;'
!L__
jI
lB
_T
L/
ONO I
t5V
~1
Il
I,(~N_rJ
11 ---
-.
tJLI
74C9??
n
__
lO11 r
GND
UllL,
~."
,
+
= "~ j'.r~lr:::===~=~1l:;;:',~
••__ ..J__ (;'1__' -
+ ~,y
21~~~O!l
~.O/J~_.
..I..~....
_
~
UA
,
'-Iln
15V
'1
;~v
cc>
INnEF
DB4
085
IIGND
DONO
f:l
'
RO
-
-l-r,-I)~
~
I,NlI
!;Nll
Ho,
w
~
<r
~
x
u
All2.
31
30
28
w
~
~
PBo
PB5
,.
14
pB] _,. --L
!CO 15
PCl
Dl
03
02
04
05
9i
x
U
if>
en
~
D
p~~ Il3
ti2
11
Pp'C'3
Il7
i.~~ tiO
O~
8255A
U7
12
1'·------
11
19
INH
"=..
5_----J
PL./
B r-g-EL.../
C
__.__.__
I
'"' "'
l~Opf
GND
-r
A jQ--E2..-/
o _tJ
14
'15
-,.,- Cl
I
~
1'·-'lL.Ll! 0/1
,,,
~
rl
12.
Z
~
~ ~4
7
ut}
P4
..
4 ).------------.
GNO
_
~
,
D
~
CD~a5lB
CKFS
:~~
s'tSY
1102
MO I
A03
/IS
~w
/lOG
DS
AD7
GNO
---------.-- ._._-
:~~ _.1D.-AD
CKOUT
GNO
T
PS I
t:
--..-£,•.
.2.1..LKOUJ
2J
m;Cl
t(i(j
DSC,'
GNU
1!LL"!.~O
-.J2__
J
:::=":::"":-'::'9:--:1
L ....."
+5'0'
6
~
__ ,AD
~
saw
GNO
liNll
PB~ ~
~
00
-.lL-AD~,-/
.ADfi.
DB5
----14ti8iuA
Hili
DY~
C07
CLKOUT~.
nh;fi
/10<
~'~K
-
voo
•
PB3 ".--;;
34
lS.........-AD3....-1
14
\.<1
.-
-_.
/lOC0!304
I"i
Alii
'l~ ,,, '
15
DB2
0113
'< AB
+5'0'
C
'j
081
r vcc
TNt
_ GNIJ
]
[t-=I""II
l11"'"']I"
.,,,.,
-~~ .. "~~aY[;O;rm
IOK
,,*""LK
,I~
-1~
1
I
I--._ ..
39
=
"
J!L_-'L
19
.'.L
PBO
PBI
rulli
5
18
17
~ 1--*7
•,
P
lNfi1
000
206
PA4
eH
I'-_AQ<>-.i:!l 06
"
Aill_ 27 D7
._
U5
31 Wi1
~·'w
'AD
110
20_'
P"'I21'
•
'"
t~
..£S1
~:',,:
"3
PAl
•"
1'--
.
-'--2764
'"jJ_L~.n~t~:
-~~1'\7-'
~:, "~-.
[Cl _ 12 _]l )
-11:
cn--=:
rx
,
'''OND
1
__
I
HX
".' . ",L..!/'
1'1
:; [,7,
,
,5.3__,
_ _, - -1'L,;,.
,. 'R
r
,""" '1
fji_CSL/
YiY4 b'L
'2B
-"Ili~
1"
'So" or.
"LmA
'
."I"
G1
G2A
GNO
5V
I?'
!.L1~;-'
Pl
36
355 We
RESET
"15
07
06
~
13 ~~
1"-.J:S3~
ILJ;,A.-/
YO
Yl
Y2
Y3
,
U6
cs
PAD t'j1=:
,
,--.,--"-
03 16
04 17 J>IJO,
05 -lL..AoL./
+.
m"
,,,,>,_.
l'--lNT1L.
__ Pl. 3
..1.1
'..1'6_,_-" 1'14
" .11i
1"'-1.1.i
'_.... 1'1.5
' ...
, 1 ' U 1 , 17
1~1
'"'"02
"
L!.-.A"!,/ '-"3
P~.
l"--l!.1-----~
Jl
OKDUL..JQ
•
"fJ-.AL./
3Q
""
" '"
4 Ao
24
,5 50
50 14-<15..../ l'3 A6
P2''-',"__,11
".A'iiL-.2 60
50 1l3' ""',
5 A)
P2,4 2.5
lV
70
'A) -,
-AB
AB
5 lL...iiT/ i'- AD1
9 Oil
Oil
21 A9
I'd 2B
"Al5Ci]
23 AlO
".7
_.
1"---AiL..£" All
11
.. . _
10
"'
U3 -" T.,
'" 27 '"
Pl.!
""'-iD PG,
1'3.' r 13
IN!I'
15 '5
.J:S"-,,,< CS
l"'-A5~
"A05..~11-
.
0
'"
3D
4H::I-~ "
..AJ
10 _
AD'
.
...
P2.0
'·ADL.;;I) 1'0 1
K:-.A02.__ ".H 1)0.2
t-...--....-r;D3_.1G P03
J!J PO.4
I'D."
'<::.Ob.. .. 'J l'Il.1i
'AUl
11. PO 7
1'1,0
'''''-.
'1'2
.. ,. I" 1
r'\.-l!J="_ l 1'1.2
(,Nil
LE
'
JOJi~ ~
GND
U4
IOK
DISPI
1~
AY
• AfUGIHNESS
CDNTRDI
GNO
_,AD~_ _ - :;
--~~
-
11
10
L TN211 I_CIl
cru
CiJNIIIOIIJI1 IWARD
FO~ EJ~
TII:IW
Il.F flMllj
CI+~110m
1001
'"o
21
5. Software Development.
The main program was written in assembler using the
ASM51 compiler. A modular programming approach was used in
order to simplify the writing thereof, debugging and to ease
understanding of the programming sequence.
Writing in
assembler also reduces execution time to a minimum. This is
important to ensure that after 14 hours of charging time the
charge circuit will be switched off. (Refer to section 6.2).
A program was also written in GWBASIC to capture data
via the serial port of a PC and to convert it to battery
voltages. See section 5.2 and 5.3 for program listings and
flowcharts.
5.1. Addressing And Control Words.
The processor board is memory-mapped and the 8K x 8-bit
EPROM allows for eight 8K bit-blocks to be addressed.
5.1.1 The EPROM.
CS-O selects the EPROM. No control words are necessary.
Start Address: OOOO-Hex
End Address
lFFF-Hex
5.1.2 The Input/Output Port.
CS-l selects the 8255-I/0 Port. The Port has 24 I/O
pins and is programmed in three groups of 8 pins, port A, B
and C. Port C is not used. Ports A and B are programmed to
be output ports only.
The Control Word is written to the
Control Word Address to set the port up for the appropriate
mode of operation.
Control Word: 81-Hex
Control Word Address: 2003-Hex
22
Port A Address: 2000-Hex
Port B Address: 2001-Hex
Port C Address: 2002-Hex (Not used)
Port
A
and
port
B are
used
to
switch
charge
the
and
discharge circuits on/off respectively.
5.1.3 The Analog-To-Digital Converter.
CS-2
selects the ADC0804
Converter.
No Control Words
are required to initialise the Converter.
Once the pointer
(DPTR) is directed to the Converter, any code may be sent to
start the conversion process eg.:
MOV
DPTR,#4000H
MOVX
@DPTR,A (Contents of Accumulator sent to Converter)
(converter Address
=
4000-Hex)
5.1.4 The Display.
CS-3 selects the LTN211 Display. The LTN211 incorporates
an
extensive
display
shift.
instruction set:
ON/OFF,
character blink,
The instructions
6000-Hex.
display
are
clear,
cursor
cursor home,
shift and display
sent to Control Word Address
The RS-line must be
low when
Control
Words are
sent to the display. It must be set when data is written to
or read from the display. The R/W-line must be low when data
is written to the display and set when data is read from the
display. The instruction set used is:
CONTROL WORDS
INSTRUCTION
1 RSIR/wl D71 D6 1 051 041 031 021 011 DOl
! 1
Display Clear
0
0
0
0
0
0
0
0
Cursor Home
0
0
0
0
0
0
0
Entry mode set
0
0
0
0
0
0
0
Disp on/off Control I 0
0
0
0
0
0 ,I 1
1 1 *
1 1I/O! s
D 1 C I B
Cursor Disp shift
0
0
0
0
0
Function set
0
0
0
0
1
I S/C! R/LI *
DLj 1 i 0 I *
I
0
i
0
I
*
*
23
*
Undefined
I/O =1: Increment
S
=1: Display shift
I/O =0: Decrement
=0: Display freeze
S
D
=1: Display on
D
=0: Display off
C
=1: Cursor on
C
=0: Cursor off
B
=1: Char. at cursor
position blinks
B
=0: Char. at cursor
position does not blink
S/C =1: Display shift
R/L =1: Right shift
SiC =0: Cursor move
R/L =0: Left shift
DL
DL
=1: 8-Bits
=0 : 4-Bits
5.1.5 The Real-Time Clock.
CS-4
selects
the
real-time
clock.
The
clock
memory consisting of 50 general purpose RAM bytes,
bytes which normally contain the time,
calendar,
has
a
10 RAM
and alarm
data, and four control and status bytes. All 64 bytes can be
read from or written to by the processor program except for
the following:
a) Registers C and 0 are read only, b) bit 7
of Register A is read only, and c) the high-order bit of the
seconds byte is read only.
ADDRESS MAP
CONTENTS
I
Address (Hex)
-----------------------------0\
SECONDS
8000
11 SECONDS ALARM
MINUTES
21
8001
31 MINUTES ALARM
HOURS
41
8003
8002
8004
5\
HOURS ALARM
8005
61
DAY OF WEEK
8006
71
DAY OF MONTH
8007
81
MONTH
8008
91
YEAR
8009
REGISTER A
800A
10\
24
111
REGISTER B
BOOB
12 I
REGISTER C
BOOC
I
REGISTER 0
BOOO
13
14
50 Bytes User RAM
63
The User RAM and Registers A and D are not used. The Control
Words for register Bare:
9A-Hex
Code to stop updating of RT-Clock
lA-Hex
Code to start updating of RT-Clock
The register bits are set as follows:
LSB 0: Set to 0- Disable daylight saving.
1: Set to 1- 24-Hour mode.
2 : Set to 0- Specifies binary-coded-decimal.
3:
Set to
1-
Not used.
4 : Set to 1- Enables the update-end flag bit in Reg.C.
5: Set to 0- Not used.
6:
MSB
7:
Set to 0- Disable the periodic interrupt.
Set to 1- stop updating.
0- Start updating.
Register C: This register is read only to determine whether
the update cycle is completed or not. This is indicated by
bit 7 and 4 being set. All other bits are unused.
5.1.6 The Hex Keyboard Encoder.
CS-5 selects the Encoder. The Encoder Address is 800AHex.
No
Control
Words
are
required
to
initialise
the
Encoder. When a key is pressed, an interrupt is sent to the
processor to initiate the reading of the keypad.
25
5.1.7 The RS-232 Serial Port.
No addressing is required. The serial port is set up as
follows:
MOV TH1,#OF7H This sets the timer up for a baud rate of 1200
MOV
TMOD,#20H
Control
word
to
specify
a-bit auto-reload
timer
MOV SCON, #52H Control word to set up the UART register
SETB TR1
To start the timer
Information is sent to the serial port as follows:
MOV SBUF,A
Move accumulator contents to serial port
JNB TI,$
wait until byte has been sent
5.2 Program Listings.
The
main
program I s
listing
is
shown
from
page
26
through 44.
The GWBASIC listing (CAPTURE) on page 45 shows how the
captured data from the serial port is converted to battery
voltages. Refer to section 7.4 for use of this program.
5.3 Flowcharts.
The
main
program I s
operation
is
illustrated
by the
detailed flowcharts from page 46 through 51.
The flowchart on page 52 shows how the battery voltage
is relayed to a PC in character format, via the serial port
at five minute intervals.
described in section 7.4.
Operation of the serial port is
LaC
aBJ
0025
0026
0027
0028
0029
002A
002c
0020
002E
oou
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
003A
003B
003C
0030
003E
003F
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
004A
004B
Q04C
0040
OQ4E
004F
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
005t.
LINE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
26
SOURCE
KEYSTORE1
KEYSTORE2
KEYSTORE3
KEYSTORE4
HRs
MIN
CYCLE1
DATA
DATA
DATA
DATA
DATA
aATA
25H
26H
27H
28H
29H
DATA
CVClE2
2CH
20H
2EH
2FH
30H
31H
32H
33H
34H
35H
36H
37H
38H
39H
3AH
3BH
3CH
30H
3EH
3FH
40H
41H
42H
43H
CYCLE3
DATA
aATA
CYCLE4
DATA
CYCLES
CYCLE6
CYCLE?
CYCLE8
ALM1SEC
AlM1MIN
ALM1HR
DATA
DATA
DATA
DATA
DATA
ALM2SEC
ALM2MIN
ALM2HR
ALM3SEC
AlM3MIN
ALM3HR
ALM4SEC
AlM4MIN
ALM4HR
AlM5SEC
ALM5MIN
ALMS HR
AlM6SEC
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
ALM6HR
DATA
DATA
DATA
DATA
DATA
DATA
DATA
ALM7SEC
DATA
ALM7MIN
ALM7HR
ALM8SEC
ALM8MIN
ALM8HR
DATA
DATA
DATA
DATA
DATA
BATTNO
DATA
BSTATUSO
DATA
DATA
AlM6MIN
BSTATUSN
2AH
4411
4511
46H
47H
48H
49H
4AH
4BH
4CH
4DH
4EH
CHARSTATUS DATA
4FH
DISCSTATUS DATA
COUNT
DATA
BFlAGl
DATA
SOH
51H
BFlAGZ
DATA
53H
BFLAG3
DATA
54H
BFlAG4
DATA
52H
BFLAG5
DATA
55H
56H
BFLAG6
DATA
57H
3FLAG7
DATA
DATA
DATA
saH
BFLAG8
TEMP
5911
SAii
LOC
OBJ
005B
005C
005D
DOSE
005F
0093
0094
0095
0000
0000 OZOO16
0013
0013 OZ055D
0016
0018
001A
001C
DOlE
OOZl
0024
0027
OOZA
0020
0030
0033
0036
0039
003C
003F
0042
0045
0047
004A
LINE
54
55
56
57
58
59
60
61
6Z
63
64
65
66
67
68
69
70
71
7Z
27
SOURCE
DATA
DATA
TEMPBSO
TEMPCHS
FLAG
DATA
DATA
DATA
BIT
BIT
BIT
OOOOH
RETDEL
SCANC
FINISH
RS
WRITE
ORG
LJMP
ORG
LJMP
5BH
5CH
5DH
5EH
5FH
P1.3
P1.4
P1.5
BEGIN
0013H
INT_SCAN
;GOTO BEGIN ~ITH POWER ON
;INT1 VECTOR ADDRESS
;WITH INTERRUPT: SCAN KEY80ARD + STORE CHAR
BEGIN:
;DISABLE ALL INTERRUPTS
WRITE
;5ET orsp WR TO LOW
P3.3
EXl
;5ET P3.3 HIGH TO PREPARE AS INTERRUPT
;ENABLE EXTERNAL INTERRUPT 1
100
LCALL
LONGDELAY
006F 90059D
1O'l
MOV
DPTR,#MINUTES
;SET POINT TO
0072 12047F
102
LCALL
MESSAGE
;DISP M!NUTES MESSAGE
0075 2Cs3FD
103
JB
104
105
LCALL
P3.3,$
SCAN
;JMP UNTILL KEY IS PRESSED
0078 120575
0078 F5Z7
0070 120405
MOV
K'EYSTORE3,A
;STORE 1ST DIGIT
106
LCALL
C:URSH
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
CLR
CLR
SETB
SETB
MOV
MQV
MOV
MOV
MOV
EA
CZAF
CZ95
DZB3
DZAA
755DDD
754000
754EOO
754FOO
755000
120401
12040D
lZ0433
lZ043F
90058C
lZ047F
ZOB3FD
120575
F525
1204D5
lZ04,3
0040 1Z0500
0050 E525
0052 1204C8
0055 120500
0058 2083FD
0058 1Z0575
DOSE F5Z6
0060 1204C8
0063 120500
0066 120405
0069 1204E3
006C 120500
FLAG,#OOH
; CLEAR FLAG
;CLEAR BSTATUSO
LCALL
BSTAruso, #()OH
BSTATUSN, #()OH
CHARSTATUS,#OOH
01 SCSTATUS, #OOH
SETUART
lCAlL
(WO ISP
LCALL
(WRTC
CW8255
;CLEAR BSTATUSN
;CLEAR CHARSTATUS
;CLEAR DISCSTATUS
;SETUP FOR SERIAL PORT
;SEND CONTR WORDS TO DISPLAY
LCALL
MOV
DPTR,#HOURS
LCALL
MESSAGE
;SEND CQNTR WORDS TO RT-CLOCK
;SEND CONTR WORDS TO 8255
;SET POINT TO HOURS MESSAGE
;DISP HOURS MESSAGE
JB
P3.3,$
;JMP UNTIlL KEY IS PRESSED
LCALL
SCAN
;ENTER 1ST DIGIT
MOV
KEYSTORE1,A
;STORE 1ST DIGIT
LCALL
CURSH
LCALL
CLEARDISP
LCALL
lONGDELAY
MOV
A,KEYSTORE1
LCALL
OPD I SP
LCALL
LONGDELAY
;DISP 1ST DIGIT
JB
P3.3,$
;JMP UNTILL KEY IS PRESSED
LCALL
SCAN
;ENTER 2ND DIGIT
MOV
KEYSTOREZ,A
LCALL
OPD ISP
,STORE 2ND DIGIT
,0ISP 2ND DIGIT
LCALL
LCALL
LONGOELAY
CURSH
LCALL
CLEARD I SP
MINUTES
;ENTER 1ST DIGIT
MESSAGE
lOC
OBJ
LINE
28
SOURCE
0080 1204E3
107
0083 120500
108
LCALl
LCAlL
0086 E527
109
MOV
0088 1204C8
110
008B 120500
111
LCALL
LCALL
CLEAROISP
lONGDElAY
A,KEYSTORE3
OPO ISP
LONGDELAY
008E 20B3FO
112
JB
P3.3,$
0091 120575
113
LCALL
SCAN
;ENTER 2ND DIGIT
0094 F528
114
MQV
KEYSTQRE4,A
;STQRE 2ND DIGIT
0096 1204C8
115
116
OPD ISP
LONGDELAY
COMBHRS
;OISP
0099 120500
;DISP 1ST DIGIT
;JMP UNTIlL KEY IS PRESSED
009C 120509
117
lCALL
LCALl
LCALL
009F 120519
118
LCALL
COMBM I N
00A2 120529
119
00A5 120533
120
00A8 120541
121
SETHRS
SETM I N
SETSEC
CWRTSU
;SET MIN OF RT-CLOCK
;SET SEC OF RT-CLOCK
R3,#18H
; R3 " COUNT " 24
OOAB 12044F
122
LCALL
lCALL
LCALl
LCAlL
OOAE 7618
123
MQV
OOBO 7834
124
00B2 74AA
125
2ND DIGIT
;SET HRS OF RT-CLQCK
00B4 F6
127
00B5 08
128
Mav
RO,#ALM1SEC
Mav
A,#OAAH
AlM_AA:
MQV
@RO,A
lNC
RC
129
DJNZ
R3,ALM_AA
;REPEAT UNTIL R3 " 0
;R3 = COUNT = 8
;SET RO TO START Of CYCLE ADDRESSES
;lOAD aOH INTO Ace
126
0086 DBFe
;SET RO TO START OF ALARM ADDRESSES
;LOAD AAH INTO ACC
;SET CONTENTS OF ALARM ADDRESS TO AAH
;INC RO TO NEXT ALARM ADDRESS
130
00B8 7808
131
MQV
R3,#08H
OOBA 782C
132
MQV
RO,#CYCLEl
A,#OQH
OOBC 7400
133
MOV
134
CLR_CYCLE:
OOBE F6
135
MQV
@RO,A
OOBF OB
136
INC
RO
OOCO D6FC
137
OJN2
R3,CLR_CYCLE
;SET CONTENTS OF CYCLE ADDRESS TO DOH
;INC Ra TO NEXT CYCLE ADDRESS
;REPEAT UNTIL R3 = 0
138
00C2 7608
139
MQV
R3,#08H
;R3 " COUNT" 8
00C4 7852
140
Mav
RC,#BFLAG1
00C6 7400
141
MQV
A,#OOH
;SET Ra TO START OF BFLAG ADDRESSES
;LOAD DOH INTO ACC
142
CLR_FlAG:
00C8 F6
143
MQV
@RO,A
;SET CONTENTS OF BFLAG ADDRESS TO OOH
00C9 08
144
QOCA D8Fe
145
INe
DJNZ
RC
R3,CLR FLAG
;INC RO TO NEXT BFlAG ADDRESS
;REPEAT UNTIL R3 = 0
146
147
UPDATE1:
148
OOCC 752800
149
MOV
OOCF 755El F
150
MOV
KEYSTORE4,#OOH
RETDEL,#lFH
;CLEAR KEYSTORE4
;SET COUNT TO 1FH
;CLEAR CARRY FLAG
;ENA8lE ALL INTERRUPTS
;MOVE FLAG INTO Ace
151
152
UPDATE:
0002 C3
153
154
CLR
C
0003 D2AF
155
SETB
EA
0005 E55D
156
MOV
A,FlAG
0007 9488
157
SUSS
A,#OBBH
; fLAG - BBH
0009 6003
158
JZ
CONT
;IF Ace
0008 120".56
159
LCALL
CWRTFU
;UPDATE TIME
=
a GOTD CONT
LaC
OBJ
OOOE
OOEO
00E3
00E5
00E8
E528
B4FFIC
E527
B40B03
020112
OOEB
OOEE
OOFl
00F4
00F6
00F9
B40FOE
1204E3
120500
E540
B40003
0200CC
OOFC 0201E2
OOFF E550
0101 64BBCE
0104
0107
0108
010A
OWB
0100
010F
0112
0115
0118
011B
011E
01Z1
0124
0127
0129
012C
120500
C3
E55E
14
F55E
70C3
0201E2
120405
1204E3
120500
9005AE
lZ047F
20B3fD
1Z0575
f525
B40103
OZ0156
012F 840Z03
013Z OZ0156
0135 640303
0138 020156
LINE
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
ZOO
ZOl
ZOZ
Z03
204
Z05
Z06
29
SOURCE
CONT:
MOV
CJNE
MOV
A,KEYSTORE4
A,#OFFH,SKIP5
A,KEYSTORE3
CJNE
A, #GBH, NEXTKEY
;IF INTERRUPT: KEYSTORE4 ~ FFH
;IF NO KEY PRESSED: GOTD SKIPS
;MOVE CHAR INTO ACC
;IF CHAR <> IB' GOTD NEXTKEY
LJMP
B_PROCESS
;ELSE GOTD B_PROCESS
NEXTKEY :
A,#OFH,UPDATEl
LCAlL
MOV
CJNE
CLEARDISP
LONGDELAY
A,BSTATUSO
A,#OOH,SKIPl
;CHECK IF ANY BATTERIES WERE ENTERED
LJMP
UPDATE1
;IF NOT - GOla UPDATE1
LCALL
SKIPl :
LJMP
F_PROCESSl
SKIPS:
MOV
A,FLAG
CJNE
LCALL
CLR
MOV
OEC
MOV
JNZ
LJMP
A,#OBBH,UPDATE
lONGDELAY
;MOVE BSTATUSO INTO Ace
;ELSE GOTD F_PROCESSl
;IF FLAG
<>
88: GOTD UPDAtE
C
A,RETDEL
A
RETDEl,A
UPDATE
F_PROCESSl
;IF RETDEL <> 0: GOTD UPDATE
;ELSE CONTINUE UITH PROCESS
B_PROCESS:
LCALL
CURSH
LCALL
(LEARD I SP
LCALL
LONGDELAY
DPTR,#8ATMES
MOV
LCALl
JB
LCALL
MOV
CJNE
LJMP
ONE:
CJNE
LJMP
TI,JO:
CJNE
LJMP
MESSAGE
P3.3,$
SCAN
KEYSTORE1,A
A,#OlH,ONE
B_CONT
;5ET POINT TO BATTERY MESSAGE
iDISPLAY BATTERY MESSAGE
;JMP UNTIll KEY IS PRESSED
;ENTER BATTERY NUMBER
;STORE BATTERY NUMBER
;CHECK FOR VALID NUMBER
A,#OZH, TWO
B CONT
;CHECK FOR VALID NUMBER
A,#03H,THREE
;CHECK FOR VALID NUMBER
B_cmn
THREE:
013B B40403
207
CJNE
A,#04H,FOUR
OBE OZ0156
Z08
B CONT
A,~5H,FIVE
a_CONT
0141 840503
ZlO
LJMP
FOUR:
CJNE
0144 D20156
211
LJMP
212
FIVE:
209
;IF CHAR <> 'F' GOTa UPDATEl
;CLEAR THE DISPLAY
CJNE
;CHECK FOR VALID NUMBER
;CHECK FOR VALID NUMBER
LOC
OBJ
0147 B40603
014A 020156
0140 B40703
0150 020156
0153 B408BC
0156
0159
015A
015C
Q15E
0160
0162
0165
0168
016B
0160
0170
9005EF
93
F54C
E540
454c
F540
120405
1204E3
120500
E525
1204[8
120500
0173
0176
0179
017c
017F
0182
0185
0188
018A
0180
120405
1204E3
120500
90058F
12047F
20B3FD
120575
F526
B40103
0201B7
0190 840203
0193 020187
0196 B40303
0199 020187
019C B40403
019F 020187
01A2 840503
01A5 020187
01A8 840603
01A8 020187
01AE 840703
0181 020187
LINE
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
30
SOURCE
CJNE
LJMP
SIX:
A,#07H,SEVEN
CJNE
LJMP B_CONT
SEVEN:
CJNE
MOV
OPTR, #oETBATT
MOVC
A,@A+DPTR
MOV
BATTNO,A
MOV
A,BSTATUSO
ORL
A,BATTNO
MOV
BSTATUSO,A
LCALL CURSH
LCALL ClEARDISP
LCALL LONGDELAY
MOV
A, KEYSTORE 1
LCALL OPO I SP
LCALL LONGDElAY
LCAlL
LCAll
LCALL
MOV
lCALL
JB
LCAlL
MOV
CJNE
LJMP
ONE1 :
CJNE
LJMP
CURSH
CLEARDISP
LONGDELAY
DPTR,#CVCLEMES
MESSAGE
P3.3,$
SCAN
KEYSTORE2,A
A,#01H,ONE1
C CONT
A, #02H, T\.I02
C
;CHECK FOR VALID NUMBER
;CHECK FOR VALID NUMBER
;CHECK FOR VALID NUMBER
;SET POINT TO START OF DETBATT1S TABLE
;DETERMINE THE BATTERY CODE
;STORE BATTERY CODE
;MOVE EXISTING BATTERY CODE INTO ACC
;LOGICAL ORR BATTNQ WITH BSTATUSO
;SET BIT FOR THAT BATTERY
;MOVE BATTERY NUMBER INTO ACC
;OISP 8ATTERY NUMBER
;SET POINT TO CYCLE MESSAGE
;DISPlAY CYCLE MESSAGE
;JMP UNTILL KEY IS PRESSED
;ENTER NO OF CYCLES
;STORE NO OF CYCLES
;CHECK FOR VALID NUMBER
;CHECK FOR VALID NUMBER
CONT
T~02:
CJNE
A,#03H,THREE3
LJMP
C_CONT
THREE3 :
CJNE
A,#04H,FOUR4
LJMP
C_CONT
FOUR,,-:
CJNE
A,#05H,FIVE5
LJMP
C_CONT
FIVES:
CJNE
A,#06H,SIX6
UN?
;CHECK FOR VALID NUMBER
;CHECK FOR VALID NUMBER
;CHfCK FOR VALID NUMBER
;CHECK FOR VALID NUMBER
C CONT
Slx6:
CJNE
A,#07H,SEVEN7
LJMP
C CONT
;CHECK FOR VALID NUMBER
Lac
OBJ
LINE
266
01B4 B408BC
267
31
SOURCE
SEVEN?:
CJNE
A~#08H~C_PROCESS
;CHECK FOR VALID NUMBER
268
269
C
CONT:
270
01B7 120405
271
01BA 1204E3
272
lCALL
LCALL
01BO 120500
273
LCALL
01cO E526
274
MOV
01C2 1204c8
275
CURSH
CLEARDISP
LONGDELAY
A,KEYSTORE2
01C5 120500
276
lCALL
LCALL
01C8 782C
277
MOV
01 CA E525
278
MOV
LONGDELAY
RO,#CYCLEl
A,KEYSTOREl
OPOIS?
01CC 14
279
GEC
A
Oleo 28
280
ADD
A,RO
01CE F8
281
MOV
RO,A
01eF E526
282
MOV
0101 F6
283
MOV
A,KEYSTORE2
@RO,A
0102 e3
284
CLR
C
OlD3 E550
285
MOV
A, FLAG
0105 94BB
286
SUBB
A,#OBBH
0107 7006
287
JNZ
SKIP4
0109 120495
288
lCALL
DISP_MES
289
LJMP
UPDATE 1
010C 0200CC
;MOVE NUMBER OF CYCLES INTO ACC
;OISPLAY NO OF CYCLES
;MOVE ADDRESS OF CYCLE1 INTO RC
;MOVE BATTERY NUMBER INTO ACC
;DEC Ace
;DETERMINE CYCLE ADDRESS FOR THAT BATTERY
;LOAD CYCLE ADDRESS INTO RO
:MDVE NUMBER OF CYCLES INTO ACC
;STORE NO OF CYCLES IN CYCLE ADDRESS
;CLEAR CARRY FLAG
;MOVE FLAG INTO Ace
;FLAG - BBH
;IF FLAG <> BBH GOTO SKIP4
;ELSE DISP ADD BATTERY/FINISH MESSAGE
290
010F 0200CC
291
SKIP4:
292
LJMP
UPOATEl
293
294
295
01E2 90800B
296
MOV
01ES 741A
297
MOV
01E? FO
298
MOVX
01E8 752800
299
MOV
DPTR,#800BH
A,#lAH
@DPTR,A
KEYSTORE4. #00;.;
01EB 755000
300
MOV
FLAG~#OOH
;POINT TO REG B OF RT-CLOCK
;MOVE START CODE OF RT-CLOCK INTO ACC
;START RT-CLOCK
;CLEAR KEYSTORE4
; CLEAR FLAG
301
302
303
OlEE D2AF
304
SETB
EA
;ENABLE ALL INTERRUPTS
01 FO 7551 F8
305
MOV
COUNT ,#GF8H
;SET ADDRESS COUNT TO 1111 1000
01F3 AC40
306
MOV
01 F5 E528
307
MOV
01F7 B4FF14
308
CJNE
01 FA E527
309
MOV
R:4,BSTATUSO
A,KEYSTORE4
A,#OFFH,TOPl
A,KEYSTORE3
01 FC 84080F
01 FF 90800B
310
CJNE
A,#GBH, TOPl
311
MOV
DPTR,#800BH
A,#9AH
@OPTR,A
FLAG,#OBBH
DISP_MES
UPDATE1
;LOAD BATT CODE INTO R4
;MOVE FLAG INTO ACC
;CHECK IF KEY ~AS PRESSED
;MOVE CHAR INTO ACC
;IF CHAR <> IB' GOTD TDP1
;SET POINT TO REG B OF RT-CLOCK
;MOVE STOP CODE OF RT-CLOCK INTO ACC
;STOP RT-CLOCK
; SET FLAG TQ BBH
0202 749A
312
MOV
0204 FO
313
0205 755DBB
314
0208 120495
315
MOVX
MOV
LCALL
LJMP
0208 0200CC
316
317
3iB
TOPt:
LOC
OBJ
LINE
32
SOURCE
319
020E C3
320
CLR
C
;CLEAR CARRY FLAG
020F EC
321
MOV
A,R4
0210 13
322
RRC
A
;RESTORE BATT CODE TO Ace
;ROTATE THROUGH CARRY TO CHECH FOR BATTER I ES
0211 FC
323
MOV
R4,A
;STaRE BATT COOE IN R4
0212 4072
324
JC
AOC
;IF BATT EXIST - GOTD ADC
325
326
TQP2:
327
0214 C295
328
CLR
J,lRITE
0216 120405
329
LCALL
CURSH
0219 120278
330
LCALL
LF
021C 90057C
331
MOV
DPTR,#MENU
;SET POINT TO MENU MESSAGE
021F 12047F
332
LCALL
MESSAGE
0222 0551
0224 7400
333
INC
COUNT
334
MOV
A,#OOH
;DISPLAY MENU MESSAGE
;INC ADDRESS COUNT
;CLEAR Ace
0226 B551E5
335
CJNE
A,COUNT,TOP1
;IF COUNT
0229 120405
336
lCALL
CURSH
022C 854F5c
337
MOV
022F 854D5B
338
TEMPCHS,CHARSTATUS
TEMPBSO,BSTATUSO
0232 755108
D235 906000
339
"av
MOV
COUNT ,#08H
; SET COUNT = 8
340
MOV
OPTR,#6000H
;SET POINT TO DISPLAY
0 GOTD TOP1
<>
341
342
5TATUSDISP:
343
0238 C3
0239 E558
344
CLR
C
345
MOV
A,TEMP8S0
;MOV TEMPBSQ INTO Ace
023B 13
346
RRC
A
;ROTATE TEMPBSO THROUGH CARRY
023C F558
347
MOV
TEMPBSO,A
023E 5016
348
JNC
OISP F
;STORE RESULT BACK IN TEMPBSO
;JF CARRY = 0 GOTD DISP F
0240 c3
349
CLR
C
0241 E55C
350
MOV
A,TEMPCHS
0243 13
351
RRC
A
0244 F55C
352
MOV
TEMPCHS,A
0246 5021
353
JNC
OISP_O
0248 7443
354
MOV
A,#43H
024A FO
355
0248 1204FS
356
MOVX
LCALL
OELAY
024E 7420
357
Mav
A,#20H
;MOVE 'SPACE
0250 FO
358
MOVX
@DPTR,A
;SEND 'SPACE' CHAR TO DISPLAY
0251 1204FB
359
LCALL
OELAY
0254 801F
360
SJMP
DECR
;JUMP TO DEeR
;MOVE TEMPCHS INTO ACC
;ROTATE TEMPCHS RIGHT
;srORE RESULT BACK IN rEMPCriS
;MOVE CHAR IF' INTO Ace
@OPTR,A
;ClEAR CARRY FLAG
;CLEAR CARRY FLAG
;MOVE TEMPCHS INTO Ace
;ROTATE TEMPCHS THROUGH CARRY
;STORE RESULT BACK IN TEMPCHS
;IF CARRY = 0 GOTO DISP_D
;MOVE CHAR 'C I INTO ACC
;SEND 'Cl TO DISPLAY
I
CHAR INTO ACC
361
362
DISP F,
363
0256 E55C
364
MOV
A,TEMPCHS
0258 03
365
RR
A
0259 F55C
366
MOV
025B 7446
367
MOV
0250 FO
368
MOVX
TEMPCHS,A
A,#46H
@OPTR,A
025E 1204FB
369
lCALl
0261 7420
370
0263 FO
371
;SENO 'F' TO DISPLAY
Mav
DELAY
A,#20H
; MOVE 'SPACE' CHAR INTO Ace
MOVX
@DPTR,A
;SENO 'SPACE' CHAR
ro OISPLAY
LOC
OBJ
33
LINE
SOURCE
0264 lZ04FB
0267 800C
37Z
373
374
375
376
LCALL
SJMP
DELAY
DECR
0269
026B
026C
026F
OZ71
OZ7Z
3n
MOV
MOVX
LCALL
MOV
MOVX
LCALL
A,#44H
@DPTR,A
DELAY
A,#20H
@DPTR,A
DELAY
;MOVE
;SEND
CaU"T,STATUSDISP
F_PROCESS
;If COUNT ~> 0 GOTO STATUSDlSP
;ELSE GOTO F_PROCESS
RS
DPTR,#6000H
A,#OCOH
@OPTR,A
RS
;TO SEND CONTR WORDS TO DlSP
;SET POINT TO DISPLAY
;ILINE FEED' TO ACC
;ILINE FEEDI TO DISP (CONTR WORD)
;TO ~R/RD DATA TO/FROM DISP
SETB
MOV
Mav
FINISH
DPTR,#C_POINT
A,COUNT
A"L
INC
MOV
A
;PREPARE P1.3 FOR INPUT
;SE1 POINT TO BEGINNING OF ALARM ADDREsSES
;LOAD ADDRESS COUNT INTO ACC
;MASK HIGHER-S BITS TO GET BATT-NO
;ADDRESS 000 = BATT-NO 1
;STORE BATT~NO IN BATTNO
;GET CORRECT ALARM ADDRESS FOR THAT BATTERY
;STORE ALARM ADDRESS IN R1
;SET POINT TO START OF DETBATT
;MOVE BArING INTO ACC
;GET CORRECT BATTERY eOOE
;STORE CODE IN BSTATUSN
;SEND ADDRESS TO C040518 (MULTIPLEXER)
;DELAY TO STABAlISE A-D VOLTAGE
;POINT TO ADC
;ACTIVATE wR LiNE TO START CONVERSION OF ADC
;FINISH = 1 DURING CONVERSION
;CLEAR CARRY FLAG
;ADC VALUE INTO Ace
7444
FO
1204FB
7420
Fa
1Z04FB
0275 0551CO
0278 OZ01EE
378
379
380
381
382
383
384
385
386
387
;JUMP TO DEeR
10
10
1
1
INTOACC
TO DISPLAY
;MOVE ISPACEI CHAR INTO ACC
;SEND 'SPACE, CHAR TO DISPLAY
DECR:
DJ"Z
LJMP
388
027B e294
389
390
391
OZlD 906000
392
0280 74CO
OZ8Z FO
OZ83 DZ94
393
394
395
396
397
398
0285 22
LF:
CLR
MOV
MOV
/'olOVX
SETB
RET
ADC:
399
0286 DZ93
0288 9005F8
OZ8B
OZ80
OZ8F
0290
OZ9Z
D293
OZ94
0297
OZ99
OZ9A
OZ9C
OZ9F
OZAZ
OZA5
OZA6
02A9
02AA
02AB
02AD
02AF
0261
0264
OZ85
E551
5407
04
FS4.[
93
F9
9005EF
E54C
93
F54E
855190
lZ04FB
904000
FO
Z093FO
c3
EO
C082
C083
COEO
908002
EO
855'OF
400
401
40Z
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
Move
MOV
MOV
MOV
MOVC
Mav
MOV
lCAlL
MOV
MQVX
JB
CLR
MOVX
PUSH
PUSH
PUSH
MOV
MOVX
CJNE
A, #07H
BATTNO,A
A,@A+DPTR
Rl,A
DPTR,#OETBATT
A,BATTNO
A,@A+DPTR
BSTATUSN,A
P1,COU"T
DELAY
OPTR,#4000H
@OPTR,A
FINISH,$
c
A,@OPTR
DPL
DPH
Ace
DPTR, #:8002H
A,@OPTR
A, SCANC, RETURN
;SET POINTER TO RTC-M!NUTES ADDRESS
;READ MINUTES INTO Ace
;IF 4 Mr~ nAVE PASSED CCNTfNUE ELSE JUMP
lOC 08J
0288
028A
028C
0280
02CO
E55F
3405
04
846002
7400
02C2 F55F
02C4 1203EO
02C7
02C9
02C8
02CD
02CF
02Dl
02D4
02D5
02D6
0209
02DA
0200
020F
02EO
02E3
02E4
02E7
02E8
02EB
02ED
02EE
OOEO
D083
D082
9487
4003
020308
E9
F8
908000
EO
120548
F55A
E6
855A1F
08
908002
EO
120548
F55A
E6
855A 11
LlNE
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
02F1 08
460
02F2
02F5
02F6
02F9
1.61
462
463
464
465
908004
EO
120548
F55A
02FB E6
02FC BS5A03
02FF 020384
466
34
SOURCE
MOV
ADDC
OA
CJNE
MOV
=
A,SCMJC
;ACC
A,#05
A
A,#60H,RSCAN
A,#OO
;SCANC = SCANC + 5
;CONVERT SCANC TO A Beo VALUE
;IF SCANC = 60 CONT ELSE JUMP
;5ET Ace = 00
SCANC
SCANC,A
TX
;SENO ADC-VALUE TO SERIAL PORT
RSCAN:
MOV
lCALL
RETURN:
POP
ACC
POP
DPH
POP
DPl
SUBS
A,#087H
JC
RTe1 ALM
LJMP
RTC2_ALM
;AOC VALUE - 87H (3.61 VOLT)
;IF ADC < 3.61 VOLT GOTD RTC1_ALM
;IF ADC> 3.61 VOLT GOTD RTC2_ALM
RTC'_ALM:
MOV
MOV
MOV
A,Rl
RO,A
OPTR,#8000H
.MOVX
A,@DPTR
;STORE ADDRESS IN RO
;POINT TO SEC ADDRESS OF RTe
;LOAD RIe-SEC INTO Ace
LCALL
BeD HEX
;TO CONVERT FROM BeD TO HEX
MOV
MOV
TEMP,A
A,@RO
CJNE
A,TEMP,SEC1_AA
INC
MOV
DPTR,#8Q02H
;.MOVE RTe-SEc INTO TEMP
;lOAD ALM-SEC INTO Ace
;IF RYe-SEC <> AlM-SEC GOTD SEC1_AA
;INC RO TO AlM-MIN ADDRESS
;POINT TO MIN ADDRESS Of RYe
;lOAO MIN INTO ACC
RO
MOVX
A,@OPTR
LCAll
BeD HEX
MOV
MOV
CJNE
INC
MOV
TEMP ,A
A,@RO
A,TEMP,SEC1_AA
RO
LCALl
DPTR #8004H
A,@DPTR
BCD_HEX
MOV
MOV
TEMP,A
A,@RO
CJNE
LJMP
A,TEMP,SEC1_AA
STP_OIRG
MOVX
I
0302 87AA03
0305 020346
467
468
469
470
471
SKIP3:
0308 020214
472
473
474
475
476
477
RTC2 ALM:
;LOAD ALM·SEC ADDRESS INTO Ace
;TO CONVERT FROM BeD TQ HEX
;MOVE MIN INTO TEMP
;LOAD AlM-MIN INTO Ace
;IF RTC-MIN <> AlM-MIN GOTO SEC1_AA
;INC RO TO ALM-HR ADDRESS
;POINT TO HR ADDRESS OF RTC
;LOAD HR INTO Ace
;TO CONVERT FROM BCD TO HEX
;MOVE HR INTO TEMP
;lOAD ALM-HR INTO ACC
;IF RTC-HR <> ALM-HR GOTD SEC'_AA
;STOP CHARGING OF BATTERY
SEC1~AA;
CJNE
@Rl,#OAAH,SKIP3
;!F SEC
LJMP
SETAlM
;SET THE ALARM
LJMP
TOP2
<>
AAH GOTD SKIP3
LOC
QBJ
030B
030C
030D
0310
0311
0314
0316
0317
031A
031B
031E
031F
0322
0324
0325
0328
0329
032C
0320
0330
0332
0333
0336
E9
FB
908000
EO
12054B
F55A
E6
B55AIF
08
908002
EO
12054B
F55A
E6
B55A 11
08
908004
EO
12054B
F55A
E6
B55A03
0203B4
0339
033B
033C
0330
033F
0340
0343
0346
0349
034A
0340
0350
0353
0354
0357
0358
0358
035C
035F
0362
0365
0366
LINE
SOURCE
MDV
MDV
MDV
MQVX
LCALL
MDV
MOV
CJNE
INC
MDV
MQVX
lCAll
MDV
MDV
CJNE
INC
MDV
MOVX
LCALL
MDV
MDV
CJNE
LJMP
EO
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
30ElF9
30E4-F6
908002
EO
120548
527
528
529
530
7852
18
E8
254C
F8
B6FF64
020214
90800C
EO
30E7F9
30E4F6
908000
EO
120548
F7
90800C
526
FLAG
35
A,Rl
RO,A
DPTR,#8000H
A,@OPTR
BCD_HEX
TEMP,A
A,@RO
A, TEMP,FLAGJF
Ra
OPTR,#8002H
A,OOPTR
BCO_HEX
TEMP,A
A,@RC
A,TEMP,FLAG_FF
RO
OPTR, #8004"
A,@DPTR
BCO_HEX
TEMP,A
A,@RO
A.,TEMP,FlAG_fF
STP_CHRG
;LOAD ALM·SEC ADDRESS INTO ACC
;STORE ADDRESS IN RC
;SET POINT TO SEC ADDRESS OF RTC
;LOAD RTC·SEC INTO ACC
;TO CONVERT FROM BCD TO HEX
;MOVE RTC-SEC INTO TEMP
;LOAD ALM-SEC INTO ACC
;IF RTC-SEC <> ALM-SEC GOTO FLAG_FF
;INC RO TO ALM-MIN ADDRESS
;SET POINT TO MIN AOORESS OF RTC
;LOAD MIN INTO ACC
;TO CONVERT FROM BeD 10 HEX
;MOVE MIN INTO TEMP
;LOAO ALM-MIN INTO ACC
;IF RTC-MIN <> ALM·MIN GOTO FLAG_FF
;INC RO TO ALM-HR ADDRESS
;SET POI~T TO HR ADDRESS OF RiC
;LOAD HR INTO ACC
;10 CONVERT FROM BCD TO HEX
;MOVE HR INTO TEMP
;LOAD ALM-HR INTO ACC
;tF R1C·HR <> ALM-HR GOiO FlAG_FF
;STOP CHARGING OF BATTERY
FF:
MOV
DEC
MOV
ADD
MOV
CJNE
lJMP
RO,#8FLAG1
;RO = POINT TO 6FlAG
RC
;OET CORRECT POSITION FOR POINTER
A,RC
;LOAD START POSITION INTO ACC
A,BATTNO
;DET CORRECT BFLAG ADDRESS
RO,A
;STORE ADDRESS IN RO
@RO.#OFFH,DISCHARGE ;IF SEC <> FFH Goro TOP2
TOP2
;SET THE ALARM
SETALM:
SETS:
MOV
MOVX
JNB
JNB
MOV
MOVX
LCALL
DPTR, #800CH
A,@])PTR
ACC.7/SETS
ACC.4,SETS
DPTR, #8000H
A,@OPTR
BeD HEX
MOV
@R1,A
SETM:
MOV
MOVX
JNB
JNB
MDV
MOVX
LCALL
DPTR #aOOeH
A,@DPTR
ACC.7, SETM
ACC.4, SETM
I
DPTR, #8002H
A,@DPTR
BCD_HEX
;SET POINT TO REG C OF RT·CLOCK
;READ REG C FOR END OF UPDATE
;CONTINUE IF BIT 7 IS SET
;CONTINUE IF BIT 4 IS SET
;SET POINT TO SEC ADDRESS OF RTe
; MOVE SEC TO ACC
;TO CONVERT FROM BeD TO HEX
;STORE SEC IN ALM*SEC
;SET POINT TO REG C OF RT~CLOCK
;READ REG C FOR END OF UPDATE
;CONTINUE IF BIT 7 IS SET
;CONTINUE IF BIT 4 IS SET
;SET POINT TO MIN ADDRESS OF RTC
;MOVE MIN TO ACC
;TO CONVERT FROM BeD TO HEX
LOC
OBJ
0369 09
036A F7
0368
036E
036F
0372
0375
0378
0379
037c
037E
037F
0380
0381
0383
0385
0386
0388
0389
038A
038C
038D
038F
0392
0394
0395
0397
0399
039A
0390
039'
03A1
03A3
03A4
90800c
EO
30E7F9
30E4F6
908004
EO
12054B
240E
09
F7
c3
9418
4001
F7
7852
18
E8
254C
F8
76FF
902001
E54E
F4
5550
F550
Fa
902000
E54E
454F
F54F
FO
020214
LINE
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
36
SOURCE
RI
@R1,A
;STORE MIN IN ALM*MIN
OPTR,#800CH
;SET POINT TO REG C OF RT-CLOCK
MQVX
A,OOPTR
;READ REG C FOR END OF UPDATE
JNB
JNB
MOV
ACC.7,SETH
SET_FLAG
;CONTINUE IF BIT 7 IS SET
;CONTINUE IF BIT 4 IS SET
;SET POINT TO HRS ADDRESS OF RTC
;MOVE HRS TO ACC
;TO DO BeD Ta HEX CONVERSION
;ADD 14 HRS CHARGING TIME TO ALARM TIME
;CHANGE ADDRESS TO THAI FOR HOURS
;STORE HRS IN ALM*HR
; CLEAR CARRY FLAG
;IF ALARM HRS < 24 SET CARRY FLAG
;IF CARRY GOTO SET_FLAG
@R1,A
;lOAD CORRECT HOURS INTO AlM*HR
ACC.4~SETH
OPTR,#8004H
A,@OPTR
MQVX
LCALl
BCD_HEX
ADD
INC
MOV
CLR
SUBS
JC
MOV
A,#OEH
R1
@R1,A
C
A,#18H
SET FLAG:
MOV
DEC
MOV
RO,#BFLAG1
RO
A,RO
ADD
A,BATTNO
MOV
ROtA
MOV
@RO,#OFFH
= POINT TO BFLAG
;DET CORRECT POSITION FOR POINTER
;LOAO START POSITION INTO ACC
;OET CORRECT BFLAG ADDRESS
;STORE ADDRESS IN RO
;5ET BFLAG ADDRESS CONTENTS TO FFH
;RO
SIP _OISCH:
Mav
Mav
DPTR,#2001H
A,BSTATUSN
CPL
A
ANl
Mav
A,DISCSTATUS
DISCSTATUS,A
MOVX
aOPTR I A
;SET POINT TO PORT B OF 8255
;LOAD BATTERY CODE INTO ACC
;COMPLIMENT ACC- RESET SIT TO STOP DISCHARGE
;DET CODE TO STOP DISCH FOR SPECIFIC BATTERY
;STORE NEU OISCSTATUS CODE
;SEND CODE TO PORT B OF 8255 TO STOP DISC of BATT
CHARGE:
572
MOV
MOV
ORL
MOV
DPTR,#2000H
A,BSTATUSN
A,CHARSTATUS
CHARSTATUS,A
573
MOVX
@DPTR,A
574
LJMP
TOP2
571
;CHANGE ADDRESS TO THAT FOR MINUTES
INC
MOV
SETH,
MOV
;SET POINT TO PORT A OF 8255
;LOAD CHARGE CODE FOR BATT INTO ACC
;DET NEW CHARGE CODE: DO NOT AFFECT EXIST BATT
;STORE NEW CHARGE CODE
;SENO CHARGE CODE TO PORT A OF 8255
575
576
DISCHARGE:
577
03A7902001
578
03AA E54E
579
03AC 4550
03AE f5S0
DPTR,#2001H
A,BSTATUSN
5BD
581
MOV
MOV
ORl
MCV
0380 FO
582
MOV'X
@DPTR,A
0381 020214
583
LJMP
TcP2
A,DlSCSTAT~S
DISCSTATUS,A
;SET POINT TO PORT B OF 8255
;LOAD DISC CODE FOR BATT INTO ACC
;OET NEU DiSC CODE: DO NOT AFFECT EXIST BATT
;STORE NEU DISCHARGE CODE
;SEND DISC CODE TO PORT B OF 8255
laC
03B4
03B7
03B9
03BA
03BC
03BE
OBJ
902000
E54E
'4
554'
'54'
'0
03SF 77AA
03Cl
03C3
03C4
03C5
03c7
0308
7852
18
E8
254c
'8
7600
030A 742c
03co 14
03CO 2540
03CF Fa
0300 E6
0301 14
0302 '6
0303 6003
0305 020214
0308 E54E
03DA F4
0306
0300
030'
03E2
03E4
03E7
5540
'540
B40008
0295
7550BB
02000C
03EA 020214
03ED 5390F8
03FO 904000
03;:3 FD
03,4 2093'0
03'7 C3
03'8 EO
LINE
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
37
SOURCE
STP_CHRG:
MOV
MOV
CPl
ANl
MOV
MOVX
OPTR,#2000H
Ai BSTATUSN
A
A,CHARSTATUS
CHARSTATUS,A
@OPTR,A
MOV
MOV
DEO
MOV
ADD
MOV
MOV
@R1,#OAAH
RO,#B'LAGl
RO
A,RO
A.BATTNO
RO,A
@RO,#OOH
;SET POINT TO PORT A 0' 8255
;LOAD CHARGE CODE FOR BATT INTO ACC
;COMPLIMENT ACC - RESET BIT TO STOP CHARGE
;DET CODE TO STOP CHARGE FOR SPECIFIC BATT
;STORE NE'W CHARGE CODE
;SEND CODE TO PORT A OF 8255 TO STOP CHARGE
;SET SEC ALARM ADDRESS CONTENTS TO AAH
= POINT TO BFLAG1 ADDRESS
;DET CORRECT POSITION FOR POINTER
;LOAD START POSITION INTO ACC
;DET CORRECT BFLAG ADDRESS
;STORE ADDRESS IN RO
;CLEAR CONTENTS OF BFlAG ADDRESS
;RO
DEC CYCOUNT:
MOV
DEC
A,#CYCLE1
ADD
A,BATTNO
RO.A
A,@RO
MOV
MOV
OEC
MOV
JZ
lJMP
A
A
@RO,A
CH_STWORD
TOP2
;LOAD THE ADDRESS OF CYClE1 INTO ACC
;DET CORRECT START POSITION
;DET CORRECT ADDRESS FOR THAT BATTERY
;MOVE ADDRESS TO RO
;MOVE NO OF CYCLES INTO ACC
;DECREMENT CYCLES
;STORE NO OF CYCLES IN CYCLE ADDRESS
;IF ZERO GOTO CH ST'WORD
;ElSE GOTO TOP2
CH_STWORD:
MOV
CPl
ANL
MOV
CJNE
CLR
MOV
LJM?
A,BSTATUSN
A
A,BSTATUSO
BSTATUSO,A
A,#OOH,SKIP2
'WRITE
FlAG,#OBBH
UPDATEl
;MOVE BSTATUS TO ACC
;COMPLIMENT ACC- RESET BIT TO STOP CYCLING
;DET NEW BSTATUSO CODE
;STORE NE~ CODE IN BST~TUSO
;IF BSTATusa <> 0 GOTa SKIP
;SET DISP 'WRITE lO'W
;SET FLAG = BBH
SKIP2:
LJMP
Top2
IX:
ANl
MOV
MQVX
JB
ClR
MOVX
Pl • #O;:8H
DPTR,#400Cri
@DPTR,A
FINISH,$
;SET POINTER TO ADC
;ACTICATE ADC TO START CONVERSION
;~AIT UNTIL CONVERSION IS FINISH
C
A,ElOPTR
;READ ADC VALUE INTO Ace
Lac
aBJ
LINE
38
SOURCE
03'9 C299
637
CLR
T1
03'B '599
638
MOV
SBUF,A
;CLEAR TRANSMIT INTERRUPT 'LAG
;MOVE ADC TO SERIAL PORT
03'0 3099'0
639
JNB
TI,$
;WAIT UNTIL FINISH
0400 22
640
RET
641
642
SETUART:
643
0401 7580'7
644
0404 758920
645
Mav
MOV
TH1,#OF7H
TMOD,#20H
; 1200 BAUD
0407 759852
646
MOV
SCON,#52H
; SETUP
040' 028E
647
SETB
TRt
; SER I AL PORT
040C 22
648
RET
649
650
C\JDrsp:
651
0400 906000
652
MOV
OPTR,#6000H
;SET POINT TO OISP
0410 c294
653
CLR
RS
;SET RS lOY TQ SEND CONTR* WORDS TO DISP
04127401
654
MOV
A,#OlH
;"DISP CLEARlI TO Ace
0414 fO
655
MOVX
@DP1R,A
;tlDlSP CLEARlI TO DlSP (CONTR WORD)
0415 1204'B
656
LCAlL
DELAY
0418 7402
657
MOV
A,#02H
;"CURSER HOME" TO
041A '0
658
MOVX
@DPTR,A
;IICURSER HOMEIl TO DISP (CONTR WORD)
041B 1204'B
659
LCALL
DELAY
041E 7438
660
MOV
A, #38H
;1I8-BITS FUNCTIONJI TO ACC
0420 '0
661
MQVX
@DPTR,A
;"8-BITS FUNCTION" TO DISP
0421 1204'B
662
LCALL
DELAY
0424 7406
663
MOV
A,#06H
;IIREG INC + DISP FREEZE" TO ACC
0426 '0
664
MQVX
@DPTR,A
;IlREG INC + DISP FREEZE" TO DISP (CONTR WORD)
Ace
0427 1204'B
665
LCAlL
DELAY
042A 740C
666
MOV
A,#OCH
;IlDISP-ON CURSER-OFF" TO Ace
042c FO
667
MQVX
@DPTR,A
; lI
0420 1204fB
668
LCALL
DELAY
0430 029i.
669
SETS
RS
0432 22
670
RET
DISP-ON CURSER-OFFIl TO DISP (CONTR WORD)
;TO WR/RD DATA TO/FROM DISP
671
672
CURIC:
673
0433 90800B
674
MOV
OPTR,#800BH
;5E1 POINTER TO REG 8 OF RT-CLOCK
0436 749A
675
MOV
A,#9AH
;10011010 - CONTR WORD
0438 fO
676
MOVX
@DPTR,A
;MOVE CONTROL WORD TO REG B
0439 1582
677
DEC
DPL
;SET POINT TO REG A OF RI-CLOCK
0438 740'
678
MOV
A;#OFH
0430 '0
679
MQVX
@DPiR,A
;LOAD CONTROL WORD tNTO ACC SOOmS PULSE TO saw
;MOVE CONTROL WORD TO REG A
680
RET
043E 22
681
682
cw8255 ;
683
043F 902003
684
MOV
DPTR,#2003H
0442 7481
685
MOV
A,#81H
0444 FO
686
0445 902000
687
0448 E54F
683
689
MOVX
MOV
MOV
ClDPTR,A
DPTR,#2000H
A,CHARSTATUS
,"1QVX
@OPTR"t;
044A FO
;SET POINT TO CONTR~ wORD ADDRESS OF 8255
;CONTR- IJORD TO Ace
;CONTR~ IJORD TO 8255
;5ET POINT TO CHARGE PORT OF 8255
;CLEAR ACC (CHARSTATUS = 0)
;DISA8LE ALL CHARGE PORTS
LOC
OBJ
LINE
044B 0582
690
044D '0
691
INC
MOVX
692
RET
044E 22
39
SOURCE
DPl
@DPTR,A
;SET POINT TO DISCHARGE PORT 0' 8255
;DISABLE ALL DISCHARGE PORTS
693
694
CIJRTSU:
695
044' 90800B
696
MOV
DPTR.#800BH
0452 741A
697
MOV
A.#lAH
;SET POINT TO REG B OF RT- CLOCK
;LOAD CONTROL UORD INTO Ace START UPDATING
0454 '0
698
MOVX
@OPTR,A
;MOVE CONTROL \.lORD TO REG B OF RT- CLOCK
699
RET
;SET POINT TO REG C OF RT- CLOCK
;READ REG C FOR END OF TIME UPDA1E
;IF BIT 7 IS SET CONTINUE
;IF BIT 4 IS SET CONTINUE
0455 22
700
701
CI.IRTFU:
702
0456 90800C
703
MOV
DPTR.#800CH
0459 EO
704
MOVX
A,@DPTR
045A 30E7'9
705
JNB
Ace.7. CI.JRTFU
045D 30E4'6
706
JNB
ACC.4,CWRTFU
0460 1204D5
707
LCALL
CURSH
0463 908004
708
MOV
DPTR.#8004H
0466 EO
709
MOVX
A,@OPTR
0467 120481
710
LCALL
OPTIME
046A 1204'1
711
LCALL
COLON
046D 908002
712
MOV
OPTR. #8002H
0470 EO
713
MOVX
A,@OPTR
0471 120481
714
LCALL
QPTlME
0474 1204'1
715
LCALl
COLON
0477 908000
716
MOV
DPTR,#8000H
047A EO
717
MOVX
[email protected]
047B 1204B1
718
LCALL
OPTIME
047E 22
719
RET
;SET POINT TO HRS- ADDRESS
;READ HRS TO ACC
;SEND HRS TO DISP
;SET POINT TO MIN- ADDRESS
;READ MIN TO Ace
;SEND MIN TO DISP
;SET POINT TO SEC- ADDRESS
; READ SEC TO ACC
;SEND SEC TO DISP
720
721
MESSAGE:
722
047' E4
n3
CLR
A
0480 93
724
Move
A,@A+DPTR
0481 C082
725
PUSH
OPL
0483 C083
n6
0485 906000
727
PUSH
MOV
DPH
OPTR,#60COH
;CLEAR ACC
;MOVE MESSAGE CHARACTER TO ACC
;STORE POINTER-L POSITION ON STACK
;STORE POINTER-H POSITION ON STACK
;SET POINTER TO OISP
0488 '0
728
MOVX
@OPTR.A
;SEND CHARACTER TO DISPLAY
0489 1204'8
729
LCALL
DELAY
048C 0083
0498 1204:::3
730
731
732
733
734
735
736
737
738
739
0498 1204FB
740
048E D082
0490 A3
0491 B4AOE8
0494 22
0495 1204D5
POP
OPH
POP
DPL
INC
DPTR
CJNE
A,#OAOH,MESSAGE
;RESTORE POINTER-H POSITION
;RESTORE POINTER-L POSITION
;INCREMENT TO NEXT CHARACTER
;REPEAT UNTIL ALL CHAR'S ARE DONE
RET
DISP _MES:
LCALL
CURSH
LCALL
CLEARD I SP
DELAY
DPTR,#ADD_BATT
MESSAGE
049::: 9005CO
741
LCALl
HOV
04A1 12047F
742
LCALL
;SET POINT TO ADD_BAIT MESSAGE
;DISP AOD BATT MESSAGE
LOC
OBJ
04A4
04A7
04AA
04AD
04BO
120405
12027B
90050E
12047F
22
04B1
04B4
04B5
04B7
04B8
04BA
048B
04BE
04BF
04C1
04C3
04C4
04c7
04C8
04CB
04CC
04CE
0400
0401
0404
906000
F8
54FO
C4
2430
FO
1204FB
E8
540f
2430
FO
1204fB
22
906000
f8
540f
2430
FO
120500
22
0405 C294
0407 906000
040A 7402
Q4QC FO
0400 120MB
04EO 0294
04E2 22
04E3
04E5
04E8
04EA
C294
906000
7401
fO
04EB 120MB
04EE D294
04'0 22
LINE
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
LCALL
DPTR ,#FIN
;SET POINT TO FIN MESSAGE
lCALL
MESSAGE
jDrSp FIN MESSAGE
MOV
MOV
ANL
SYAP
ADD
OPIR,#6000H
RO,A
A,#OFOH
;STORE Ace IN RO
MOVX
QlDPTR,A
LCALL
MOV
ANL
ADD
MOVX
LCALL
REI
DELAY
REI
QPTlME:
A
A,#30H
A/RO
A,#OFH
A,#30H
@DPTR,A
DELAY
;SET POINT TO DISP
;MASK
;EXCH
LO~ER
L~ER·
ORDER BITS
AND HIGHER-FOUR BITS
;CONVERT TO BeD VALUE
;SEND CHARACTER TO DI5P
;MOVE CONTENTS OF RC TO Ace
;MASK HIGHER ORDER BITS
;CONVERT TO BeD VALUE
;SEND CHARACTER TO DlSP
OPOISP,
MOV
MOV
ANL
ADD
DPTR, #6000H
;SET POINT TO DISP
RO,A
;STORE Ace CONTENTS IN RO
A,#OFH
MOVX
@DPTR,A
;MASK HIGHER ORDER BITS
;CONVERT TO BeD VALUE
;SEND CHARACTER TO DISP
LCAlL
LONGDELAY
REI
774
775
776
CURSH:
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
CURSH
LF
LCALL
MOV
773
777
40
SOLRCE
CLR
MOV
MOV
MOVX
LCALL
SETB
RET
A,#30H
RS
DPTR,#6000H
A,#02H
@OPTR.A
DELAY
RS
;SET RS lO~ TQ SEND CONTR- WORD TO DI SP
;SET POINT TO DISP
; lICURSER HOME" TO ACC
;IICURSER HOME" TO DISP
;TO 'WR/RD DATA TO/FROM OISP
CLEARD ISP:
CLR
MOV
MOV
MOVX
LCALL
SETB
RET
COLO;:
RS
DPTR,#6000H
A,#D1H
;RS MUST BE L~ ~HEN 'WRITING CONTROL
;SET POI~T TO DISP
; liD IS? ClEARIl TO ACC
@OPTR,A
;"DISP CLEAR" TO D!SP (CmHR wORD)
DELAY
RS
;TO wR/RD DATA TO/fROM orsp
~ORDS
TO OISP
LaC
OBJ
LINE
41
SOURCE
796
04Fl 906000
797
MOV
DPTR, #6000H
;SET POINT TO OISP
04F4 743A
798
MOV
; lICOLON CooEII TO Ace
04F6 FO
799
MDVX
A,#3AH
@OPTR,A
04F7 1204FB
800
LCALL
DELAY
801
RET
04FA 22
;"COLON COOElI TO DISP
802
803
DELAY:
804
04FB 7E9F
805
MOV
R6,#9FH
04fD DEFE
806
OJNZ
R6,$
04FF 22
807
RET
;START VALUE OF DELAY LOOP
;OEe COUNTER UNTIL = 0
808
809
LONGOElAY:
810
0500 7F6F
811
MOV
812
INNER:
R7,#6FH
;5ET OUTER TIME lOOP
0502 7EFF
813
MOV
R6,#OFFH
0504 DHE
814
DJNZ
R6,$
;5ET INNER TIME LOOP
;DEe INNER LOOP UNTIL ZERO
0506 DFFA
815
DJNZ
R7,INNER
JDEe OUTER LOOP UNTIL ZERO
0508 22
816
RET
817
818
COMBHRS:
819
0509 E525
820
Mav
A,KEYSTOREl
050B 54DF
821
ANl
A,#OFH
A
0500 C4
822
SUAP
050E F525
823
Mav
KEYSTORE1,A
0510 E526
824
Mav
A,KEYSTORE2
0512 540F
825
ANl
A,#OFH
0514 4525
826
ORL
A, KEYSTOREl
0516 F529
827
Mav
HRS,A
0518 22
828
RET
;MOVE 1 ST HR-DIGIT INTO ACC
;MASK HIGHER FOUR BITS
;EXCH lOYER- AND HIGHER-FOUR BITS
;STORE IN KEYSTORE1
;MOVE 2 NO HR~DIGIT INTO ACC
;MASK HIGHER FOUR BITS
;lOGICAL ORR UITH KEYSTORE1
;STORE RESULT IN HRS
829
830
COMBMIN:
831
0519 E527
832
MOV
A,KEYSTORE3
051B 540F
833
ANL
A,#OFH
0510 C4
834
SWAP
A
051E F527
835
0520 E528
836
MOV
MOV
KEYSTORE3,A
A,KEYSTORE4
0522 540F
837
ANl
A,#CFH
0524 4527
838
ORl
A,KEYSTORE3
0526 F52A
839
Mav
MIN,A
0528 22
840
RET
;lST DIGIT OF MIN TO Ace
;MASK HIGHER BITS
;EXCH lOUER- AND HIGHER-FOUR BITS
; SAVE Ace CONTENTS
;2ND DIGIT OF MIN TO ACC
;MASK HIGHER BITS
;COMBINE 1ST + 2ND DIGITS OF MIN
;STORE ACC IN MIN
841
842
SETHRS:
843
0529 908004
844
MOV
DPTR, #8004H
052C E529
052E FO
845
MOV
A,HRS
846
MOVX
@DPTR,A
052F 1204FB
847
LCALL
DELAY
0532 22
848
RET
;SET POINT TO
;HOlJRS TO Ace
;HOURS TO RTc
HOURS~
ADDRESS OF RTC
LOC
OBJ
LINE
42
SOURCE
849
850
SETMIN:
851
0533 908002
852
MOV
OPTR,#8002H
0536 E52A
853
0538 FO
854
A,MIN
@DPTR,A
0539 2405
855
0538 F55F
856
0530 1204F8
857
MOV
MOVX
ADD
MOV
LCALL
0540 22
858
RET
A,#05
SCANC,A
DELAY
;SET POINT TO MIN- ADDRESS OF RTC
;MIN TO ACC
;MIN TO R1C
;ACC ; RTC MIN + 5
;SCANC = RTC MIN + 5
859
860
SETSEC:
861
0541 908000
862
MOV
DPTR,#8000H
;SET POINT TO SEC- ADDRESS OF RTC
0544 7400
863
MOV
A,#OOH
;00 SEC 10 ACC
0546 FO
864
865
MOVX
lCALL
@DPTR,A
DELAY
;00 SEC TO RTC
0547 1204F8
866
RET
054A 22
867
868
BCD HEX:
869
0548 F525
870
MOY
KEYSTORE1,A
0540 54FO
871
ANL
A,#OFOH
054F c4
872
0550 75FOOA
873
A
B,#OAH
AB
B,A
A,KEYSTOREl
A,#OFH
A,8
0556 E525
876
0558 540'
877
055A 25'0
878
SWAP
MQV
MUL
MOY
MOV
ANl
ADD
055C 22
879
RET
0553 A4
874
0554 F5FO
875
;STORE HOURS TEMP
;MASK lOWER-4 BITS
;SUAP HIGHER- AND lOUER-4 BITS
;MOVE OAH INTO REG B
;ACC * REG B
;STORE ANSWER IN REG B
;lOAD HOURS INTO Ace
;MASK HIGHER-4 BITS
;Ace
+
REG B ; BeD VALUE
880
881
882
0550 C083
883
055F C082
884
0572 0083
893
PUSH
PUSH
PUSH
MOV
MOV
MOVX
ANl
MOV
POP
POP
POP
0574 32
894
RETI
0561 COEO
885
0563 7528FF
886
0566 90AOOO
887
0569 EO
888
0560 540'
889
056C F527
890
056E DOED
891
0570 0082
892
DPH
DPL
Ace
KEYSTORE4,#OFFH
OPTR,#OAOOOH
A,@OPTR
A,#OFH
KEYSTORE3,A
Ace
DPl
DPH
;SET KEYSTORE4 ; FFH DUE TO INTERRUPT
;SET POINT TO 74C922
;READ KEY FROM KEYBOARD INTO ACC
;MASK OfF HIGHER-FOUR BITS
;STORE CHAR IN KEYSTORE3
;RETURN AFTER INTERRUPT
895
896
SCAN:
897
0575 90AOOO
898
MOV
0578 EO
899
MOVX
ANL
RET
0579 540,
900
0575 22
901
0PTR,#OACOOH
A,@OPT,1<1
A,#OFH
;5ET POINT TO 74C922
;REAO KEY FROM KEYBOARD INTO Ace
;MASK OFF HIGHER-fOUR 81T5
LOC
OBJ
LINE
43
SOURCE
902
05?e 31203220
MENU:
DB '1 234567 B',OAOH
;BATTERY NO'S
905
HOURS:
DB 'ENTR HRS 00-23 ?',OAOH
;MESSAGE FOR HOURS
906
MINUTES:
DB 'ENTR MIN 00-59 ?',OAOH
;MESSAGE FOR MINUTES
908
BATMES:
DB 'ENTR BATT: 1-8 ?' ,OAOH
;MESSAGE FOR BATT-NO.
909
CYCLEMES: DB 'ENTR CYCLES ?',OAOH
;MESSAGE FOR NO OF CYCLES
911
ADO_BATT: DB 'ADD MORE BATT OR',OAOH
;MESSAGE FOR ADDING BATTERIES
912
FIN:
DB 'FINISH? ENTR B/F',OAOH
;MESSAGE FOR FINISH
913
914
DETBATT:
DB
OOH,OlH,02H,04H,08H,10H,20H,40H,80H
C POINT:
08
OCH,34H,37ri,3AH,3DH,40H,43n,46H,49H
903
0580 33203420
0584 35203620
0588 372038
058B AO
904
058e 454E5452
0590 20485253
0594 20303020
0598 3233203F
05ge AO
0590 454E5452
05A1 2040494E
05A5 20303020
05A9 3539203F
05AO AO
90?
05AE 454E5452
0562 20424154
05B6 543A2031
05BA 2038203 F
05BE AO
05BF 454E5452
05e3 20435943
05e? 4e455320
05eB 3F
05ee AO
910
05CO 41444420
0501 4D4F5245
0505 20424154
0509 54204F52
0500 AO
050E 46494E49
05E2 53483F20
05E6 454E5452
05EA 20422F46
05EE AO
05EF 00
05FO 01
05Fl 02
05F2 04
OSF3 08
05F4 10
05F5 20
05F6 40
05F7 80
915
05F8 00
05F9 34
05FA 37
916
LOC
OBJ
05'B
05'C
05FD
05'E
05FF
0600
3A
30
40
43
46
49
LINE
917
918
SOURCE
END
44
45
Program Capture (GWBASIC- Program)
10 OUT 1019,128
20 OUT 1016,96
30 OUT 1017,0
40 OUT 1019,3
50 D=O
'Set time counter = 0
60 LINE INPUT "FILE?";DSKFIL$
'Enter the file name
70 OPEN DSKFIL$ FOR OUTPUT AS #1
'Open file
802 Z=INP(1016)
'Clear the port
90 FOR I=l TO 40
'Set counter
100 A=INP(1021)
'Read port register
no
'Mask data
A=A AND 1
120 IF A=l THEN GOTO 150
130 C$=INKEY$:IF C$= till THEN 100
'Data received?
140 GOTO 200
'If keypressed goto 200
150 B=INP(1016)
'Read data from port
160 D=D+5
'Time counter + 5 minutes
'Any key pressed?
170 PRINT D"Minutes Passed l ,B/18.53 I Volt"
'Disp time + data
180 PRINT #1,B/18.53
'write data to file
190 NEXT I
'Repeat until I = 0
200 CLOSE #1
'Close file
210 END
START
46
BEGIN:
SET FLAG ~ 0
SET aSTATUSO
~
a
SET BSTATUSN = 0
SET CHARSTATUS = 0
SET OISC5TATUS = 0
ENTER 1ST DIGIT
ENTER 2ND DIGIT
5m~E
Drsp
AND
~INUTE
cts~
MESSAGE
J
ENiE"
~5T
DIGIT
AND
STORE
DIS~
!
t
ENTER
~,o
DIGIT
STORE :..NO
'0
OISP
~TArlT UPQATI~G
ie:
AAri
UPDATE1:
47
UPDATE:
YES
+
IS il.CC ;
,
CONT:
Ace "'"
KE\'5TCRE~
SKIP5:
IS fLAG ;
aan
NO
KEY BEEN PRESSE:
i YES
"i"
ACC '" K!:':YSTORE3
NO
YES
IS CHAR; '6'
rES
48
I'---::",~~'~~ .I I
Of;1E
;;SI":~SO ~.
TO
j
i
I
H'~". >''-;'''';;c'."·-'T-,,-,-,,-,.
i
~
--=-'-----
49
TOi'l:
~PAf£
1'1.3
eo_"'""=-::'_ _~
L._ _
ClET ~.>.DO'£SS
I
CET s.or7ERr Cort
i
,
I
j
.vc
SToFE:>I 8ST"T1J9i
S£~ E.T~[;;!
lJCi'l;SS
'0 1t.ILT!"'I..DU;
lS
t
50
RTC2JL1t
!S
BFL'o's • FFH
WoC • AUI1lI WE
SEC!j.I.;
SET4L~
YE
REA:!
,rME:
F~II
RT-CUlCX
=
14 J-;(ltJ;s AI{]
SE1 J.:..AAIO rrll£
~J~o
t
I
SET EH.A:;
n Hii
'-----~
I
c;.;:.N6E aA. ,Erl¥
SHT'JS
>tQF;D
i
I
I
k
,!
"
I.
1
k
v
FiOC,ESS
f-----!
"
S~
J
SH.W O'..lF6E
SSTJ,".,.'S.~
,
•
'j
51
sTATUSD13r':
IS
Drsp ...f
CARRY FLAG SET
YES
\1/
ACC
CHARS TAWS
ROTATE TiiFiGUGH CARRY
+ STJRE IN TE~PCHS
SEND 'SPACE' TO C'ISf'l
C:SP ....D:
IS
SET
"
i
::END ·0
,
D~S"Ul'
,
,
,!/
~'::f;Q
S:'ND 'C' TO D~SPLAY
'SFA:C
re
J~S?
~~:~
'11
3r"TI.·~:J'o'
Jl
JI
__
I
(
--"-'_~
O!I * :IN"fJS Si
~SF\111S
~1ll;3HLJ
I
sn:JJ.~ ~
Cfl !:l31J€
l • lli'< "!:8li"fll
z:s
!lute
53
6. Problems Encountered.
6.1 Hardware.
Any batteries
connected to the charger,
whether they
are being cycled or not, will start to discharge in the case
of a power failure.
To prevent this from happening,
pUll-
down resistors were put on the base of the first switching
transistor
circuit
to
keep
it
switched
is switched on by a
off
until
+5V signal
the
discharge
from the
control
unit.
To select the display a NOR-gate is required to combine
the CS-3 and WR signals in order to overcome timing problems
between the CPU and the display.
Initially a 5V regulator was used to supply a constant
voltage to the processor unit.
drop
across
the
tracks
As a result of the voltage
the
processor
malfunctioned
intermittently. To overcome this problem an adjustable power
supply is used in order to supply the required voltage at
the input terminals of the processor.
6.2 Software.
It
is
important
that
stopped after 14 hours.
is
the
charging
process
time
entered.
While batteries are being entered,
aborted
when
might equal the RT-Clock time.
charged
to
the
more
batteries
are
being
any alarm-time
This will not be noted when
cycling process
indef initely.
be
The comparison of alarm-times with
RT-Clock
returned
must
To prevent
and
the
this
battery
will be
from happening, the
RT-Clock is stopped when batteries are added,
and started
again when returned to the cycling process.
It
is
obvious that
the
RT-Clocks I
time will
not be
correct after more batteries have been entered. This
no
concern
condition.
as
the
time
is
not
displayed
in
the
lS
of
idle
54
7. Operating Instructions.
7.1 Initial Power-On.
The
user
will
be
prompted
to
enter
the
hours
by
the
following displayed message:
ENTR HRS 00-23 ?
The
24-hour
mode
is
used
and
the
time
must
be entered
accordingly eg: 9 am must be entered as 09 and 9 pm as 21.
After the second digit has been entered the following
message will be displayed:
ENTR MIN 00-59 ?
Two digits must be used to enter the minutes eg: 4 minutes
must be entered as 04. After the last digit has been entered
the time will be displayed eg:
09:04:00
7.2 Charging After Initial Power-On.
The batteries that need to be cycled may be placed in any
spare positions in the unit.
Enter a 'B' and the following
message will be displayed:
ENTR BATT: 1-8 ?
Enter the battery number corresponding to the number on the
unit and the following message will be displayed:
ENTR CYCLES ?
After
entering
the
number
of
cycles
battery the time will be displayed again.
for
that
specific
55
More batteries may be entered by entering a 'B' again. When
all batteries have been entered an 'F' needs to be entered
to start the cycling process. After a short
following, by way of example, will be displayed:
delay the
C F D C F F F F
123 4 567 8
1-> 8 indicates the battery numbers on the unit.
'C' means that the battery is being charged.
'D' means that the battery is being discharged.
1Ft
means that the battery has finished cycling or that the
position is spare (unused) .
7.3 Charging SUbsequent Batteries.
To add batteries while others are being cycled or if all
positions are spare (unused). Enter a 'B' and the following
message will be displayed:
ADD MORE BATT OR
FINISH? ENTR BIF
To add a battery enter 'B' within
following message will be displayed:
5
seconds
and
the
ENTR BATT: 1-8 ?
Enter the battery number and the following message will be
displayed:
ENTR CYCLES ?
Enter the nUmber of cycles and the following message will be
displayed:
ADD MORE BATT OR
FINISH? ENTR B/F
56
Enter a
'F'
'B' within 5 seconds to enter more batteries or an
when finished.
If nothing is entered within 5
seconds
the unit will automatically return to the process
and the
following will be displayed, for example:
CDDCCFFF
12345678
When all the cycles have been completed or if all positions
are spare (unused) the following will be displayed:
FFFFFFFF
12345678
NB:
ALWAYS ENSURE THAT THE UNIT RETURNS
MODE OTHERWISE
THE BATTERIES MAY
TO THE PROCESSING
BE OVER-CHARGED
OR OVER-
DISCHARGED, RESULTING IN POSSIBLE DAMAGE TO THE BATTERIES.
7.4 Using The RS-232 Serial Port.
The
Serial
Port may
discharge
curve
of
Personal
Computer
a
be used
to
plot
particular battery.
(PC)
and
software
the
charge
A serial
packages
and
cable,
that
can
capture the data from the serial port and plot a graph are
required.
The BASIC program, Capture (Refer to page 45),
is
used to capture the data from the processor unit at a baud
rate of
1200.
for
serial
the
This program automatically
port
charger unit to
(Coml)
ie:
sets up
1200,n,8,2,p.
the serial port
of the
the mode
Connect
the
PC and follow the
procedure below:
Run
the Capture program.
When prompted,
enter a file
name to which the data must be captured, ego Testl.txt. The
charger unit must not be
reset
button.
number 1.
or
a
Place
the
in use.
battery
Reset
to
be
the unit with the
tested
In position
Enter the time. The minutes must be entered as 00
multiple
of
5
eg.
05,10,15
etc.
Enter
the battery
number (1) and number of cycles as described in section 7.2.
57
start the process by entering an 'F'. Incoming data is
captured and converted to the appropriate battery vol tages
which are then displayed on the PC monitor at five minute
intervals. This will be done irrespective of whether the
battery is being charged or discharged. This information is
automatically stored in the text file.
A package, like Quattro Pro, may now used to import the
captured file. Enter the x-axis values as five minute
intervals and plot the graph.
58
8. Test Results.
It was the objective to improve the efficiency of the
Ni-Cad batteries through a cycling process to erase any
memory effect and/or to prevent the formation thereof.
It must be stressed again that the existing charger is a
charge only system with no current or time control. The new
charger has current and time control and depending on the
battery's condition, also discharges it to the voltage
cutoff point.
The age of the batteries, and whether they had the
memory effect or not, was not known when they were received
from the Security section. Firstly all batteries were fully
charged with the existing charger. They were then cycled by
this new charger and their discharge curves were plotted.
The times taken to discharge to the cutoff voltage point is
of importance
batteries.
as
it
indicates
the
efficiency
of
the
The following results were obtained:
Battery
1st Disch.
2nd Disch.
Curve
Curve
1
+10 Min
1000 %
2
+10 Min
+25 Min
+110 Min
+75 Min
650
%
+140 Min
460
%
Number
3
% Efficiency
Improvement
The above results and the curves on pages 59 to 61 show
that the batteries suffered from the memory effect. Clearly
there was a vast improvement after only one cycle with the
new charger. The curve for battery 4 on page 62 is that of a
normally used battery without the memory effect.
As a result of this proper charging technique the lifespan of these batteries will also be increased.
59
,-
>Cl:
0
0
w
.,....
II-
«
OJ
w
0
CO
Cl)
()
0
(j)
W
w
>
Cl:
01-
(O:J
Z
~
::::>
()
ro
W
<;t
z
N
t
w
>
a:
:J
()
I(j)
.,....
(!)
Cl:
"
t
t
«
I
I!
<;t
.-
0
N
1>
()
-0
:J
f
••
Cl)
>
a:
tu)
"-
C\J
.,....
0
.-
1
t
i
I
CO
(0
C\J
38V.llO/\
60
0
CO
C\I
>a:
w
II-
«
CO
ill
0
>
er:
<0
~
0
• •
0
(J)
2
(f)
W
ill
r-
>
a:
t
:2:
ill
'1"-
I
1
1
()
W
CJ
~
0
I
I(f)
,...-
r
0
C\J
f
«
I
;r,
!
i
\
I \
()
*
!
i
,x
(J)
,
I
'1"
,...-
I
C\J
,...-
\
r
i
i
~U)
L
I
0
,...-
I
co
38V-llOJ\
>
er:
I
II
a:
-0
02
~
:::>
C\I
I
I
I
(!)
'1"
C\J
r-
LL
DISCHARGE CURVES: BATTERY 3
14,-12
10
I
I
I
f
~-----'>4-X---rc--'X----'X---X---oYf<X---7<:-C;X ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( '( ) (
X
?
"7')(~?(~
.....~
w
(!J
«
I-..J
8
0
>
6
4-
2_L1
5
I
[
I
I
I
r
20
r
(
40
I
f
r
r
I
60
I
I
I
I
I
80
MINUTES
1 ST CURVE
)(
1
I
i
I
I
I
120
100
2 NO CURVE
)
I
)
)
)
)
)
140
'"f-'
62
0
<0
or-
~
>a:
0
'>t
or-
W
II-
0
C\J
«
(J)
.....
• •
.....
0
0
w
Cl)
>
a:
t
:::>
l-
0:::>
coZ
t
()
~
I
~
W
!
f-I
f
{
CJ
a:
~O
l'>t
t
r
t
I
t
T
~~
.~
()
)
Cl)
L
I
I
I
I
L
I
0
<0
f-
\
«
I
0
w
I
'>t
C\j
or-
or-
I
0
.....
I
co
38\1110/\
I
I
<0
'>t
rL()
C\J
63
9. Bibliography.
Intel
corporation.
1990.
Mt.
8-Bit Embedded Controllers.
Prospect, Intel Literature Sales. 6-1 to 6-73.
Intel Corporation.
1988. Memory components Handbook.
Santa
Clara, Intel Literature Sales. 4-10 to 4-20.
Intel
Corporation.
1988.
Microprocessor
and
Peripheral
Handbook. Santa Clara, Intel Literature Sales. 2-63 to 2-86.
Motorola Semiconductors. 1979. The European CMOS Selection.
switzerland. 9-141 to 9-146.
Motorola
Semiconductors.
1988.
Microprocessor
Microcontroller And peripheral Data. Switzerland.
National Semiconductor Corporation. 1988. Linear Databook 1.
Santa Clara. 1-163 to 1-173, 1-254 to 1-258.
National
Semiconductor
corporation.
1984.
CMOS
Databook.
Santa Clara. 1-308 to 1-310.
National
Semiconductor
Corporation.
1988.
CMOS
Logic
Databook Santa Clara. 6-151 to 6-156.
Perez,
R.A.
1985.
The
Complete
Battery
Book.
Blue Ridge
Summit, Tab Books Inc. 41 to 62.
Philips. 1991. Data Handbook Liquid Crystal Displays LCD01.
Texas
Instruments.
1989.
The
TTL
Databook
Volume
1.
Germany. 3-411 to 3-412.
Towers, T.D. 1980. Towers' International Transistor Selector
Third Edition. Blue Ridge Summit, Tab Books Inc. 50,149,171.
64
10. Acknowledgments.
I wish
Development
to thank my colleagues in the Research
Centre
of
the
Department
of
Posts
And
and
Telecommunications, especially Mr. G.V. Williams, with whom
many helpful discussions were held.
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement