LCD FREQUENCY COUNTER WITH EEPROM FUNCTION

Software: LCD4DIEC.asm
Edited
by: Osmo OH6CJ
Date: 29th
April 2001
Page udated: September 2001

Osmo, OH6CJ, did a good job! He enhanced LCD digital scale in a few
very important features:

Description

Start-up
of the counter

Parameter
settings

How
to use

Schematics

PCB

Component
placement

How
it looks

Description

This software version is based on the Peter's OM3CPH LCD4DIGI.asm
version on this web page. User's parameter set possibility has been added
using PIC's EEPROM memory and save functions. This SW has been designed
for 4 MHz xtal. As this version has four bit data bus between PIC and LCD
unit, the remaining four I/O-pins are available for counter control. There
are now two modes available:

COUNTER MODE and

EEPROM MODE.

The RB0...RB3 have different functions in both modes:

----------------------------------------------------------
COUNTER
MODE
False (0) True
(1)
----------------------------------------------------------
RB0
COUNTER MODE EEPROM MODE *)
RB1 RF offset1 RF offset2
RB2 Offset 1
& 2 Direct frequency
RB3 Normal 10 divider (decimal point
location)
----------------------------------------------------------
EEPROM
MODE
False (0) True
(1)
----------------------------------------------------------
RB0 -
Increase EEPROM address
RB1 - Increase data value
RB2 - Decrease
data value
RB3 - Save to
EEPROM
----------------------------------------------------------
*)
Access to the EEPROM mode is enabled when the RB0 is true (1) and +5 V
power is connected to the counter. Exit from the EEPROM mode is made by
disconnecting +5 V. When the RB0 is false (0) and power is connected, the
COUNTER MODE is started.

----------------------------------------------------------
EEPROM
ADDRESSES
----------------
; 00 = MFt1_HigB = High Byte of RF
offset1 (def. 0D) 9001.50 kHz = 0DBC36
; 01 = MFt1_MidB = Mid Byte of
RF offset1 (def. BC)
; 02 = MFt1_LowB = Low Byte of RF offset1 (def.
36)
; 03 = MFt2_HigB = High Byte of RF offset2 (def. 0D) 8998.50 khz =
0DBB0A
; 04 = MFt2_MidB = Mid Byte of RF offset2 (def. BB)
; 05 =
MFt2_LowB = Low Byte of RF offset2 (def. 0A)
; 06 = Direct_freq =
Direct frequency counter without sub or add = 00 h
; Sub or Add
function activated = 01...FFh (def. 00h)
; 07 = EE_Fine1 = Counter
value for calibration 1 == 3*4/fx= 3us (def. 15)
; 08 = EE_Fine2 =
Counter value for calibration 1 == 4*4/fx= 4us (def. 01)
; 09 =
1x16_Disp = LCD display type: 0 = 1x16 LCD, 1 = 2x20 LCD (def. 01)
; 0A
= Digits = Number of displayed digits: 0 = 7 digits, 1 = 6 (def. 1)
;
0B...0Eh = (not in use)
; 0F = Defaults = When set to 01...FFh then
defaults are restored to EEPROM
; on next power-on.

Start-up of the counter

After the 16F84 (16C84) PIC has been programmed and +5 V power is
connected to the PIC, the default values are saved automatically into the
EEPROM.

If you going to use your counter to measure the VFO frequency and use
it for receiving frequency indication, you have to know the receiver
IF-frequency (455kHz, 9.000 MHz..etc).
With the SSB mode you must know
the BFO frequency and use it as a Display offset. E.g. BFO frequency for
LSB is 9001.5 MHz and USB 8998.5 MHz in superheterodyne receiver. With AM
and FM mode use IF frequency as Display offset.
Next you have to
convert this frequency to hexa format so that the first digit on right
means 10 Hz decade e.g 9000.00 kHz IF = 900000. Conversion to hexa = DBBA0
h. Next this hexa value is divided for two digit groups by starting from
right: 0D BB A0
D = 0D = MFt1_HigB
BB =
MFt1_MidB
A0 = MFt1_LowB

Calculate MFt2 using similar method if needed.

Parameter settings

Keep RB0 in state true (1) and connect +5 V to the counter.

Text "EEPROM MODE x.x" is displayed. (x.x = software version)

Text is shown at least 1.4 seconds until the RB0...RB3 have value
False (0)

Next text "ADDR:00 DATA: FF" is displayed. This means EEPROM address
00h and its data value is FFh.

Press the RB1 (increment) or RB2 (decrement) to set calculated RF
offset values.

When the data value is correct, press RB3 to save the value to
EEPROM. When saved text "*SAVED*" is displayed and data is read again
and displayed. This is a method to check the value immediately after
saving.

Select next address 01h by RB0 and set the next data value. Press
RB3 to save the value to EEPROM.

Repeat until all needed parameters have been set and saved (EEPROM
addresses 01...0Ah).

Addresses 0B...0Eh are not in use. Exit the EEPROM MODE by
disconnecting +5V.

Connect +5V back to the counter. Now the counter should display the
measured frequency. (COUNTER MODE).

Calibrate the counter by comparing with another calibrated counter
or by means of receiver (short wave reference station).

EXAMPLE:

The minimum step is 1 us using the combinations of EE_fine1 & 2
based on the 4 MHz crystal. Relative effect of the one step is
1us/100000 us = 0.00001. A bit smaller value for T4 (see the mpasm code)
is used than calculated according to formula in mpasm code to get +/-
adjusting range for final correction by EE_fine1 and EE_fine2.
The
correct calibration value is found by means of the combination of
EE_fine1&2 and comparing to reference frequency source. E.g. the
freq. of calibrated reference source is 10.00000 MHz and counter shows
9.99980 MHz, then the counting window is too short. Increase DELAY.

See the table below.

However the most accurate calibration tuning is made in HW by
adjusting one of the capacitor in the crystal circuit.

---------------------------------------
07h 08h
DELAY
EE_fine1 EE_fine2
1== 3 us 1== 4
us
---------------------------------------
60 us 02h 09h
61 us
13h 01h
62 us 12h 02h
63 us 03h 09h
64 us 14h 01h
65 us 13h
02h
66 us 12h 03h
67 us 15h ----> 01h ---> Default
68 us
14h 02h
69 us 13h 03h
70 us 16h 01h
71 us 15h 02h
72 us 14h
03h
73 us 13h 04h
74 us 16h
02h
---------------------------------------

Change the EEPROM address 07 & 08 values according to table
above until the nearest value has been found. If the displayed frequency
is below the reference, increase the delay and vise versa.

How to use

RB1

is used to select either RF offset1 or RF
offset2.

RB2

is used to indicate direct frequency without
add or sub the offsets.

RB3

is used to move the decimal point one digit
to right, if additional 10 divider is used front of the counter input to
extend the measuring range to VHF frequencies. The second decimal point is
not displayed with 6 digit mode.

RA2

is used to select either ADD or SUB the RF
offset.

Note!

If Address 0Fh = 01...FFh the default values are saved back to the EEPROM on
the next power-on.

Schematics

PCB

Components placement

How it looks

Great! Thank you, Osmo!