Download The Controller

Survey
yes no Was this document useful for you?
   Thank you for your participation!

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

Document related concepts

Control system wikipedia , lookup

PID controller wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Control theory wikipedia , lookup

Transcript
The CDG2000 High Performance Transceiver (Part 6)
The Controller
The controller is designed to manage all aspects of the transceiver. It provides two VFOs, manages the
user interface and controls all functions of the rig. It handles transmit / receive switching and provides
an automatic keyer. It can be seen in Picture 1.
As you may remember from the first part of this series, the three transceivers built so far have differed
widely in their interfaces. Dave wanted a minimalist design with ‘soft’ buttons and a single rotary
control. This was anathema to George who wanted separate controls for each major function. Colin’s
design fell somewhere in between.
In consequence of these widely differing requirements, the controller needed to be highly configurable.
It can support the following User Interface options:
 Up to 32 push buttons in 2 scanned banks that can be soft programmed
 1 or 2 rotary controls ( shaft encoders )
 20x2 or 40x4 alphanumeric displays or
 320x240 graphics displays
In addition it possesses:
 An I2C bus to control the transceiver
 Dual DDS control interface
 A PTT input
 A keyer input
 Analogue inputs for S meter and Power meter functions
 Switched 12 V outputs for tx/rx and mode control
 An in circuit programming interface
 An RS232 interface
All push buttons are ‘soft’ controlled. When first switched on, pressing any button causes nothing to
happen. Holding it down for more than 5 seconds however allows the button to be programmed to one
of a large number of functions by means of the main tuning control. Releasing the button stores that
button’s function in non volatile memory. It will retain that function when switched off. When the
graphics display version is used, the function associated with a button is displayed in an on screen
menu close to the button, and the functions may change with selectable menus. Picture 2 shows this.
Almost all operational parameters are configurable – the DDS frequency, the band details, the VCO
and relay control data etc. Those that cannot be configured can be altered by rebuilding the software.
The software is written in PIC assembler, and the full source code is available for Amateur use from
the Internet [1] together with a User Guide and pre-built executables for our configurations. The PIC
may be programmed in circuit in the controller by means of a small interface board plugged into the
parallel port of a PC if a dedicated PIC programmer is not available.
The Circuit
The circuit diagram of the controller is shown in Figure 3, Figure 4 and Figure 5. The heart of the
controller is a PIC micro – the PIC17C766. This is a “high end” processor in an 84 pin chip carrier with
a rich set of interface devices [2].
A number of interfaces to the controller are provided – these are summarised in Table 1.
JP1 provides two analogue inputs and also carries the keyer lines. The analogue inputs are used for the
on screen S meter and TX Power meters. Each requires an analogue voltage in the range 0 to 4 Volts
and the software allows it to be converted into an accurate S meter which will also display a textual
reading in “S” points and dBm. An example of this is shown in Picture 3. If the on screen S meter is
Controller Version 8
Page 1 of 15
not used, the controller can instead provide a DC voltage that is controllable by software and reflects
the attenuator and band settings so that an analogue S meter can be corrected automatically to read true
regardless of receiver configuration.
JP2 allows the controller to manage the Direct Digital Synthesizer that provides frequency control. In
fact, support for 2 DDS chips is provided, but only one is used at present. There is a common serial
data/clock interface and two separate load signals.
JP3 is the I2C bus that controls the transceiver. An overview of I 2C will be given later but in summary
it is a 2 wire bus that allows the controller to read and write a number of devices that are all connected
in parallel on the 2 wire bus. The detailed circuit diagram shows it on a 10 way connector, with
multiple ground and power lines. The keyer lines are also connected to the bus for convenience. The
I2C bus also controls an EEPROM that is located on the controller board that provides non volatile
storage for the rig.
JP4, 9 and 13 are concerned with power. JP9 provides power to the controller itself – a voltage
sufficient for the 5V regulator plus a negative voltage for the LCD if required. JP13 provides a high
current +12V feed to a set of FET switches. These are controlled by the processor and provide switched
voltages on JP4, allowing the processor to switch on and off 12V supplies on transmit and receive as
well as controlling other functions as required. The two main outputs for TX and RX power have active
pull downs to reduce leakage into the circuits when off.
The display is connected to JP5. A wide range of displays can be used provided that they employ an 8
bit parallel bus interface. In George’s transceiver this is a 4 line 40 character alphanumeric display
based on the industry standard HD44780 controller. In Dave’s it is a 320 x 240 pixel ¼ VGA graphics
panel with a CCFL backlight. Colin’s uses the Hitachi HD61830.
JP6 connects to one or two shaft encoders. These are used to provide main tuning and other functions
and are quadrature signal devices with two signals from each that allows the controller to read the
speed, direction and amount of rotation of each.
Keyboard scanning is provided on JP7 and JP8. The software assumes a 4x4 matrix on each port as
shown in Figure 1 providing 32 switches. Not all have to be used. Every (configurable) one or two
milliseconds a scan line is pulled low and the state of the switches for the previous scan line low is
stored. This means that within each 10 msec period all 32 switches are scanned. The scan speed is low,
so if the lines connecting keyboard to controller are long they can be heavily filtered. Note that series
resistors and pull ups are provided to facilitate this.
Apart from the LCD display updating ( and the LCD itself ! ) the controller is very quiet electrically. It
has a 32 MHz clock which is provided by a crystal connected directly to the PIC and no external bus on
which digital signals are changing unless an update to a peripheral is requested.
I2C Bus Overview
A full description of I2C bus is beyond the space available here. Detailed information is to be found
from Philips who invented it [3] and a good description is presented in the PIC17C766 datasheet [2]. In
summary, it is a two wire bus where a master provides a clock for a number of slave devices and the
master and slaves communicate by means of a single data line. It is possible to have multiple bus
masters in I2C but that option is not used here – the controller is the master. The bus operates at 100
kHz. Faster modes are possible but not necessary. The slow speed also means that the I2C bus cable can
be up to 6 feet long but keep it as short as practicable. Each device on the bus has its own address, and
Table 2 shows the addresses in use at the moment for CDG2000. When the controller wishes to address
a device, it sends a START signal by pulling low the data line whilst clock is high. When it has
finished, it signals a STOP by raising data whilst clock is high. This is shown in Figure 3. Having sent
a START, it sends the slave address of the device it wishes to communicate with, with the last bit
denoting a read or a write. The slave then acknowledges the request by sending back an ACK ( pulls
data low whilst clock goes high then low). What happens next depends on the type of peripheral. For
the simple PCF8574 [4] latches, data is then sent or received next. For more complex devices such as
the EEPROM a sub address is sent first.
Controller Version 8
Page 2 of 15
By the way, I2C bus is the same method used by the SDRAMs you probably have in your PC to
communicate with the chipset – ever wondered how the motherboard magically knows the size and
type of memory you install without you needing to configure it ?
As has been stated earlier, the I2C process in the controller software is an interrupt driven state
machine. The controller can ‘stack up’ a number of requests that the I 2C handler will process one by
one. Some of these events are time critical some are not. When the controller switches bands, for
example, it waits until it knows it has read the data for the new band from the EEPROM. When it is,
for example, updating the current frequency of the VFO it instructs the controller to have up to 5 goes
and not to bother telling it if it succeeded or not. The reason for multiple tries is that certain devices
such as EEPROMS can temporarily disconnect themselves from the bus if they are busy writing to non
volatile storage.
The CDG2000 boards are designed so that a 10 way ribbon cable with connectors crimped to it at
intervals can be used to “daisy chain” all the peripherals together. Just be careful of the orientation of
the sockets!
Construction
Like other CDG2000 boards, the controller is a single Eurocard 160 x 100 mm. It is a single sided
board with a ground plane. Given the density of wiring for the PIC however, a number of wire links are
required. Picture 1 shows the controller PCB, and PCB artwork, layout, component lists and other
constructional details are available on the internet [1]. The authors can also supply it on CD if required.
Construction is straightforward – the main things to be careful of are the pins that connect directly to
the ground plane and the orientation of the connectors.
Full programming details are also not presented here. A program is available to allow this to be
performed. Ready programmed PICs may be made available – check with the authors for details.
Programming is effected using a small interface connected to the controller.
Configuration Data
As a minimum of data is hard coded, most data items can be changed from the screen. Specifically, the
actual DDS frequency, band limits, step rate, IF offset, per band relay settings, S meter calibration data
and VCO control words may be altered.
Full details are not presented here but are in the user guide[1]. In order to facilitate setting the data, a
spreadsheet is available to calculate all the nasty hex values that must be entered for a specific clock
frequency and band configuration.
Software Internals
Internally the CPU operates on 1msec, 10msec and 1 second cycles. Every second millisecond, the
push button scan is advanced and the PTT line is debounced. Both are debounced digitally to avoid
transient effects and the results are made available for the 10 msec process. Every 10 msec, the core
events are processed in sequence; all push button events are handled, the transmit / receive and keyer
finite state machines are executed, the display is updated and any required peripheral events are
initiated. Every second, EEPROM data writes occur if required and miscellaneous events such as
controlling the LCD backlight are processed.
Interrupts are used for the following:
 PTT line changes
 Opto shaft encoder events
 I2C event interrupts
 1 millisecond core clock events
Controller Version 8
Page 3 of 15
I2C activity is controlled by a background interrupt driven finite state machine. When the main
processes want to request I2C activity, they locate a free buffer, define the required activity by setting
the buffer and then pass it to the event handler.
Concern has been raised over the responsiveness of PIC processors when used for tuning control and
display frequency update [6] and the use of dual PICs has been suggested. This is avoided here by
virtue of the interrupt handling of opto events and the 10msec main event loop. If an alphanumeric
display is used, frequency updates on the screen take under 7 msec. When a graphics display is used it
takes between 18 and 21 msec, well over the 10 msec loop. This has no effect however on performance
as interrupt collected tuning events are accumulated and handled within the main loop (in this case
every 20 msec when the frequency is changed, 10 msec otherwise) so that it remains responsive
without losing pulses. No detrimental effect will be noticed in use.
All band data and related parameters are stored in the EEPROM. On first use however there is no need
to pre-configure the EEPROM. Critical data is checksummed and if the data read does not pass
checking, it is rejected and data from the EPROM memory of the PIC is used instead. If a change is
made to the data, the updated values are written back to EEPROM to be read next time it is needed. It
is also possible to ask the controller to reinitialise the data from EPROM.
References
[1]
[2]
[3]
[4]
[5]
http://www.warc.org.uk
Microchip PIC17C766 datasheet, reference DS30289A from http://www.microchip.com
Philips I2C bus information from http://www.semiconductors.philips.com/i2c
PCF8574 datasheet from http://www.semiconductors.philips.com
Microchip in circuit programing specification for the PIC17C7xx, DS30274B from
http://www.microchip.com
[6] Use of PICs in DDS designs, Technical Topics, RadCom January 2001, p61
Controller Version 8
Page 4 of 15
Picture 1 - controller PCB
Picture 2 - display detail
Controller Version 8
Page 5 of 15
Picture 3 - S Meter closeup
Controller Version 8
Page 6 of 15
Connector
Usage
P1
Future RS232 interface
JP1
IF log amp ( s meter ) & power meter inputs and keyer input
JP2
DDS bus – drives 1 or 2 DDS devices
JP3
I2C bus.
JP4
switched 12V outputs
JP5
LCD connector
JP6
Opto switches
JP7
switch matrix input 2
JP8
switch matrix input 1
JP9
power to the controller ( +12V and whatever negative voltage the
LCD & RS232 need )
JP10
in circuit serial programming interface.
JP11
write protect configuration data in EEPROM.
JP12
unused and not fitted – future interrupt input from I2C
JP13
incoming 12V to the FET switches
JP14
push to talk. Ground for transmit
Table 1 - interfaces to the controller
Address
range
Device
Usage
A0-AF
ST24C16
EEPROM
54-55
MAX521
8 analogue outputs
5A-5B
DS1807
ChA=mic gain ChB=af gain
5C-5D
DS1807
ChA=vox gain ChB=antivox
4E-4F
PCF8574
Band switch for LPF
4A-4B
PCF8574
VCO control
48-49
PCF8574
Secondary band switch for LPF
46-47
PCF8574
DSP Control
44-45
PCF8574
first band switch on front end
board
42-43
PCF8574
second band switch on front end
Table 2 - I2C device address map
Controller Version 8
Page 7 of 15
D0
D1
D2
D3
D4
D5
D6
Figure 1 - Switch scan circuit
Controller Version 8
Page 8 of 15
D7
Data
(SDA)
Clock
(SCL)
Data
Transfer
S
Start Condition
Figure 2 - I2C Start & Stop
Controller Version 8
Page 9 of 15
P
Stop Condition
VCC
R17
100k
R18
100k
VCC
RF[0..7]
RELAYS[0..7]
JP1
1
2
3
4
5
6
7
8
HEADER 8
KEY_0
KEY_1
RS232-CTS
RS232-RTS
RS232-TXD
RS232-RXD
PORT-H[0..7]
RH[0..7]
PORT-J[0..7]
PGM-VPP
RJ[0..7]
3
246
7 2451
RF0
RF1
RF2
RF3
RF4
RF5
RF6
RF7
GND
RH0
RH1
RH2
RH3
RH4
RH5
RH6
RH7
RJ0
RJ1
RJ2
RJ3
RJ4
RJ5
RJ6
RJ7
R10
C1
PGM-TEST
10K
R11
10K
10pF
Y1
33MHz
36
35
30
29
28
27
26
25
42
41
40
39
46
47
49
48
10
11
12
13
31
32
33
34
52
53
54
55
73
74
75
76
20
21
62
63
RF0
RF1
RF2
RF3
RF4
RF5
RF6
RF7
RG0
RG1
RG2
RG3
RG4
RG5
RG6
RG7
RH0
RH1
RH2
RH3
RH4
RH5
RH6
RH7
RJ0
RJ1
RJ2
RJ3
RJ4
RJ5
RJ6
RJ7
MCLR
TEST
OSC1
OSC2
A VVVV
V DDDD
D DDDD
D
A
V
S
S
3
8
VVVV
SSSS
SSSS
2468
3454
C2
GND
PGM-DCLK
PGM-IO
PGM-CLK
10pF
C3
L1
0u1
2u2
GND
GND
RA0
RA1
RA2
RA3
RA4
RA5
RB0
RB1
RB2
RB3
RB4
RB5
RB6
RB7
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
RD0
RD1
RD2
RD3
RD4
RD5
RD6
RD7
RE0
RE1
RE2
RE3
U1
72
56
57
58
51
50
71
70
66
69
68
67
59
60
3
83
82
81
80
79
78
77
15
14
9
8
7
6
5
4
16
17
18
19
R1
4k7
R2
4k7
PTT
RB0
RB1
RB2
RB3
RB4
RB5
RB6
RB7
VCC
RB[0..7]
GND
GND
GND
VCC
VCC
JP3
1
2
3
4
5
6
7
8
KEY_0
9 10
KEY_1
HEADER 5X2
I2C BUS
I2C-SCL
I2C-SDA
VCC
R5
47k
6
5
7
1
2
3
PORT-B[0..7]
21
JP12
HEADER 2
I2C INT
JP11
1
2
HEADER 2
WR PROT
U2
SCL
SDA
MODE
PRE
PB0
PB1
24C16
GND
LCD-RS
LCD-RW
LCD-E
LCD-CS
LCD-RES
OPTO1_B
OPTO2_B
RD0
RD1
RD2
RD3
RD4
RD5
RD6
RD7
PIC17C76X
RD[0..7]
PORT-D[0..7]
DDS CLK
DDS DATA
DDS1 E
DDS2 E
GND
JP2
1
2
3
4
5
6
7
8
9 10
HEADER 5X2
DDS BUS
Title
CDG2000 Controller V2
Size Document Number
B
.\NEWCTRL1
Date: September 16, 2001
Sheet
Controller Version 8
Page 10 of 15
1
of
REV
4
4
Figure 3 - Controller circuit diagram - part 1 of 3
Controller Version 8
Page 11 of 15
VCC
VCC
5
R12
GND
22K VAR
LCD-RW
VEE
PORT-D[0..7]
RS232-RTS
JP5
1
2
3
4
5
6
7
8
9 10
11 12
13 14
15 16
17 18
19 20
HEADER 10X2
LCD
RD0
RD2
RD4
RD6
LCD-CS
6
U4A
LCD-RS
LCD-E
RD1
RD3
RD5
RD7
2
RS232-CTS
9
RB7
PORT-B[0..7]
JP6
1
2
3
4
5
6
7
8
9 10
HEADER 5X2
OPTO SWITCHES
OPTO1_INT
GND
VCC
GND
2
3
U5C
1489
1
1
2
3
4
5
6
7
8
RF0
RF1
RF2
RF3
RF4
RF5
RF6
RF7
RF[0..7]
87654321
R3
8x10K
9
9
R4
100K
1
0
I1 C O1
O
I2
O2
I3 M O3
I4
O4
I5
O5
I6
O6
I7
O7
I8
O8
U3
ULN2803A
Q1
VP0300L
Q2
VP0300L
1488
U4C
8
1488
U4B
4
5
6
1488
GND
Q3
VP0300L
Q4
VP0300L
Q5
IRF9Z24N
12345678
18
17
16
15
14
13
12
11
GND
Q8
IRF9Z24N
P1
CONNECTOR DB9
11
9
10
10
U5A
1489
RB[0..7]
JP13
1
2
3
4
HEADER 4
SW POWER IN
GND
RELAYS[0..7]
8
OPTO1_B
GND
VCC
OPTO2_B
GND
13
U5D
1489
U4D
12
13
5
9
4
8
3
7
2
6
1
1
2
11
RS232-TXD
RB6
3
RS232-RXD
RD[0..7]
GND
U5B
1489
1488
LCD-RES
4
Q7
IRF9Z24N
JP4
1
2
3
4
5
6
7
8
9
10
HEADER 10
POWER OUT
Q6
IRF9Z24N
R8
100
1W
R7
100
1W
Q10
VN0300L
Q9
VN0300L
GND
GND
Title
CDG2000 CONTROLLER V2
Size Document Number
B
.\NEWCTRL2
Date: September 16, 2001
Sheet
2
Controller Version 8
Page 12 of 15
of
REV
4
4
Figure 4 - Controller circuit diagram - part 2 of 3
Controller Version 8
Page 13 of 15
VCC Vsupp
VCC
9
12345678
RH0
RH1
RH2
RH3
RH4
RH5
RH6
RH7
PORT-H[0..7]
16
15
14
13
12
11
10
9
R6
1N4148
1k
JP10
1
2
3
4
5
6
7
8
9
10
HEADER 10
PROGRAM
PGM-VPP
PGM-CLK
PGM-IO
PGM-DCLK
PGM-TEST
R13
100K
R15
D1
JP8
1
2
3
4
5
6
7
8
9 10
HEADER 5X2
KEY SWITCH 1
1
2
3
4
5
6
7
8
VCC
GND
1K
RH[0..7]
GND
VCC
9
R14
100K
PTT
12345678
GND
RJ0
RJ1
RJ2
RJ3
RJ4
RJ5
RJ6
RJ7
PORT-J[0..7]
16
15
14
13
12
11
10
9
R16
JP7
1
2
3
4
5
6
7
8
9 10
HEADER 5X2
KEY SWITCH 2
1
2
3
4
5
6
7
8
JP14
1
2
HEADER 2
PTT
VCC
1K
RJ[0..7]
GND
Vsupp
JP9
1
2
3
HEADER 3
CTRL PWR
VDD
U6
7805
1
3
2
C4
10u
VCC
C5
1u
C6
100n
C8
100n
C7
100n
VEE
C10
100n
C9
100n
C11
100n
Title
GND
Controller Version 8
Page 14 of 15
VSS
CDG2000 CONTROLLER V2
Size Document Number
B
.\NEWCTRL3
Date: September 16, 2001
Sheet
3
of
REV
4
4
Figure 5 - Controller Circuit diagram - part 3 of 3
Controller Version 8
Page 15 of 15