Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
RF signal generatorpart 1: circuit descriptions
An RF signal genera-tor is used for repair-ing radio/TV circuits,
checking filters, align-ing receivers, and forcomparative sensitiv-
ity tests on all kinds ofreceivers, whether
home-made, restoredsurplus or off -the -
shelf. The generatordescribed here has an
output frequencyrange of 0.5 to
30 MHz, making itsuitable for many
applications.
A rock -solid RF signal with an accu-rately known frequency and level is amust for anyone seriously involved inrepairing radio receivers and othercommunications equipment like filtersand even antennas. In particular,
Main specificationsFrequency range: 0.5 MHz to 30 MHzOutput level: 0 dBm down to -79 dBm in 1 -dB stepsMax. output level: 0.63VPP into 50 Q
In* Output impedance: 50 Q AM input FM input
LCD readoutMicroprocessor controlledOptional serial interface
Design by Guido Brunner
receiver RF input and IF (intermediatefrequency) sections can not be testedwith any degree of certainty if a trust-worthy RF signal generator is not tohand. Unfortunately, professional -grade RF signal generators (like themighty Hewlett Packard 8640B in ourdesign lab) cost an arm and a leg, evenin the surplus trade. None the less, youwill see at least one RF signal generator,home-made, thrown together fromother bits and pieces, or ex -MOD, inthe shack of the more advanced radioamateur, simply because this piece oftest gear is as indispensable as the plainold multimeter.
The stability of the RF signal gen-erator described in this article is suchthat it will meet the (moderate)demands of many amateurs. Offeringa frequency range of 0.5 through30 MHz and an output level down to-80 dBm, it is perfect for testing andaligning many receivers and their sub -circuits like RF/IF amplifiers, mixers
Aio Elektor Electronics 11/98Elektor Electronics 11/98
A rock-solid RF signal with an accu-rately known frequency and level is amust for anyone seriously involved inrepairing radio receivers and othercommunications equipment like filtersand even antennas. In particular,
receiver RF input and IF (intermediatefrequency) sections can not be testedwith any degree of certainty if a trust-worthy RF signal generator is not tohand. Unfortunately, professional-grade RF signal generators (like themighty Hewlett Packard 8640B in ourdesign lab) cost an arm and a leg, evenin the surplus trade. None the less, youwill see at least one RF signal generator,home-made, thrown together fromother bits and pieces, or ex-MOD, inthe shack of the more advanced radioamateur, simply because this piece oftest gear is as indispensable as the plainold multimeter.
The stability of the RF signal gen-erator described in this article is suchthat it will meet the (moderate)demands of many amateurs. Offeringa frequency range of 0.5 through30 MHz and an output level down to–80 dBm, it is perfect for testing andaligning many receivers and their sub-circuits like RF/IF amplifiers, mixers
An RF signal genera-tor is used for repair-ing radio/TV circuits,
checking filters, align-ing receivers, and forcomparative sensitiv-
ity tests on all kinds ofreceivers, whether
home-made, restoredsurplus or off-the-
shelf. The generatordescribed here has an
output frequencyrange of 0.5 to
30 MHz, making itsuitable for many
applications.
10
Design by Guido Brunner
RF signal generator
RADIO, TELEVISION & VIDEO
Main specificationsà Frequency range: 0.5 MHz to 30 MHzà Output level: 0 dBm down to –79 dBm in 1-dB stepsà Max. output level: 0.63Vpp into 50 Ωà Output impedance: 50 Ωà AM inputà FM inputà LCD readoutà Microprocessor controlledà Optional serial interface
part 1: circuit descriptions
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor uk
and demodulators.What requirements can be men-
tioned in relation to an RF signal gen-erator? The answer is very simpleindeed: you need to be sure of (1) thefrequency and (2) the level of the signalyou feed into the circuit (receiver)under test. If either of these is unreli-able, all testing and comparing ofreceiver specs becomes meaningless.In the present design, frequency sta-bility is assured by a PLL (phase -locked loop), while the output level isdetermined by a switched pi (pi) atten-uator, all under the control of a micro-processor.
BLOCK DIAGRAMBecause the actual circuit diagrams ofthe four modules that make up the sig-nal generator are a fairly complex lot
when presented together, it wasdecided to draw and dis-
cuss them as separateblocks. The
basic interac-tion ofthese blocksis illustratedin Figure 1.The blockdiagramshows thatthe heart ofthe circuit isa PLL syn-thesizer mod-ule keeping aVCO (volt-
age -controlledoscillator) in check. The
VCO output signal is amplified andfed to the generator output as well tothe synthesizer input and the input ofthe attenuator. The PLL obtains digitalinformation on the target VCO fre-quency from a microprocessor module.The micro also takes care of the front -panel mounted user interface, whichconsists of 3 switches, a rotary encoderand an LCD (liquid -crystal display). Italso controls the amount of attenuationat the generator output, across a rangeof -1 dB through -79 dB. An optionalserial interface is available to enable theRF Signal Generator to be linked to aPC using an RS232 cable. Functionally,the instrument is completed by aninternal power supply.
PLL BOARDThe circuit diagram of this first moduleto be discussed in detail is shown inFigure 2. It comprises three sub -cir-cuits: VCO, synthesizer and outputbuffer. The VCO and the synthesizertogether from the PLL.
VCO and buffersThe active element in the oscillator is adifferential amplifier built around tran-sistors T1, T2 and T3, whose gain
depends on the currentpassed by T3. The actualresonating element inthe oscillator is an L -Cparallel tuned circuitconnected to the inputof the difference amplifier. The LC net-work consists of inductors L1 -L5 incombination with variable -capacitancediodes (varicaps) D9 and D10. Theother input of the oscillator isgrounded for RF by capacitor C10.Depending on the desired frequencyrange, one or more inductors areswitched into the oscillator. This isdone by pulling the non-commonedterminals to RF ground using +5Vcontrol voltages on PIN diodes D2, D4,D6 and D8. In the highest frequencyrange, all inductors are effectively con-nected in parallel. This is necessary tomake sure that the non -selected induc-tors and their parasitic capacitance cannot form a series tuned circuit thatwould prevent the oscillator fromoperating at the desired frequency. Allinductors are off -the -shelf miniaturechokes. The frequency range switchingtakes place at 1.024 MHz, 2.304 MHz,5.376 MHz and 13.056 MHz.
Capacitor C8 provides the neces-sary amount of positive feedback in theoscillator. An AF signal may be appliedto the emitter of T4 to effect amplitudemodulation (AM). Frequency modula-tion (FM) is also possible by superim-posing an AF signal onto the varicaptuning voltage. Although FM willcause the PLL to drop out of lock, theaverage frequency remains constantbecause the time constant of the con -
0.5 ... 30 MHz
LCD
1/4
Figure 1. Block dia-gram of the RF SignalGenerator. All intelli-gence is vested in amicrocontroller.
980053-11
trol loop is not capableof tracking the 'insta-bility' caused by themodulation signal.
To make sure it isnot too heavily loaded,
the oscillator signal is first buffered by aFET (field-effect transistor), T4. Nextcomes the real amplifier, IC1, a typeNE592 which some of you may knowfrom baseband-video amplifiers insatellite -TV receivers. The amplifier isbiased at half the supply voltage byopamp IC3b, and its gain is defined byseries network R26 -L8. Because of theinductor action, the gain decreases athigher frequencies. Because the VCOstrives to maintain a stable outputlevel, less gain on the NE592 automat-ically more gain in the differential oscil-lator. This purposely -created effect isessential for reliable starting of theoscillator at higher frequencies.
The NE592 being a differentialamplifier, it has two inputs, but alsooutputs. Both are used here. The signalat the first output (pin 7) is applied toemitter follower T5 which supplies theactual generator output signal at animpedance of 50 Q (the standard in RFtest equipment). The other output sig-nal supplied by the NE592 is used todrive two sub -circuits. One branchgoes to the PLL chip via C23 and R33,the other is used to drive a voltage rec-tifier/doubler, D11 -D12 which in turndrives amplitude -control opamp IC3a.The desired highest output amplitudemay be set using preset P1. The authorused a setting where 0 dBm (decibel-
Elektor Electronics 11/98
and demodulators.What requirements can be men-
tioned in relation to an RF signal gen-erator? The answer is very simpleindeed: you need to be sure of (1) thefrequency and (2) the level of the signalyou feed into the circuit (receiver)under test. If either of these is unreli-able, all testing and comparing ofreceiver specs becomes meaningless.In the present design, frequency sta-bility is assured by a PLL (phase-locked loop), while the output level isdetermined by a switched pi (pi) atten-uator, all under the control of a micro-processor.
B L O C K D I A G R A MBecause the actual circuit diagrams ofthe four modules that make up the sig-nal generator are a fairly complex lot
when presented together, it wasdecided to draw and dis-
cuss them as separateblocks. The
basic interac-tion ofthese blocksis illustratedin Figure 1.The blockd i a g r a mshows thatthe heart ofthe circuit isa PLL syn-thesizer mod-ule keeping aVCO (volt-
age-controlledoscillator) in check. The
VCO output signal is amplified andfed to the generator output as well tothe synthesizer input and the input ofthe attenuator. The PLL obtains digitalinformation on the target VCO fre-quency from a microprocessor module.The micro also takes care of the front-panel mounted user interface, whichconsists of 3 switches, a rotary encoderand an LCD (liquid-crystal display). Italso controls the amount of attenuationat the generator output, across a rangeof –1 dB through –79 dB. An optionalserial interface is available to enable theRF Signal Generator to be linked to aPC using an RS232 cable. Functionally,the instrument is completed by aninternal power supply.
P L L B O A R DThe circuit diagram of this first moduleto be discussed in detail is shown inFigure 2. It comprises three sub-cir-cuits: VCO, synthesizer and outputbuffer. The VCO and the synthesizertogether from the PLL.
VCO and buffersThe active element in the oscillator is adifferential amplifier built around tran-sistors T1, T2 and T3, whose gain
depends on the currentpassed by T3. The actualresonating element inthe oscillator is an L-Cparallel tuned circuitconnected to the inputof the difference amplifier. The LC net-work consists of inductors L1-L5 incombination with variable-capacitancediodes (varicaps) D9 and D10. Theother input of the oscillator isgrounded for RF by capacitor C10.Depending on the desired frequencyrange, one or more inductors areswitched into the oscillator. This isdone by pulling the non-commonedterminals to RF ground using +5Vcontrol voltages on PIN diodes D2, D4,D6 and D8. In the highest frequencyrange, all inductors are effectively con-nected in parallel. This is necessary tomake sure that the non-selected induc-tors and their parasitic capacitance cannot form a series tuned circuit thatwould prevent the oscillator fromoperating at the desired frequency. Allinductors are off-the-shelf miniaturechokes. The frequency range switchingtakes place at 1.024 MHz, 2.304 MHz,5.376 MHz and 13.056 MHz.
Capacitor C8 provides the neces-sary amount of positive feedback in theoscillator. An AF signal may be appliedto the emitter of T4 to effect amplitudemodulation (AM). Frequency modula-tion (FM) is also possible by superim-posing an AF signal onto the varicaptuning voltage. Although FM willcause the PLL to drop out of lock, theaverage frequency remains constantbecause the time constant of the con-
trol loop is not capableof tracking the ‘insta-bility’ caused by themodulation signal.
To make sure it isnot too heavily loaded,
the oscillator signal is first buffered by aFET (field-effect transistor), T4. Nextcomes the real amplifier, IC1, a typeNE592 which some of you may knowfrom baseband-video amplifiers insatellite-TV receivers. The amplifier isbiased at half the supply voltage byopamp IC3b, and its gain is defined byseries network R26-L8. Because of theinductor action, the gain decreases athigher frequencies. Because the VCOstrives to maintain a stable outputlevel, less gain on the NE592 automat-ically more gain in the differential oscil-lator. This purposely-created effect isessential for reliable starting of theoscillator at higher frequencies.
The NE592 being a differentialamplifier, it has two inputs, but alsooutputs. Both are used here. The signalat the first output (pin 7) is applied toemitter follower T5 which supplies theactual generator output signal at animpedance of 50 Ω (the standard in RFtest equipment). The other output sig-nal supplied by the NE592 is used todrive two sub-circuits. One branchgoes to the PLL chip via C23 and R33,the other is used to drive a voltage rec-tifier/doubler, D11-D12 which in turndrives amplitude-control opamp IC3a.The desired highest output amplitudemay be set using preset P1. The authorused a setting where 0 dBm (decibel-
11Elektor Electronics 11/98
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
VCO
PLL
PSU
Interface
PC
30V
12V
5V
mains
keysF
Attenuator0 ... - 79 dB
LCD
980053 - 11
0.5 ... 30 MHz
Figure 1. Block dia-gram of the RF SignalGenerator. All intelli-gence is vested in amicrocontroller.
1
B2
R1
D1
1N4148 D2
BA243
C2
33n
L2
100µH
B3
R3
D3
1N4148 D4
BA243
C3
33n
L3
22µH
B4
R5
D5
1N4148 D6
BA243
C4
33n
L4
3µH9
B5
R7
D7
1N4148 D8
BA243
C5
33n
L5
0µH56
C8
330p
C9
330p
C13
100n
C10
33n
C15
27p
R13 R14 R15 R16 R19
R20 R21
R25
R24
R27
R29
R28
R31
R11
R17
R34
T1
BF494
T2
R41
T3
BF494
C40
100n
C12
10µ63V
C14
180p
T4
BF256B
C16
330p
L6
39µH
L7
39µH
R22
10k
R23
10k
C17
33n
L8
3µH3
R26
C214n7
R30
T5
2N5179
C22
33n
R32
47Ω
C11
68p
C19
100n
C20
47µ16V
C18
10µ16V
OUT
D10
BB130D9
R2
390Ω
R4
390Ω
R6
390Ω
R8
390Ω
2x
R10
330kR9
C6
2n2
FM
L1
330µH
C1
33n
R12
10k
C7
220n
AM
R18
100k
R37
10k
R36
10k
R35
R33
2
3
1IC3a 2k2
P1
C28
2µ216V
C26
2µ2 16V
C25
2n2
C24
330p
D12AA13
D11
AA113
6
5
7IC3b
C23
330p
R40
1kC
B
A
NE592
IC1
G2B G2A
G1B G1A
14
10
11
12
I2
I1
Q2
Q1
1
8
7
3
54
C30
2n2
C31
10n
C29
10n
C37
330n
C39
100nC36
1µ
C35
100nR39
18k
R38
R42
C34
100µ 10V
C38
10µ63V
LOCK
C33
40p
X1
4MHz
2x
A A
B B
C
D
E
F
G
H
I
J
J
K
(N14)
L
L
M
N
+30V
30V
+12V
12V
+5V
5VDLEN
SDA
SCL
U TUNING = 0 ... 30V
LOCK
PLL
8
4
IC3
IC3 = LM358P
12V U+
U+
5V
C32
47µ16V
A 11V9
B
C
D
E
F
10V2
0V
9V5
0V02
0V86
G
H
I
J
K
L
M
N3V5
4V2
0V35
5V9
5V1
K
9V
2V5
1V95980053 - 12
30V
C27
100n
SAA1057IC2
XTAL
TEST
AMIN
DLENFMIN
OUTSDA
SCL
DCSDCA
TCA TCB
IN
15
17
18
11
12
14
13
10
TR
16
CC
5
6
41 2 3
1
9
2 3
7
V
8
2
D1
1N4148
C1
100n
R3
6Ω81
R4
39Ω2
RE1
R1 R2 R5 R6
D2
1N4148
C2
100n
R9
368Ω
R10
12Ω1
RE2
R7 R8 R11 R12
D3
1N4148
C3
100n
R15
3k65
R16
24Ω3
RE3
R13 R14 R17 R18
D4
1N4148
C4
100n
R21
909Ω
R22
56Ω2
RE4
R19 R20 R23 R24
D5
1N4148
C5
100n
R27
3k92
R28
162Ω
RE5
R25 R26 R29 R30
D6
1N4148
C6
100n
R33
3k92
R34
162Ω
RE6
R31 R32 R35 R36
D7
1N4148
C7
100n
R39
3k92
R40
162Ω
RE7
R37 R38 R41 R42
D8
1N4148
C8
100n
R45
3k92
R46
162Ω
RE8
R43 R44 R47 R48
A1– 1dB
A2 A3 A4– 2dB – 4dB – 8dB
A5 A6 A7 A8– 16dB – 16dB – 16dB – 16dB
980053 - 13RE1 ... RE8 = V23042-A1001-B101
3
milliwatt) into 50 equals 0.63 Vp p a tthe generator output.
S y n t h e s i z e rThe circuit of the synthesizer largelyfollows the Application Note for theS AA1057 as supplied by Philips Semi-conductors. Some component values
in the control loop had to be modified alittle to optimise the behaviour of thePLL. The ‘LOCK’ output is only pro-vided for test purposes. The SAA 1 0 5 7receives its control information in I2Cf o rmat via its SDA, SCL and DLENinputs. These lines are connected to am i c r o c o n t r o l l e r. Basically, the SAA 1 0 5 7compares the frequency of the VCOwith that of a reference signal derivedfrom the ex t e rnal 4-MHz quartz cry s-tal. For this purpose the VCO signal isi n t e rnally divided by a factor deter-mined by the microprocessor. The fre-quency difference produces an err o rsignal which is converted into a corr e-
sponding varicap control voltage. Thiscontrol voltage is integrated by R40-C37 and has a range of 0-30 V. Remark-a b l y, the SAA1057 does not require anex t e rnal level converter for the varicapcontrol voltage — a special amplifier isincluded on the chip for this purpose,as well as a direct connection for +30 V( p i n7 ) .
Trimmer C33 allows the generatoroutput frequency to be calibratedagainst a frequency standard.
The VCO/PLL board requires threesupply voltages: +5 V for the synthe-s i z e r, +12 V for the VCO, and +30 Vfor the varicap voltage.
Figure 2. Circuit diagram ofthe VCO/PLL board. The heartof the PLL is an I2C-controlledsynthesizer chip typeSAA1057.
C1
1µ 16V
R1
K1P1
10k
R5 8x 10k 1
23456789
C5
100n
R2 R3 R4
R28
1k
PSEN
ALE
R29
3k3
T12
R26
1k
R27
3k3
T11
R24
1k
R25
3k3
T10
R22
1k
R23
3k3
T9
R12
1k
R13
3k3
T4
R10
1k
R11
3k3
T3
R8
1k
R9
3k3
T2
R6
1k
R7
3k3
T1
R20
1k
R21
3k3
T8
R18
1k
R19
3k3
T7
R16
1k
R17
3k3
T6
R14
1k
R15
3k3
T5
X1
11.059 MHz
C2
33p
C3
33p
C4
100n
S1S2S3
T0
MAX232
R1OUT
R2OUT
RS1OUT
RS2OUT
IC2
T1IN
T2IN
RS1IN
RS2IN
C1–
C1+
C2+
C2–
11
12
10
13
14
15
16V+
V-
7
8 9
3
1
4
5
2
6
C9
C10
C6
C7
C8
K2
1
2
3
4
5
6
7
8
9
S4
ENCODER
A1
A2
A3
A4
A5
A6
A7
A8
C
B
A
P2.4
EA/VP
ALE/P
RESET
89C51
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
PSEN
INT0
INT1
IC1
TXD
RXD
39
38
37
36
35
34
33
32
21
22
23
24
25
26
27
28
31
19
X1
18
X2
20
40
17 RD16 WR
29
30
11
1012
13
14T015T1
1
2
3
4
5
6
7
8
9
B5
B4
B3
B2
DGCLK
DGDIR
C12
100n
C11
220µ16V
5V
T1 ... T8 = BC557B
C6 ... C10 = 10µ / 63V
OUT
IN
RS232
RES
5V 5V 5V
LOCK
980053 - 14
+5V
RS
R/W
EN
DB4
DB5
DB6
DB7
5V
5V
5V
T9 ... T12 = BC557B
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
5V
TxD
RxD
SDA
SCL
DLEN
Figure 4. Circuit diagram ofthe controller board. An 89C51sits between a number ofinput and output devices.
4
Figure 3. Circuit diagram ofthe digitally controlled attenu-ator. Range is –1 dB to –79 dBin 1-dB steps.
A T T E N U A T O R B O A R DFigure 3 shows the circuit diagram of adigitally controlled 8-section pi RFattenuator with a range of –1 dB to–79 dB in 1-dB steps. The resistor com-binations we need to realize each ofthe 79 discrete attenuation levels areconnected into the circuit by means ofrelay contacts. The associated relays areactuated and de-actuated by micro-processor drive signals that form 8-bitcombinations at the control inputsmarked A1-A8.
The theoretical values of the resis-tors in the attenuator are realized bymeans of parallel combinations of 1%resistors from the E96 series.
Each relay coil is shunted by a back-emf suppressor diode and a decou-pling capacitor.
M I C R O C O N T R O L L E RB O A R DAll the intelligence we need to imple-ment a man/machine interface, i.e.,establish communication between theuser on the one hand, and the PLL andthe attenuator on the other, is packedin a microcontroller type 89C51. Thiscontroller executes a program written
by the author and burned into theinternal program memory by the Pub-lishers. The 89C51 is available ready-programmed from the Publishers orcertain kit suppliers advertising in thismagazine.
The 89C51 accepts information andsupplies information. Microcontrollerfreaks call this ‘I/O’ for input/output.Well, the input devices are a rotaryshaft encoder, S4, which is used for thefrequency setting, a small keyboard,S1-S2-S3, the SDA line of the I2C busand (optionally) the RxD line of theMAX232 serial interface. The outputdevices to control are the LCD con-nected to port P0, the attenuator onport P1), the VCO inductors on portline P2.0 through P2.3 and, of course,the synthesizer chip, by way of theDDA and SCL lines (P2.6 and P2.7).Actually, the I2C bus is modified into aso-called CBUS by the addition of P2.5(DLEN) and its pull-up resistor, R2.
The 89C51 is clocked at11.0592 MHz by an external quartzcrystal, X1. This frequency was chosenbecause it allows standard baud ratesto be used on the serial interface.
A classic power-on reset network,R1-C1, completes the microcontrollercircuit.
This board requires only +5 V to
operate, the MAX232 having on-chipstep-up converters for +10 V and–10 V.
P O W E R S U P P L Y B O A R DAs you can see from the circuit dia-gram in Figure 5, the power supply forthe RF signal generator is entirely con-ventional.
The 30-V varicap supply is based ona simple combination of a zener diodeand a series transistor. Current drainon the 30-V rail will be very small, soextensive regulation is not necessary.None the less, a fair number of decou-pling capacitors is used to keep the var-icap voltage as clean as possible. Afterall, all hum, noise etc. on this rail willcause frequency modulation on theoutput signal. The input voltage for the30-V regulator is supplied by a voltagedoubler, C10-D5-D5.
The 5-V and 12-V supplies are basedon two old faithfuls, the 7805 and theLM317 respectively. These ICs andtheir usual ‘satellite’ components havebeen used so many times in our pub-lished circuits that no further descrip-tion will be necessary.
A single mains transformer rated at15 V, 8VA, supplies all the necessaryalternating voltages. The mains voltageat the primary side is applied via adouble-pole switch and a fuse, bothbuilt into a Euro-style appliance socket.
N E X T M O N T HIn next month’s second and conclud-ing instalment we will be discussingthe construction of the instrument onfour printed circuit boards. The articlewill be concluded with notes on theoperation of the RF Signal Generator,miscellaneous matters and optionalextras.
(980053-1)
15Elektor Electronics 11/98
D3
D1
D2
D4
15V
TR1
8VA
C3
C4
C2
C1
7812
IC1
IC2
LM317T
C5
1000µ 35V
C7
2µ2 16V
C9
2µ216V
C13
10µ 63V
C12
1µ63V
C11
220µ63V
C10
470µ63V
K1K2
C6
220n
D5
C8
220n
R1
22
Ω
5W
R2
27
0Ω
R3
82
0Ω
D6
1N4001
R4
1k
D7
33V
400mW
R5
10
k
D8T1
BC141+30V
+12V
+5V
30V
12V
5V
2x
63mA T
980053 - 15
D1 ... D4 = 4x 1N4001C1 ... C4 = 4x 47n
Figure 5. Circuit dia-gram of the powersupply. Three voltagesfrom one transformer!
5
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
Elektor Electronics 11/98
T H E C O M M A N D SThe commands sent to the PLC87(A) by the PC may bedivided into a number of groups. The Datasheets in this mag-azine list the English versions of the commands, togetherwith their parameters, if applicable, and short descriptions.The Datasheets may be used as Quick Reference Cards for thePLC87(A) system.
Bit combinationsare the result of combining two bit-parameters.
A z x.y ANDAN z x.y AND NOT (NAND)O z x.y ORON z x.y OR NOT (NOR)
The BCR (bit combination result) is the result of these logicoperations. Valid parameters in position z are I, Q, F, T, C and(, while x represents the number of the byte, and y the num-ber of the bit.
AllocationsThese are used to allocate a certain bit parameter to the BCR.
S z x.y set when BCR =1 R z x.y reset when BCR = 1= z x.y equals (equals BCR)
Valid parameters are Q, F and C, while x represents the num-ber of the byte, and y the number of the bit.
Timer functionsThe timers T n (0-15) count down a previously loaded value.Various options are available. If the value becomes 0, interro-gating the BCR will produce a ‘1’. Before the start command,
The PLC87(A) is programmed using Simatic compatible command lists(CLs). A CL consists of a sequence of logic combinations and/or instruc-
tions for the PLC to execute. In this second and last instalment we lookat the way command lists are written, and also explain the operation of
some of the more important instructions.
18
Design by R. Geugelin
versatile controlsystem PLC87(A)part 2: command list (CL)
programming
The ports of the microcontroller on the PLC87(A) board aredivided in inputs and outputs which form the links betweenthe PLC and the ‘real world’. The CL program, which isstored in an EEPROM, interrogates these inputs, andarranges for outputs to be set (actuated). Additionally, thePLC87(A) is capable of using flags (markers), software timers,flashers and counters. When the PLC is initialised or stopped,all outputs, flags, etc., are reset to zero.
A CL line consists of an operator and a parameter, or acommand and a variable. Comment may be appended, or ajump label may appear ahead of operators or commands.After the program start, the CL interpreter, which is stored inthe controller ROM, first reads the inputs, and stores a copyof the bit-image in a register (PAE). Next, the interpreter startsto execute the CL from the top line down to the bottom.While the processor executes the CL, it does not read theinputs, but their bit image. Likewise, the output states are firstcopied into a register (PAA), and not written into the respec-tive ports until the PE command (program end) is encoun-tered in the CL.
The CL interpreter reads a program line and executes itimmediately. The results of the various logic combinationsand the instructions are copied to internal registers (BCR,ACCU1, ACCU2, PAE, PAA), and may be called up for pro-cessing later. When the PE command is encountered, theinterpreter returns to the start of the CL. This results in adelayed response to events (cycle time). Although the valuesof inputs and outputs are updated during every cycle, theirstatus is not modified.
MICROPROCESSORS
the timer value has to be loaded by means of L KT x.y (x=0-255, y=1, 2, 3)
SD T n start T n, on-delayedSF T n start T n, off-delayedSP T n start T n, as pulseSE T n start T n, as extended pulse
Counter functionsEach counter C n (0-7) has a count range of 0 through 255,and is capable of counting up or down. The counter valuemay be cleared, set and interrogated. A bit interrogation thenproduces a zero when the counter value is greater than 1.
CU C n C n counts up on positive edge of BCRCD C n C n counts down on positive edge of
BCRR C n set counter to 0 when BCR=1S C n counter value to ACCU1 when BCR=1L C n load counter value into ACCU1A C n BCR=1 when counter value > 0
Byte combinationsThese serve to perform bit-by-bit combinations of the con-tents of ACCU1 and ACCU2. The result of the byte-combina-tion is left behind in ACCU1.
AB AND byteXB Exclusive-OR byteOB OR byte
Comparison commandsThese allow you to compare the contents of ACCU1 andACCU2.
!=B compare for: equal>B compare for: greater than=B compare for: greater than or equal
With cyclic refresh, every PRT command should be precededby a POS command, if the same position is desired. If displaycommands are used without an LCD module connected, thePLC87(A) is likely to ‘crash’.
PollingThe polling register, PR, writes values in the Polling Data Stor-age (PDS), which is basically a cyclic memory with a capac-ity of 512 bytes in EEPROM. Using the command TRG thevalue stored in the PR is written to the PDS at the end of thecycle, whereupon the next cell in the PDS is prepared forbeing written to. These are the relevant commands:
L IB 1 load input byte 1T PR into polling registerA I 0.1 when I 0.1 = 1TRG PR to PDS, one line on
For example, the PDS may capture certain events or statesoccurring as the program is being executed, and so enable theresults to be read or processed at a later time. Once thePLC87(A) board is up and running, the PDS entry starts againat the first line. Only one value may be written into the PDSfor every program cycle.
F O R E X A M P L E …Under this sub-heading and helped by examples we willintroduce CL programming. The PLC87(A) controls relays(via driver stages) which capture input states (via optocou-plers) in a system using 24-V direct voltages.
Assignment: an immersion pump which is driven via output0.4, should work when a switch at location ‘A’ or ‘B’ isswitched on (High). It should stop pumping when the mini-mum water intake level (‘dry’) is reached.
:O I 0.1 switch A is on input 0.1:O I 0.2 switch B is on input 0.2:AN I 0.6 float switch at I 0.6 reports water:= Q 0.4 output 0.4 switches on pump:PE end of program
Assignment: a garage door is to be closed by a motor when apushbutton is actuated, but only if there is no obstacle. Whenthe end position is reached, or an obstruction is encountered,the motor should be switched off.
:A I 0.1 motor-on pushbutton connected toinput 0.1
:A I 0.2 light barrier at input 0.2 reportsall clear
:S Q 0.4 set output 0.4 (motor on)::ON I 0.2 switch at I 0.2 reports occupied
(negative interrogation):ON I 0.4 switch end position reached at I 0.4
(opener):R Q 0.4 reset output (motor off)::PE
Assignment: a horn should sound at a rate of 1 Hz when themotor powering a press is operating. Motor activity shouldalso be indicated by a lamp. The motor runs when pushbut-tons 1 and 2 are pressed simultaneously.
:O I 0.1 pushbutton 1:O I 0.3 pushbutton 2:= M 0.1 motor-on flag:
:A F 0.1 motor-on flag:= Q 0.4 motor output:= Q 0.5 lamp output:A F 0.1 motor-on flagA S 1.4 flash rate:= Q 0.6 horn-on output::PE
Assignment: when a switch labelled ‘OPEN’ is pressed, avalve should open after four seconds. After switching off, thevalve should remain open for 20 seconds.
A I 0.1 switch, valve open:L KT 40.1 load time constant 40x0.1s:SD T 1 start timer 1, on- delayed::A I 0.1 switch, valve open:L KT 20.2 load time constant 20x0.1s:SF T 2 start timer 2, off-delayed:A T 2 when timer 2 reports 1:AN I 0.1 and the valve was switched off
already:O T 1 or the on-delay has elapsed:= Q 0.4 then actuate valve:PE
Assignment: Pulses applied to input 0.0 are to be countedand shown on a two-digit 7-segment display via output byte0. Because the display is a common-anode type, the drive sig-nals have to be inverted. When the counter value exceeds 99,or input 0.1 is actuated, the counter value is cleared.
:A I 0.0 count pulses:CU C 1 on positive edge of BCR::L KB 99 load constant 99:L C 1 compare with counter 1:
:L KB 160: 130°C, switch off heater:L KB 180:>B:R Q 0.0:POS 64 cursor in 2nd display line::L FB 1 when temp. 0 (whencount > 0 thenBCR=1)
The highest count rate depends onthe program cycle time.
FlasherThe system has available a flasher, S1.4 (see bit parameters), which oper-ates at a rate of 1 Hz. Its state may beinterrogated by means of a logic com-bination.
JumpsWhen the CL interpreter encounters ajump command, program executioncontinues at the CL line before thejump label, provided the jump condi-tion is fulfilled. There are two types ofjump:
JU unconditional jump to labelJC conditional jump if BCR=1
The label is entered in the right-handcolumn of the CL, and is defined by a‘#’ followed by four characters.
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
PLC87(A) vs. Simatic-S5As already mentioned, the instructionset of the PLC87(A) is based on thatof a Siemens Simatic-S5 system, It isnot fully compatible with the S5!Because the PLC87(A) has accumu-lators with a width of just 8 bits, andno modules, a number of commandshave been simplified to some extent.The essential differences with the S5instruction set are:
1. comparisons use ...B instead of ...F;2. shift operations use SLB, SRB
instead of SLW, SRW;3. different method of indirect
addressing;4. program end has to be marked with
PE;5. subroutines are placed at the end
of the main program, they are calledwith UPA, UPC and closed off withRET;
6. BE is used to separate the mainprogram from subroutines;
7. analogue inputs may be readdirectly
8. as opposed to a Simatic system, thePLC87(A) recognises commandsfor LCD control and for the pollingregister (PR).
The bulk of the commands is howeveridentical, and that should enable youto teach yourself PLC programmingusing any of the vast number ofcourses and manuals covering theSimatic S5 standard.When using jumps and subroutinecalls, you should make sure that thejump label occurs only once in theprogram. The CL may contain up to64 labels, no matter if simple jumplabels or subroutine labels. Further-more, subroutines may only beginafter a BE command.
Programming errorsThe following errors typically causethe PLC87(A) system to crash. Recov-ering from a system crash is only pos-sible by removing the EEPROM andinserting it again.JU, JC used to branch to subroutinelabel1. UPA, UPC used to branch to jump
label;2. Multiple use of flags3. Failure to use RET to close off sub-
routine;4. Subroutine before a BE;5. No BE before program end and the
first subroutine;6. Jumps from one subroutine into
another;7. Nesting of subroutines;8. Too many opening brackets;9. Failure to complement opening
bracket with closing bracket.
SafetyAccording to various standards forindustrial safety, errors in automated
71W,Trov777TITT
equipment may not cause a risk to theintrinsic safety of persons, machinesor goods. Equipment parts relevant toany aspect of intrinsic safety shouldbe implemented in hardware (i.e., tra-ditional circuit technology like relaysand protective devices). An 'emer-gency -off' switch has to be imple-mented in hardware. With system reli-ability in mind, limit switches and otheractuators should be connected to thePLC87(A) in the same way as to itshardware equivalent. For example, the`off' switch of a motor has to be wiredand programmed as a normally -closed contact:
AN I 0.3 switch: motor -off
R Q 0.5 stop motor
Temperature measurementThe ADJ command is available fortemperature measurement using theAD22100K sensor from AnalogDevices (see Datasheets, October1998 issue). A temperature range of-50 °C to +150 °C then correspondsto an output voltage of 0.25 V to4.75 V The contents of ACCU1 isautomatically adjusted to give '0' at atemperature of -50 °C, '50' at 0 °C,and '200' at the maximum tempera-ture, 150 °C.The command TMP causes the mea-sured temperature to be shown on theLC display at the cursor position, orthe position set up by the POS com-mand.
00.
of
PRI ,-I I '1*1
SubroutinesWhen the CL interpreter encounters asubroutine call, the program is con-tinued at the CL line before the sub-routine label, provided the call condi-tion is fulfilled. There are two types ofsubroutine call:
UPA unconditional call
UPC conditional call (SCR=1)
The subroutine should be closed offwith an RET command to enable theinterpreter to continue executing theCL at the line following the subroutinecall. A BE command must be insertedbetween the main program and thefirst subroutine.Subroutines may be called as often asyou like. They may not, however, benested or call themselves.
TimersThe PLC87(A) command interpreteroffers 16 timers (0-15), each having4 user -selectable functions.
SD
SF
SP
SE
start with on -delay
start with off -delay
start as pulse
start as extended pulse
Before a timer may be started, a timeconstant has to be loaded into theACCU. The value should be in therange 1-255 (in ACCU1), while thetimebase goes to ACCU2 and takes avalue of 1, 2 or 3 for 0.1 s, 1 s or 10 srespectively, in the format XXX.Y
Elektor Electronics 11/98 2323Elektor Electronics 11/98
PLC87(A) vs. Simatic-S5As already mentioned, the instructionset of the PLC87(A) is based on thatof a Siemens Simatic–S5 system, It isnot fully compatible with the S5!Because the PLC87(A) has accumu-lators with a width of just 8 bits, andno modules, a number of commandshave been simplified to some extent.The essential differences with the S5instruction set are:
1. comparisons use ...B instead of ...F;2. shift operations use SLB, SRB
instead of SLW, SRW;3. different method of indirect
addressing;4. program end has to be marked with
PE;5. subroutines are placed at the end
of the main program, they are calledwith UPA, UPC and closed off withRET;
6. BE is used to separate the mainprogram from subroutines;
7. analogue inputs may be readdirectly
8. as opposed to a Simatic system, thePLC87(A) recognises commandsfor LCD control and for the pollingregister (PR).
The bulk of the commands is howeveridentical, and that should enable youto teach yourself PLC programmingusing any of the vast number ofcourses and manuals covering theSimatic S5 standard.When using jumps and subroutinecalls, you should make sure that thejump label occurs only once in theprogram. The CL may contain up to64 labels, no matter if simple jumplabels or subroutine labels. Further-more, subroutines may only beginafter a BE command.
Programming errorsThe following errors typically causethe PLC87(A) system to crash. Recov-ering from a system crash is only pos-sible by removing the EEPROM andinserting it again.JU, JC used to branch to subroutinelabel1. UPA, UPC used to branch to jump
label;2. Multiple use of flags3. Failure to use RET to close off sub-
routine;4. Subroutine before a BE;5. No BE before program end and the
first subroutine;6. Jumps from one subroutine into
another;7. Nesting of subroutines;8. Too many opening brackets;9. Failure to complement opening
bracket with closing bracket.
SafetyAccording to various standards forindustrial safety, errors in automated
equipment may not cause a risk to theintrinsic safety of persons, machinesor goods. Equipment parts relevant toany aspect of intrinsic safety shouldbe implemented in hardware (i.e., tra-ditional circuit technology like relaysand protective devices). An ‘emer-gency-off’ switch has to be imple-mented in hardware. With system reli-ability in mind, limit switches and otheractuators should be connected to thePLC87(A) in the same way as to itshardware equivalent. For example, the‘off’ switch of a motor has to be wiredand programmed as a normally-closed contact:
AN I 0.3 switch: motor-offR Q 0.5 stop motor
Temperature measurementThe ADJ command is available fortemperature measurement using theAD22100K sensor from AnalogDevices (see Datasheets, October1998 issue). A temperature range of–50 °C to +150 °C then correspondsto an output voltage of 0.25 V to4.75 V. The contents of ACCU1 isautomatically adjusted to give ‘0’ at atemperature of –50 °C, ‘50’ at 0 °C,and ‘200’ at the maximum tempera-ture, 150 °C.The command TMP causes the mea-sured temperature to be shown on theLC display at the cursor position, orthe position set up by the POS com-mand.
SubroutinesWhen the CL interpreter encounters asubroutine call, the program is con-tinued at the CL line before the sub-routine label, provided the call condi-tion is fulfilled. There are two types ofsubroutine call:
UPA unconditional callUPC conditional call (BCR=1)
The subroutine should be closed offwith an RET command to enable theinterpreter to continue executing theCL at the line following the subroutinecall. A BE command must be insertedbetween the main program and thefirst subroutine.Subroutines may be called as often asyou like. They may not, however, benested or call themselves.
TimersThe PLC87(A) command interpreteroffers 16 timers (0-15), each having4 user-selectable functions.
SD start with on-delaySF start with off-delaySP start as pulseSE start as extended pulse
Before a timer may be started, a timeconstant has to be loaded into theACCU. The value should be in therange 1-255 (in ACCU1), while thetimebase goes to ACCU2 and takes avalue of 1, 2 or 3 for 0.1 s, 1 s or 10 srespectively, in the format XXX.Y
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
GENERAL INTEREST
Smartcard-operatedcode lock
give expired Smartcards a second life
Reading smartcardsand writing to them,
that's all very well, butbuilding real -life appli-
cation circuits, that'seven better! Among
the countless circuitsthat can be labelled`electronic locks' anobvious, preferred,position is held by
systems employing`smartcards'.
Design by Patrick Gueulle
This type of application is particularlywell suited to programming into amicrocontroller with on -board EEP-ROM (electrically erasable program-mable read-only memory) such as thePIC16C84, even if you content yourselfwith the limited possibilities of a sim-ple programming language like BASIC.
LEARN -AS -YOUPROGRAMThe essential point of a Smartcard-con-trolled lock is simply the sheer infinitenumber of possible codes.
A simple (expired) payphone orloyalty card, for example, is identifiedby a unique 'reference number' whichis easy to read into a memory butalmost impossible to modify.
Such a 96 -bit identifier word allowsnearly 80 trillion (million million mil-lion) different card numbers to beissued.
To exploit this almost inexhaustiblestock of 'keys' represented by dispos-able chipcards, it is sufficient to designa reader unit capable of memorisingthe 'images' (electronic contents) ofone or (better) several expired smart -cards, and then preferably cards you
actually want to re -use.Having passed this 'learning' phase,
the card reader may well control, say, arelay if and only if you insert one of thesmartcards the reader has been'trained' to recognize as far as the elec-tronic content is concerned.
Alternatively, you may want to con-sider 'personalizing' certain cards hav-ing one and the same 'ID', and origi-nally intended for applications notrelated to telephones, for example,GSMs, car -wash cards (Mobil and BP),parking cards, loyalty cards, satellite -TVcards, etc. An expired car -wash cardoriginally worth 24 units, for example,still contains 136 bits reading '0', whichare easily and individually set to '1'with the aid of a chipcard reader/pro-grammer like the one described in Elek-tor Electronics September 1997.
Although the most obvious choice isto use expired smartcards, an alterna-tive is to order new (blank) cards in anyquantity you want, from suppliers likeElea (France, type number ELEA100),or Crownhill Associates in the UK (seetheir advertisement elsewhere in thismagazine).
As far as the author has been able to
24 Elektor Electronics 11/98Elektor Electronics 11/98
This type of application is particularlywell suited to programming into amicrocontroller with on-board EEP-ROM (electrically erasable program-mable read-only memory) such as thePIC16C84, even if you content yourselfwith the limited possibilities of a sim-ple programming language like BASIC.
L E A R N - A S - Y O UP R O G R A MThe essential point of a Smartcard-con-trolled lock is simply the sheer infinitenumber of possible codes.
A simple (expired) payphone orloyalty card, for example, is identifiedby a unique ‘reference number’ whichis easy to read into a memory butalmost impossible to modify.
Such a 96-bit identifier word allowsnearly 80 trillion (million million mil-lion) different card numbers to beissued.
To exploit this almost inexhaustiblestock of ‘keys’ represented by dispos-able chipcards, it is sufficient to designa reader unit capable of memorisingthe ‘images’ (electronic contents) ofone or (better) several expired smart-cards, and then preferably cards you
actually want to re-use.Having passed this ‘learning’ phase,
the card reader may well control, say, arelay if and only if you insert one of thesmartcards the reader has been‘trained’ to recognize as far as the elec-tronic content is concerned.
Alternatively, you may want to con-sider ‘personalizing’ certain cards hav-ing one and the same ‘ID’, and origi-nally intended for applications notrelated to telephones, for example,GSMs, car-wash cards (Mobil and BP),parking cards, loyalty cards, satellite-TVcards, etc. An expired car-wash cardoriginally worth 24 units, for example,still contains 136 bits reading ‘0’, whichare easily and individually set to ‘1’with the aid of a chipcard reader/pro-grammer like the one described in Elek-tor Electronics September 1997.
Although the most obvious choice isto use expired smartcards, an alterna-tive is to order new (blank) cards in anyquantity you want, from suppliers likeElea (France, type number ELEA100),or Crownhill Associates in the UK (seetheir advertisement elsewhere in thismagazine).
As far as the author has been able to
Reading smartcardsand writing to them,
that’s all very well, butbuilding real-life appli-
cation circuits, that’seven better! Among
the countless circuitsthat can be labelled‘electronic locks’ anobvious, preferred,position is held by
systems employing‘smartcards’.
24
Design by Patrick Gueulle
Smartcard-operatedcode lock
give expired Smartcards a second life
GENERAL INTEREST
find out, these 256-bitcards are not reallyblank, though, becausethey contain a ‘lot’number in the memory are reservedfor the first 96 bits. The next 160 bitsare, however, at logic 0, and may befreely changed to logic 1s.
Depending on the application(s)you have in mind, the electronic lockwill either recognize one or two cardsthat can not be forged, or, by contrast,any number of identical cards that may,under certain conditions, be duplicated.
A P I C 1 6 C 8 4P R O G R A M M E D I NB A S I C !The simplicity of the circuit diagramshown in Figure 1 may come as a sur-prise given the relative complexity ofthe functions it is designed to carryout.
Actually, that is because the micro-controller used, a PIC16C84, containsalmost everything we need; to beginwith, a data EEPROM with a size of
64 bytes.This non-volatile memory is capa-
ble of recording two ‘card images’ of256 bits each. These images may qui-etly remain in the PIC EEPROM formore than ten years, or be modified asmany times as you like.
Because the circuit does not con-sume any significant current unless acard is inserted into the connector, itmay operate from a simple 9-volt bat-tery, although there is, of course, noobjection against powering it from amains adaptor or a rechargeable bat-tery (for example, that of an alarm sys-tem).
Whatever power source is used, atype 78L05 voltage regulator is used tosupply the PIC with its 5-volt supply
25Elektor Electronics 11/98
PIC16
IC2OSC1
MCLR
OSC2
RA4
RA1
RA0
RA2
RA3
RB0
RB1
RB2
RB3
RB4
RB5
RB6
RB7
F84
18
17
13
12
11
10
16
14
15
1
3
9
8
7
6
2
4
5
R5
3k
9
C5
27p
R3
5k
6
JP2
1/2
R4
5k
6JP1
LEARN
R1
5k
6
R2
3k9
T1
BC547
D2
1N4148
RE1
K2C2
100n
R9
1kD3
V+5V
1
2
3
4
5
6
7
8
9
10
K3
R6
3k
9
K1
D1
1N4001
C1
47µ63V
R10
22Ω
V+
T2
BC557
R8
10
k
R11
22Ω
C3
10µ63V
C4
10µ63V
78L05
IC1
R7
47
Ω
C6
220n
5V
17184 8765123
K4
CHIPCARD
1
2
3
4
5
6
7
8
9
10K5
RFU
'
I/O'
+5V
'
GN
D'
+5V
'
RS
T'
CLK
'
RFU
'
RFU
'
RFU
'
CLK
'
RS
T'
+5V
'
GN
D'
+5V
'
I/O'
RFU
'
RS
T'
CLK
'
+5V
'
GN
D'
+5V
'
I/O'
980061-11
+R
FU
RS
T
CLK
I/O
48 7 6 5 1 2 3
*
see text*siehe Text*voir texte*zie tekst*
0
Figure 1. The circuit of the electroniccode lock consists essentially of a PICmicrocontroller, a Smartcard reader anda handful of other components.
‘DUAL smart card lock with PIC16F84‘copyright (c) 1998 Patrick GUEULLEsymbol f = B0symbol g = B1symbol e = B2symbol r = B3symbol BLINK = B4symbol h = B5DIRS = %11100110PINS = %00000010high 7high 6low 6low 7high 6low 6high 5if PIN3 = 0 then learnif PIN3 = 1 then check
learn:for f = 0 to 31e = 0for g = 0 to 7e = e * 2e = e + PIN4high 6low 6next gh = 32 * PIN0h = h + fwrite h,enext fPINS = 0BLINK = 50goto led
check:for f = 0 to 31e = 0for g = 0 to 7e = e * 2e = e + PIN4high 6low 6next gread f,rif e r then othergoto cont
other:h = f + 32read h,rif e r then error
cont:next fPINS = %00000110goto forever
error:PINS = 0BLINK = 255goto led
led:for f = 0 to 10high 1pause BLINKlow 1pause BLINKnext f
forever:goto forever
Figure 2. Listing of the program, before compilation, to be stored in the PIC.
1
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
voltage, while a transistor allows therelay coil to operate at a sufficientlyhigh coil voltage.
It will be clear at this point that thewonderful simplicity of the circuit isdue to an invisible program executedby the PIC microcontroller.
It may come as surprise to you thatthe control program was written inBASIC, or PBASIC to be precise, a‘dialect’ originally developed by Paral-lax Inc. for its BASIC Stamp modules.
Although it would be easy to down-load the program shown in Figure 2into a BASIC Stamp 1 wired up to aSmartcard reader unit, we could notresist the temptation of an alternativesolution which looks poised to becomea buzz-word: compiling.
Several PBASIC compilers for thePIC microcontroller are available fromreputed companies like Forest Elec-tronic Developments and Micro Engi-neering Labs, but they may also befound in the public domain.
Whereas the most efficient of thesecompilers produce object code whichis competitive to what can be producedwith an assembler program, the sim-plest of them are no more than ‘inter-preters’.
That is not to say that the term
‘interpreter ’ is inappropriate herebecause the BASIC program is actuallystored in memory in the form of‘tokens’ (a couple of bytes per instruc-tion), which a resident piece of soft-ware starts to ‘interpret’ one by one.However, this process is usually called‘tokenising’ instead of ‘interpreting’.
The compiler we employed for thepresent project at the same time loadsthis ‘firmware’ and the ‘tokenised’BASIC into an ordinary PIC16F84 ofwhich about three quarters of the avail-able program memory is occupied.
By contrast, the BASIC Stamp 1comes with its interpreter mask-pro-grammed into the (read-protected)EPROM on board an OTP (one-timeprogrammable) PIC16C56, while theBASIC ‘tokens’ are stored in a separateEEPROM type 93LC56.
Whatever method is used, 256 bytesare available for the application pro-gram. Strange as it may sound, that isboth a lot and very little to go on,mainly, because the tokenised BASIC isvery compact.
For sure, the approach using the
BASIC Stamp is the most practical dur-ing the development phase. On theother hand, the use of empty PICs anda compiler is cheaper once the systemsoftware and hardware have passedthe debugging phase.
The fact that a compiler could beused which is compatible both with theBASIC Stamp and the PIC16F84 was agreat help when it came to writing ourprogram, particularly at the level ofaccessing the EEPROM, a functionwhich is a bit difficult to implement inassembly language.
It is universally acknowledged thatmost ‘interpreted’ BASIC runs at snail’space. Here, however, that turned out tobe an advantage because delay loopsare then not required!
The PIC is clocked at about 2 MHzby a simple RC network, and requiresless than a second to read 256 bytesfrom any synchronous chipcard usingthe German or French protocols fordata/command exchange.
A reset facility is provided to makethe circuit compatible with payphonecards from almost any country.
26 Elektor Electronics 11/98
980061-1(C) ELEKTOR
C1
C2
C3
C4
C5
C6
D1
D2
D3
G1 G2
G3G4 G5
G6 G7
G8
IC1
IC2
JP1
JP2
K1
K2
K3
K4
K5
R1
R2
R3
R4
R5
R6R7
R8
R9
R10
R11
RE1
T1
T2
X
X
X
X
X
X
+0
learn
1/2
980061-1
980061-1(C) ELEKTOR
Figure 3. PCB design for the Smartcard controlledelectronics lock. The board consists of two sec-tions that have to be separated with a saw.
3
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor uk
PRACTICALREALISATIONIf you construct an electronic codelock, based on whatever circuit princi-ples, you should observe a minimumnumber of elementary security mea-sures.
It would have been (too) easy tothrow all components that make upthe circuit on the same board as theinevitable chipcard connector, and pre-scribe the use of SMA (surface -mountassembly) components to keep the sizeof the board within reason.
We know several examples of 'pro-fessional' equipment from reputablemanufacturers, having the above -men-tioned deplorable and over -simplisticconstruction.
In a number of cases, it was suffi-cient to remove just two screws to getaccess to two wires which, when short-circuited, open the locks...
The printed circuit board of whichthe design (artwork) is shown in Fig-ure 3 has been designed to facilitate fit-ting the electronics in a safe place, thatis, inside a building or room to be pro-tected (for example, on the inside of adoor).
The only part which is accessiblefrom the outside is the card connector,
whose ISO and AFNOR contacts maybe wired in parallel if you want the sys-tem to be able to process both cardtypes (the AFNOR pin arrangement isnow obsolete even in France).
(Dotted) components R8/T2 are pro-vided to allow card connectors witheither a normally -open (NO) or nor-mally -closed (NC) contact to be used.
In the first case, you do not fitR8/T2, and install a short wire linkingthe base and collector pads reservedfor this transistor. This link is shown asa dotted line. If, on the other hand, youhave an NC -style connector available,you have to install these two parts, andno wire link.
As illustrated in Figure 3, a 10 -wayflatcable is used to connect the cardreader to the circuit. This cable is fittedwith an IDC (insulation displacementconnector) socket to be plugged on tothe 10 -way pinheader on the PCB.
Considering the (purposely -reduced) speed of the signalsexchanged with the Smartcard(approx. 500 Hz), cable lengths of up to50 cm may be used without problems.
A robust 4 -way PCB mount termi-nal block allows the dc power supply(9 to 15 volts) to be connected to theboard (K1), as well as the load to be
switched on and off by the relay con-tact (K2). This contact is only closedwhen the 'right' card is detected in thecard reader.
The LED has to be mounted so thatit is only visible when the system isbeing set up, because its very functionis to inform you of the correct execu-tion of each of the steps in the process.
Two jumpers, finally, allow you toselect between the two availablemodes of operation: 'learn' or 'normal'use (1 / 2). It is not necessary or evendesirable (for obvious reasons) to pro-vide access to these jumpers for anypurpose other than the process of'teaching' the system to recognize newcards.
The programmed PIC for this pro-ject is available through our ReadersServices under order code 986511-1. Itshould not be installed in its socketbefore you have checked your con-struction and verified the presence ofthe correct voltages at several points inthe circuit.
PRACTICAL USEEasy to build, the electronic code lockis even easier to use.
As a matter of course, you shouldstart by 'teaching' the PIC to recognize
COMPONENTS LIST
Resistors:R1,R3,R4 = 5kQ6R2,R5,R6 = 3kQ9R7 = 47QR8 = 10kQR9 = 1kQR10,R11 = 22Q
Capacitors:C1 = 47,uF 63V radialC2 = 100nFC3,C4 = 10,uF 63V radialC5 = 27pF
C6 = 220nF
Semiconductors:D1 = 1N4001D2 = 1N4148D3 = LED, red, 3mm, low -currentT1 = BC547T2 = BC557IC1 = 78L05IC2 = PIC16F84-04P (pre-programmed,order code 9865111-1, see ReadersServices page)
Miscellaneous:K1,K2 = 2 -way PCB terminal block,
pitch 5mmRe1 = 12V PCB mount relay, e.g,
Siemens V23037 -A0002 -A101 (Elec-tro Value)
JP1,JP2 = 2 -pin header with jumperK3,K5 = 1 -way pinheaderK4 = smartcard reader, e.g. Canon
CCM02 2N0 21 93 20.10 -way flatcable (max. 50cm)2 10 -way IDC socketsPrinted circuit board, order code
980061-1 (see Readers Servicespage).
Elektor Electronics 11/98 27
P R A C T I C A LR E A L I S A T I O NIf you construct an electronic codelock, based on whatever circuit princi-ples, you should observe a minimumnumber of elementary security mea-sures.
It would have been (too) easy tothrow all components that make upthe circuit on the same board as theinevitable chipcard connector, and pre-scribe the use of SMA (surface-mountassembly) components to keep the sizeof the board within reason.
We know several examples of ‘pro-fessional’ equipment from reputablemanufacturers, having the above-men-tioned deplorable and over-simplisticconstruction.
In a number of cases, it was suffi-cient to remove just two screws to getaccess to two wires which, when short-circuited, open the locks…
The printed circuit board of whichthe design (artwork) is shown in Fig-ure 3 has been designed to facilitate fit-ting the electronics in a safe place, thatis, inside a building or room to be pro-tected (for example, on the inside of adoor).
The only part which is accessiblefrom the outside is the card connector,
whose ISO and AFNOR contacts maybe wired in parallel if you want the sys-tem to be able to process both cardtypes (the AFNOR pin arrangement isnow obsolete even in France).
(Dotted) components R8/T2 are pro-vided to allow card connectors witheither a normally-open (NO) or nor-mally-closed (NC) contact to be used.
In the first case, you do not fitR8/T2, and install a short wire linkingthe base and collector pads reservedfor this transistor. This link is shown asa dotted line. If, on the other hand, youhave an NC-style connector available,you have to install these two parts, andno wire link.
As illustrated in Figure 3, a 10-wayflatcable is used to connect the cardreader to the circuit. This cable is fittedwith an IDC (insulation displacementconnector) socket to be plugged on tothe 10-way pinheader on the PCB.
Considering the (purposely-reduced) speed of the signalsexchanged with the Smartcard(approx. 500 Hz), cable lengths of up to50 cm may be used without problems.
A robust 4-way PCB mount termi-nal block allows the dc power supply(9 to 15 volts) to be connected to theboard (K1), as well as the load to be
switched on and off by the relay con-tact (K2). This contact is only closedwhen the ‘right’ card is detected in thecard reader.
The LED has to be mounted so thatit is only visible when the system isbeing set up, because its very functionis to inform you of the correct execu-tion of each of the steps in the process.
Two jumpers, finally, allow you toselect between the two availablemodes of operation: ‘learn’ or ‘normal’use (1 / 2). It is not necessary or evendesirable (for obvious reasons) to pro-vide access to these jumpers for anypurpose other than the process of‘teaching’ the system to recognize newcards.
The programmed PIC for this pro-ject is available through our ReadersServices under order code 986511-1. Itshould not be installed in its socketbefore you have checked your con-struction and verified the presence ofthe correct voltages at several points inthe circuit.
P R A C T I C A L U S EEasy to build, the electronic code lockis even easier to use.
As a matter of course, you shouldstart by ‘teaching’ the PIC to recognize
27Elektor Electronics 11/98
COMPONENTS LIST
Resistors:R1,R3,R4 = 5kΩ6R2,R5,R6 = 3kΩ9R7 = 47ΩR8 = 10kΩR9 = 1kΩR10,R11 = 22Ω
Capacitors:C1 = 47µF 63V radialC2 = 100nFC3,C4 = 10µF 63V radialC5 = 27pF
C6 = 220nF
Semiconductors:D1 = 1N4001D2 = 1N4148D3 = LED, red, 3mm, low-currentT1 = BC547T2 = BC557IC1 = 78L05IC2 = PIC16F84-04P (pre-programmed,
order code 9865111-1, see ReadersServices page)
Miscellaneous:K1,K2 = 2-way PCB terminal block,
pitch 5mmRe1 = 12V PCB mount relay, e.g,
Siemens V23037-A0002-A101 (Elec-troValue)
JP1,JP2 = 2-pin header with jumperK3,K5 = 1-way pinheaderK4 = smartcard reader, e.g. Canon
CCM02 2NO 21 93 20.10-way flatcable (max. 50cm)2 10-way IDC socketsPrinted circuit board, order code
980061-1 (see Readers Servicespage).
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
29Elektor Electronics 11/98
a certain Smartcard. To do so, install JP1to select ‘LEARN’ mode. That effectivelypulls the RB3 port line of the PIC (pin 9)to ground. Next, insert the Smartcard orpayphone card into the reader.
The LED should light up, indicatingthat the circuit is being powered. Afterabout one second the LED should startto flash rapidly. This ‘eye-winking’indicates that the card image (elec-tronic contents) has been transferred toEEPROM, and that it remains thereuntil another card is inserted, even ifyou turn off the power supply andleave it off for months.
Having supplied this signal, theLED indicator goes out, and you cansafely withdraw the card, which fromthen on is promoted to ‘master key’.
Now remove the ‘LEARN’ jumperand insert your Smartcard again. TheLED indicator should light, and therelay should be energised the next sec-ond or so. It remains energised and theLED remains on, as long as the card isin the connector.
Remove the card and try another.Unless this one has exactly the samecontents as the ‘master key’, the LEDshould flash slowly, and then go out.Of course, the relay should not beenergised!
The above process may be repeatedafter changing the jumper in position‘1 / 2’, which enables the electronic lockto be ‘taught’ to recognize a secondcard.
In case you want the lock to recog-nize just one card, you have to presentit to the system for both positions ofthe ‘1 / 2’ jumper. This is done to avoidthe system security being weakened byleaving one half of the EEPROM in anundefined state.
E N C O D E Y O U R O W NC A R D S E R I E SAlthough the ability of the system torecognize two different Smartcards willbe sufficient for many applications,there will be cases in which manymore users need to be authorized toopen one and the same door or lock(as, for instance, in a laboratory withcontrolled access, a club or a block ofapartments).
You then turn to cards whose con-tents was originally the same, withinthe same series, and you complete theencoding by a couple of freely chosenbits.
As an example, let’s use car-wash
cards sold in France by BP or Mobilpetrol stations. Once expired thesecards are thrown away by the tens ofthousands by their users.
A Smartcard worth 24 units (cred-its), all used up, contains the following256 bits:
1000 1000 1000 0000 0010 0000 0000 00100011 1100 0111 0101 1000 0010 0010 01001010 0001 0000 0000 0000 0000 0000 00010000 0000 0011 1111 1111 1111 1111 11111100 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 0000
In the first three lines we find the nameof the card manufacturer, which cannot be modified. The name string isidentical on all 24-unit cards issued upto now, but different from the one on12-unit cards, which, fortunately, areequally easy to obtain (in France).
Next come 10 bits all reading ‘0’, fol-lowed by 24 ‘1’s (these are the used-upcredit units), and then 126 ‘0’s whichare not used by the application.
If you make the mistake of ‘teach-ing’ the electronic lock to recognizesuch a card, then the door can beopened by anyone having an expiredcar-wash card originally worth24 credit units!
The obvious thing to do is of courseto ‘personalise’ the card and so limitthe number of authorized cards inaccordance with the number of people(card users) who are authorized toopen the lock. Cards may be ‘person-alised’ quite easily using the softwareutility ‘ELEKT1G’ and the associatedSmartcard Reader/Writer, both asdescribed in the September 1997 issueof Elektor Electronics.The following example goes to showhow to change any number of the 136‘0’s on the card into logic ‘1’, simply bypressing the ‘+’ key on the PC key-board when the cursor is on top of thedesired bit, after the card data havebeen read.
Space bar: read next bit(auto-repeat)
+ key: write 1 (at current location)
ESCape key: quit
1000 1000 1000 0000 0010 0000 0000 00100011 1100 0111 0101 1000 0010 0010 01001010 0001 0000 0000 0000 0000 0000 0001
0011 0000 0011 1111 1111 1111 1111 11111100 0000 0000 0000 0000 0000 0000 00000000 0000 1010 0000 0000 0000 0000 00000000 0000 0101 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 0000
WARNING: Switch the Vpp off!
For the other authorized cards you fol-low exactly the same procedure, andyou use on of these cards to ‘teach’ theelectronic lock the code by which thedoor is opened.
The same procedure may beapplied with ‘blank’ (new) cards, pro-vided they are of the GPM256 type orsimilar (256 bits of EEPROM) — askyour supplier.
Whether the card is new or expired,only the first 96 bits have already beenpersonalised (by the manufacturer),the remaining 160 being at 0 and freelyprogrammable by yourself.
Here is an example of what may befound on a card picked from an actualbatch:
0000 0000 1000 0000 0000 0000 0000 00000100 1011 0000 0000 0000 0000 0000 00001111 1111 1111 0000 0000 1111 1111 11110000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 0000
The buyer of a batch of these cards istotally free to employ ELEKT1G towrite logic 1’s into any location(s) inthe last five lines, as illustrated below:
0000 0000 1000 0000 0000 0000 0000 00000100 1011 0000 0000 0000 0000 0000 00001111 1111 1111 0000 0000 1111 1111 11111111 1111 0000 0000 0000 0000 0000 00010000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 1100 0011 0000 0000 00001000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 1110 0010
WARNING: Switch the Vpp off!
Of course, you have to be aware of thefact that such a card may be copied,but only on to a card with the same 96-bit manufacturer-ID, which means thatit has to be from the same batch boughtfrom the same manufacturer. That seri-ously limits the possibilities of cardsbeing forged!
(980061-1)
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
PC control forMiniDisc player
beam up track titles from your PC
Sure, it did take sometime, but it is fair to
say that Sony's Mini -Disc has finally
achieved marketacceptance. The cir-cuit presented in this
article enables a Mini -Disc deck to be con-trolled in a comfort-
able way when itcomes to entering
track titles. By using aPC and some cleverelectronics, you canput track titles onto
your shiny little discs.
Design by P Glatzel
SpecificationsFor use with Sony MD decks types MDS-JE500 and laterTransmitter range: several metresUp to 99 track titlesUp to 2032 characters per MDSuitable for any PC with a free RS232 portStandard 9 -pin RS232 connectionNo special software requiredMay be combined with a track -title databaseEnergy -saving designPowered by one 9-V battery
MiniDisc (MD) audio systems are soldby the hundreds of thousands everyyear in various countries in which thisElektor Electronics is published. After aslow start, the MD system appears to
have made it to general recognitionand commercial success after a numberof years. Not surprisingly, several read-ers (mostly proud owners of MDdecks) wrote to us with the request to
430 Elektor Electronics 11/98Elektor Electronics 11/98
MiniDisc (MD) audio systems are soldby the hundreds of thousands everyyear in various countries in which thisElektor Electronics is published. After aslow start, the MD system appears to
have made it to general recognitionand commercial success after a numberof years. Not surprisingly, several read-ers (mostly proud owners of MDdecks) wrote to us with the request to
Sure, it did take sometime, but it is fair to
say that Sony’s Mini-Disc has finally
achieved marketacceptance. The cir-cuit presented in this
article enables a Mini-Disc deck to be con-trolled in a comfort-
able way when itcomes to entering
track titles. By using aPC and some cleverelectronics, you canput track titles onto
your shiny little discs.
30
Design by P. Glatzel
PC control forMiniDisc player
beam up track titles from your PC
Specificationsë For use with Sony MD decks types MDS-JE500 and laterë Transmitter range: several metresë Up to 99 track titlesë Up to 2032 characters per MDë Suitable for any PC with a free RS232 portë Standard 9-pin RS232 connectionë No special software requiredë May be combined with a track-title databaseë Energy-saving designë Powered by one 9-V battery
COMPUTERS
give some attention to the MiniDiscsystem. One frequently heard short-coming of the MD system, we learned,is that entering a track title list is cum-bersome. Although every MiniDischas sufficient capacity for 256 tracksrepresenting a total of 1,700 text char-acters, the process of actually enteringthe texts you want is very userunfriendly: lots of cursor and letterkeys have to be pressed on the com-pact remote control before any mean-ingful text appears on the display. Thistext function is of special interest tomusic collectors. Tracks on old records(LPs), for example, can be efficientlyfiled together with the name of thealbum, the release number, name ofthe artist(s), etc. In most cases, theavailable space of 1,700 characters willbe more than sufficient. A fine system,really, if only the process of enteringtexts was a little less awkward.
In this day and age, with he prolif-eration of PCs, it must be possible tosimplify the process of conveying atrack title to a MiniDisc deck, and,from there on, to the little disc itself.The designer of the present circuitfully agrees with this opinion, and setout to combine the functionality of a
PC with the power of a small micro-controller. This has become possibleever since Sony, from their modelMDS-JE500, started to incorporate soft-ware in their MD decks that allowstexts to be read by an infra-red receiverand then copied on to a MiniDisc. ThePC control for MiniDisk players dis-cussed in this article forms the linkbetween a text file (document) writtenon your PC, and the infra-red ‘eye’ onthe MD player. The system allows anyPC to ‘beam’ up to 99 track titles to theMD deck, which writes them to aMiniDisc. If you are not sure if a par-ticular MD deck will be compatiblewith the present circuit, ask the sup-plier if it is suitable for use with theadvanced MD Title Generator sup-plied by Sony. If it is, then the presentcircuit can be used also.
T H E C I R C U I T I ND E T A I LThe circuit diagram of the MD control isshown in Figure 1. The input is formedby connector K1, a 9-way serial port.The output is formed by an infra-redsender diode, D3. IC4, aMAX232, converts thesignals on the serial
port from TTL to RS232 levels, and theother way around. The electrolyticcapacitors around IC4 help the internalcircuits in the MAX232 to adapt thevarious voltage levels. In this way, theinternal charge pump enables a sym-metrical voltage to be derived from adirect voltage of +5 V.
Although the circuit only uses theTxD, RxD and CTS signals on theRS232 port, these are sufficient for reli-able data exchange between the MDcontrol and the PC. The three logic sig-nals appear at TTL level on three pinsof the microcontroller (P3.0, P3.1 andP3.2) type AT89C2051 from Atmel.
The controller is an 8-bit machinewhose instruction set is compatiblewith Intel’s MCS-51 instruction set. Ithas 128 bytes of RAM and 2 Kbytes ofFlash memory.
The circuit around the controllerincludes a standard crystal oscillatoroperating at 11.0592 MHz.
The line marked ‘ACTIVE’ (P3.5)plays an important role because it isused to implement software control ofthe power supply. You actuate the cir-
cuit by pressing switchS1. The base of transis-tor T2 is then pulled to
31Elektor Electronics 11/98
24C16
IC3SDASCL
A0
A1
A0
WC
1
5
8
4
6
2
3
7
C15
100n
C5
100n
C14
22p
C13
22p
C12
100n
C17
470p
C18
470p
C19
470p
C2
100n
C3
100n
C11
1µ 63V
C16
100µ25V
C1
100µ 25V
C4
10µ63V
C8
C9
R3
10
k
R4
10
k
R7
3Ω
3
R8
10
Ω
R6
3k
3
R21
33
0k
R2
47
k
R13
33
k
R14
22
k
X1
11.0592 MHz
R11
68
0Ω
R12
68
0Ω
D6D5
T1
BC638 D3
R5
68
0Ω
R17
10
k
C6
C7
C10
K1
1
2
3
4
5
6
7
8
9
R19
1k8
R20
1k8
R18
1k8
MAX232
R1OUT
R2OUT
T1OUT
T2OUT
IC4
T1IN
T2IN
R1IN
R2IN
C1–
C1+
C2+
C2–
11
12
10
13
14
15
16V+
V-
7
89
3
1
4
5
2
6
D11N4001
D4
1N4148
D21N4001
78L05
IC1T2BC638
R22
2k
2
R23
4k
7
T3
BC
R24
4k7
R15
51
k
R16
22
k
S1
K2
547R1
10
0k
AT89C2051
IC2
20
10
19
13
14
15
18
17
16
11
12
XX
54
1
2
3
6
7
89
5V
5V
5V
5V5V
C6 ... C10 = 10µ / 63V
UIN
ON
ACTIVE
980092 - 11
1
Figure 1. Circuit dia-gram of the MD titlegenerator: simplicityis trumps!
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
ground via resistor R22, whereuponthe power supply is activated. Themicrocontroller then receives its sup-ply voltage, and is initialised. Upondetecting that the ON line is active, thecontroller pulls the ‘ACTIVE’ line logichigh, causing transistor T3 to beswitched on. As a result, the powersupply remains switched on even ifyou release S1. If the circuit has beeninactive for some time, the microcon-troller makes the ‘ACTIVE’ line lowagain and so causes the whole circuitto be switched off. In this way, the bat-tery life is considerably extended.There is another benefit, namely thatyou can switch off the circuit by hold-ing S1 depressed for about 2 seconds.
Incidentally, the circuit will onlyrespond to this command if no com-munication activity is detected on theRS232 port.
Although it may appear rather com-plex at first blush, the power supply isof a straightforward design. TransistorT2 is the actual on/off switch whichconveys the applied direct voltage toIC1, at the command of S1 or T3. Theoutput of IC1 supplies a stable directvoltage of 5 V. Diode D1 protects thecircuit against accidental supply rever-sals. Although a 9-V battery is the pre-ferred power source, the circuit mayalso be powered by an inexpensivemains adaptor having an output volt-age between 9 V and 12 V.
Via its input pins 12 and 13, themicrocontroller continuously monitorsthe levels of the stabilised and non-sta-bilised voltages. Actually, the voltagesat these pins are scaled-down versionsof the full supply levels.
Two of the microcontroller’s outputlines are used to control LEDs D5 andD6. As soon as an output drops low,the associated LED lights up. Further,two port lines are in use to implementthe communication with the EEPROM.Both lines (pins 16 and 17) simulate anI2C bus, and are connected to the +5-V rail via a pull-up resistor. The EEP-ROM, a type 24C16, is used to bufferthe text which is eventually stored onthe MiniDisc. After all, the whole point
32 Elektor Electronics 11/98
(C) ELEKTOR980092-1
9VC1
C2
C3
C4
C5 C6
C7
C8
C9
C10
C11 C12
C13
C14
C15
C16
C17 C18
C19
D1
D2
D3
D4
D5 D6
IC1
IC2
IC3
IC4
K1
R1
R2
R3
R4
R5
R6
R7
R8
R11
R12
R13
R14
R15
R16
R17
R18
R19
R20
R21
R22
R23
R24S1
T1T2
T3
X1
-+
980092-1
(C) ELEKTOR980092-1
2
COMPONENTS LIST
Resistors:R1 = 100kΩR2 = 47kΩR3,R4,R17 = 10kΩR5,R11,R12 = 680ΩR6 = 3kΩ3R7 = 3Ω3R8 = 10ΩR13 = 33kΩR14,R16 = 22kΩR15 = 51kΩR18,R19,R20 = 1kΩ8R21 = 330kΩR22 = 2kΩ2R23,R24 = 4kΩ7
Capacitors:C1,C16 = 100µF 25V radialC2,C3,C5,C12,C15 = 100nF ceramicC4,C6-C10 = 10µF 63V radialC11 = 1µF 63V radialC13,C14 = 22pFC17,C18,C19 = 470pF
Semiconductors:D1,D2 = 1N4001D5 = red led 3mmD6 = yellow led 3mmD7 = IR-LED e.g. LD271 (LD274)D8 = 1N4148T1,T2 = BC638T3 = BC547IC1 = 78L05
IC2 = AT89C2051-PC, order code986516-1
IC3 = 24C16IC4 = MAX232
Miscellaneous:K1 = 9-pin sub-D socket (female), PCB
mountS1 = push-button D6-C-90 cap BTN-
D6-90 (90=black; 40=red) ITC(Eurodis)
X1 = 11.0592MHzCase: Heddic type 222PCB, order code 980092-1PCB and programmed microcontroller
(set), order code 980092-C.
Figure 2. The single-sided printed circuitboard was designed tofit in a Heddic case.
Visit our Web site at http://ourworld.compuserve.com/homepages/elektor_uk
Figure 3. The MD title gen-erator makes enteringtrack titles into an MDdeck much easier thanwith the remote control!
of the circuit is to beable to 'beam' data fromthe PC to the MiniDisc player.
The transmitting of data is accom-plished by the transmitter stage builtaround transistor T1 and IR senderdiode D3. This stage effectively con-verts pulses received from the micro -controller into infra -red light signalsthe MD is capable of detecting.
CONSTRUCTION:SIMPLE AND COMPACTA circuit like this simply demands acompact construction, and we believewe have been successful in this respect.As you can see from the photographsin this article, the size of our prototypemay be compared to that of a regularremote control. The PCB has beendesigned such that a standard casefrom Heddic is easily adapted for aperfect fit. The board, the battery, thesender diode, the control push-button,the serial connection and the two LEDsform a compact unit.
The copper track layout and com-ponent overlay of the circuit board maybe found in Figure 2. The board is sin-gle -sided, contains one wire link, andaccommodates all components. Beforeyou start soldering, it is useful to firstdetermine the exact locations of theholes for K1 and Si. The actual solder-ing work, we reckon, is not likely tocause problems. Once the circuit is fullybuilt up, it may be fitted into the enclo-
Al sure, and the bat-tery may be con-
nected. The unit is then ready for use.
ENTER THE PCAs already mentioned, the present con-trol allows comfortable programmingof track titles on a MiniDisc. In princi-ple, there are two ways of storing yourdata in the EEPROM. Using a simpleterminal program which may be foundon almost any PC, laptop PC, organiseror, indeed, any other computer system,it is possible to 'get in touch' with thecircuit. In all cases, select the followingserial port settings:
Baudrate:No. of bits:Parity:Stop bits:Handshaking:
96008
none1
hardware
After switching on the circuit (press thepush-button briefly) the red LED lightsup, and the circuit identifies itself byproducing this message on the PCscreen:
MD programmer V1.1
Title input help for Sony MD -Players
By Peter Glatzel (February 98)
Copyright Elektor 1998-09-08
Equipment types JE500...JE700
If this message appears, the circuit and
the PC link are fully functional, and theMD control is waiting for a command.
In command input mode, the follow-ing commands are recognised:
d dump EEPROM contents to PC viaRS232 port
c clear EEPROM contentsm manual input modeel select character set of equipment
from MDS-JE seriese2 select character set of equipment
from SAJ series.
If you have an MD player from the SAJseries it is essential to be able to switchbetween the two equipment familiessupported by the control. In all othercases, the correct character set hasalready been selected for you.
To begin with, select 'm' via yourterminal. Next, enter the MD title andthe track titles:
00 MD title (CR+LF)
01 Title of track no. 1 (CR+LF)
99 Title of track no. 99 (CR+LF)
# End of input file
In this simple way, all data may beentered. Apart from letters and num-bers, the following characters are alsoacceptable:!$%&'()*+,-./:; = >?@_'The 'hash' character (#) at the end of
Elektor Electronics 11/98 33
of the circuit is to beable to ‘beam’ data fromthe PC to the MiniDisc player.
The transmitting of data is accom-plished by the transmitter stage builtaround transistor T1 and IR senderdiode D3. This stage effectively con-verts pulses received from the micro-controller into infra-red light signalsthe MD is capable of detecting.
C O N S T R U C T I O N :S I M P L E A N D C O M P A C TA circuit like this simply demands acompact construction, and we believewe have been successful in this respect.As you can see from the photographsin this article, the size of our prototypemay be compared to that of a regularremote control. The PCB has beendesigned such that a standard casefrom Heddic is easily adapted for aperfect fit. The board, the battery, thesender diode, the control push-button,the serial connection and the two LEDsform a compact unit.
The copper track layout and com-ponent overlay of the circuit board maybe found in Figure 2. The board is sin-gle-sided, contains one wire link, andaccommodates all components. Beforeyou start soldering, it is useful to firstdetermine the exact locations of theholes for K1 and S1.