|
A FAST TUNING 16F877 DDS CONTROLLER
Tuning Rate
Hardware Bootloader
Software
The dual PIC controller was developed to produce a fast tuning rate when used
with fairly slow LCD modules. Since this was designed faster PIC's became available allowing the performance of the Dual PIC design to be improved by
simply increasing the speed of the DDS controller PIC to 20MHz. I was
considering using spare processing time in the LCD PIC to implement and A to D
allowing line 2 of the LCD to be used as an S-Meter. However Microchips range
of PIC devices has expanded considerably over the past few years and one device
in particular, the 16F877, offers many advantages to the designer;
- Expanded I/O
-
8k Flash Memory
-
Integral A to D
-
In Circuit Debugger
-
In Circuit Programming
-
20MHz clock speed
-
16F84 Code easily adapted
I decided to replace my dual DDS controller with a single 16F877. The features of
this device would allow me to easily incorporate new functionality with
minimal additional hardware and software development. The basic requirements for
the new controller were;
- Fast Tuning (no need for variable tuning rate)
-
S-Meter on Line 2
-
IF Offset - switched sum/difference
-
IF Offset - switched enable/disable (for Direct Tx/Superhet Rx)
-
RIT
-
LCD Display
-
Minimal external components
Speeding It Up
The fast tuning feature was at the heart of the design. Without a good tuning
rate of around 20kHz/Second the system would be too slow for comfortable use. I didn't
want to use variable rate tuning, personally I dislike this approach, my
preference is for a "true vfo feel". To realise a fast tuning rate it
was
essential to streamline the overall tuning process. This comprises of many
routines to process encoder information and translate it into display and DDS
data with appropriate compensation for IF frequencies and RIT. One of the most
time consuming routines is the LCD interface. In the Dual PIC design the
processing was split between two PIC's with the LCD only being updated every
10mS or so. The relatively infrequent LCD update rate is the key to increasing
the tuning rate of this type of design. This is based upon the principle that
the human eye/brain could not possibly process changing display information at a
rate of more than about 20 updates per second. On this basis any display
activity above this rate is unnecessary and a waste of processing time - a
critical aspect of single processor design. The routine associated with the LCD
update control is shown below;
;
**************************************************************************************************
; Determine whether we need to update the LCD frequency and S-Meter, this decision
; is based upon the state of counters which decrement with each polling loop cycle.
; The principle is that the LCD does not need to be updated on every polling cycle
; or frequency step. If the software were configured this way the tuning rate would
; be slow and the user would not be able to process visual information from the LCD
; fast enough to notice any benefit. The S-Meter is updated fewer times than the
; frequency display because the time constant of a typical agc system makes a high
; update rate unnecessary.
; **************************************************************************************************
; LCD Updates
; Frequency Display Update
decfsz main_LCD_counter,f ; Count loop cycles and call LCD update
goto check_controls
; Not time to update LCD Freq, move on
movlw 0xFF
; Re-load loop counter
movwf main_LCD_counter
call bin2BCD
; Update LCD Frequency
call show_freq
; S-Meter Update
decfsz main_S_counter,f
; Count loop cycles and call S-Meter update
goto check_controls
; Not time to update S-Meter, move onto IF checks
movlw 0x20
; Re-load loop counter (Nested counter within LCD Updates
movwf main_S_counter
; routine S-Meter rate =polling rate/(main_LCD_Counter*main_S_Counter)
call S_Meter
; Update LCD S-Meter
check_controls
; Check state of Port D Controls
movf PortD,w ; Get the current Port D value
movwf cntl_read ; Save it
movlw b'00111111' ; Get switch mask
andwf cntl_read,w ; Isolate control switch bits
movwf cntl_new ; Save new value
xorwf cntl_old,w ; Has it changed?
btfsc STATUS,B_Z ;
goto tuning_step ; No, jump to tuning routine
A second technique is used in this design to reduce the time taken to update the
display. An 8 bit interface, rather than the more common 4 bit configuration, is
used to transfer data to the display a byte at a time. This almost halves the
display update time further reducing processing time required to be dedicated to
display activity.
Display Updates
The display update process has two branches, one to update the frequency and the
second to drive the S-Meter bar graph on line 2. The separation of these two
display activities from a single process offers a further improvement in
efficiency. A faster update rate is desirable for the frequency information to
give the user the impression that the displayed frequency is closely tracking
the DDS output. The S-Meter bar graph updates can be much slower, principally
because of the relatively slow response time of the analogue voltage that it is
representing. This slow response is set by the AGC time constant of the host
receiver. Similarly if the bar graph were to be used to represent a Tx output
power, a damped (slow) response is desired to average out fast changes. The
frequency and S-Meter update routines are called from a nested counter routine
where a full counter cycle of the frequency updates occurs before the secondary
S-Meter counter is decremented. The constants in both counters can be adjusted
in the program to suit personal preference, note that reducing the counts (i.e. increasing the update rate) will slow the tuning speed. The counter routines sit
inside the main polling loop used to scan the controls and shaft encoder. This
runs continuously regardless of tuning activity and is a convenient way of
efficiently driving the display counters routine. During each cycle of the
polling loop the frequency update counter is decremented, during each zero and
reload cycle of the frequency update counter, the frequency display is updated
and the S-Meter counter is decremented. During each zero and reload cycle of the
S-Meter counter the bar graph is updated.
Fig.1 Display under Beta version software
Tuning Rate
Normal tuning rate employs 10Hz steps. The action of the software is such that
with every transition of the shaft encoder a frequency step in incremented or
decremented. Therefore the number of steps per revolution is twice the encoder
wheel step size. With the 512 step HP Agilent code wheel specified the normal
tuning rate is 10,240kHz per revolution. A slower rate using a 1Hz step
size is selectable. This fine tuning rate offers a 1,024kHz per revolution tuning speed
for netting purposes. The 1Hz tuning rate is also selected during RIT operation
as it is presumed that this function will be used to compensate for small
differences between the transmit and receive frequency of the distant station.
Hardware
The prototype was built using a PIC40 prototype board from Olimex
(www.olimex.com/pcb). This had the
advantage of a useful prototype area and an
integral RS232 interface to support ICD/ICP. This latter feature greatly speeded
up development of the software by allowing programming access with the device in
situ. A strongly recommended approach to any PIC development of this scale.

Fig.2 Controller Board with connectors and pull up SIL packages fitted

Fig.3 Transceiver showing from left to right Shaft Encoder, Controller Board and
DDS unit
Bootloader
The Bootloader program
http://www.workingtex.com/htpic/PIC_bootloader.htm
offered as freeware by Shane Tolmie was used in conjunction with the
WLdownloader program written by Petr Kolomaznik
http://www.ehl.cz/pic/pic_e.htm.
These two pieces of software are well proven and reliable. The program can be
downloaded direct into the PIC, whilst it is in circuit, in a few seconds. A
tremendous advantage over repeated removal and replacement for external
programming.
The Bootloader program has to be first installed into the target
PIC, for this you will need to perform a "one off" programming of the
16F877 in a standard 40 pin compatible programmer. I use P16PRO40 hardware in conjunction
with IC-Prog software; http://
www.ic-prog.com
.This is an excellent combination for most PIC's up
to 40 Pins. Note that this Bootloader uses different pins on the 16F877 than the
Microchip version. The Olimex board RS232 interface is wired to PortB 6 and 7
for ICD/ICP. These connections are easily extended to the PortC 6 and 7 pins
used by Shane's Bootloader.
A new version of the Bootloader is now available that is compatible with
MPLAB-ICD. I haven't tried this yet.
PIC Software
Several variants are presented below to suit
different hardware configurations. Port allocations are given in the header
text of each asm file. Please note any comments relating to the test status
and hardware. This software contains modules adapted from
software published by others, notably the NJQRP Club. Please note original
author details!
1. Original Version.
This is the first published Beta version. Later
versions include additional functionality, however I have retained this version
on the web page for archive purposes.
Beta
16F877 DDS Controller 877_1n.asm
2. Band Select Outputs.
This version offers 4 bit binary band select
outputs which can be used to drive Band Filter switching. A typical application
might use a 4 to 16 line decoder and two ULN2003's, or similar Darlington
drivers, to operate filter selection relays. NOTE THE RE-ALLOCATION OF PORTS!!
Port A is kept free for future analogue uses.
This version supercedes the 2d revision and
features changes to the configuration word to disable the Watchdog Timer, a
correction to the Calibrate function (this now works) and a general tidy up of
the narrative. Ignore any previous mention of the removal of the 4 "nop's"
in front of the band table when programming without a Bootloader, it works fine
with them left in.
16F877 DDS Controller
with Band Filter Selection outputs 877_2f.asm
3. 4 Bit LCD DT106 Board
This version has been developed for used with commercial
16F877 boards employing a 4 bit LCD interface on Port B. One of the more popular
units in this category is the very reasonably priced Dontronics DT106. Note that
for access to all of the ports used for control inputs and data/control outputs,
it is necessary to build a simple interface board to provide pull up resistors
and connectivity. This is easily achieved by making an IDC cable to extend the
40 pin connector on the DT106 to a separate interface board constructed on a
Dontronics DT202 proto board.
I have tested this software as far as the display, I
haven't added an interface board for full implementation however, as there are
no changes other than to the display routines it should function successfully.
If you try this drop me an email to let me know how it
goes, better still if you have the spare time to lift the 4bit interface in this
version and drop it into the 8 bit version above please go ahead. If you get it
working email it to me and I'll post it below.
16F877 DDS
Controller for Dontronics DT106 or similar 4 bit Port B boards
877_4_1a.asm
Enjoy!
rontaylor@g4gxo.freeserve.co.uk
|