Practical_Electronics-May_2019

([email protected]) #1

base of Q1. The 470pF capacitor filters
any transients while diode D2 clamps
the base voltage at –0.7V for negative
excursions. Q1 inverts and amplifies
the signal, suitable for the capture
compare input (CCP1) at pin 6 of IC1.


Frequency measurement modes
When the micro is configured to gen-
erate frequencies for setting the up-
per and lower thresholds, the output
signal appears at pin 6 and TP3. For
this to work, there must be no input
signal at CON2 and this means that Q1
is biased off and it will not load the
output signal from pin 6.
20MHz crystal oscillator X1 is con-
nected to IC1, between its CLKO and
CLKI pins, to allow for accurate and
wide-ranging frequency measure-
ments. The MCLR reset input is tied
to the 5V supply via a 10kΩ resistor
to provide a power-on reset for the
microcontroller (IC1).
Internal pull-up currents within
IC1 hold the RB1 and RB2 inputs
high when switches S1 and S2 are
not pressed and similarly, are enabled
for the RB5 and RB6 inputs which
are connected to jumpers JP1 and
JP2. These inputs are pulled low if a
switch is pressed or jumper plug in-
serted, and this can be sensed by IC1.


Output pins RA0 (17), RB4 (10), RB7
(13) and RA1 (18) drive signal indica-
tors LED2-LED5 via 3.3kΩ current-
limiting resistors at around 1mA each.
Similarly, output RA4 (pin 3) drives
the threshold LED (LED6). The RB3
output (pin 9) switches transistor Q2
on when it goes high. This transistor
in turn switches on the relay. Diode
D3 quenches back-EMF from the coil
as Q2 is switched off.
LED7 is also switched on when the
relay is powered. It’s wired across the
relay coil and uses a 10kΩ series resis-
tor due to the higher voltage (11.4V). It
provides the same current to LED7 as
for the other LEDs.
Trimpots VR1 and VR2 set the default
hysteresis and delay time and both are
connected across the 5V supply, with
their wipers connected to analogue
inputs AN2 (pin 1) and AN3 (pin 2)
respectively. The voltages at these pins
are converted to digital values using
IC1’s inbuilt 10-bit analogue-to-digital
converter (ADC). The 100nF capaci-
tors between each of these two pins
and ground provide a low-impedance
source for the ADC during conversions.

Construction
The Deluxe Frequency Switch is
built on a double-sided PCB coded

05104181, available from the Practical
Electronics PCB Service. It measures
102 × 58.5mm and fits in a plastic util-
ity box measuring 129 × 68 × 43mm.
Follow the overlay diagram, Fig.3,
when installing the parts. Fit the resis-
tors first – we recommend you use a
digital multimeter (DMM) to check the
values before soldering them.
Diodes D1, D2, D3 and ZD1 are
next, and these need to be inserted
with the correct polarity, with the
striped end (cathode, k) oriented as
shown in the overlay diagram. Diode
D2 is the 1N4148 type while D1 and
D3 are 1N4004.
We recommend using an IC socket
for IC1. Take care with orientation
when installing the socket and when

Fig.2: the circuit is based around a PIC16F88-I/P, which measures the incoming frequency and energises the relay if
the frequency is above or below certain values and whether JP1 is present or not. It also has pre-settable response
times and hysteresis to prevent ‘chattering’. LEDs give you visual indication of the operation as well.

Deluxe frequency Switch


TP1 voltage Hysteresis
(adjusted when setting
with VR1) upper threshold
5V 50%
3.75V 43%
2.5V 33%
1.25V 20%
625mV 12%
312.5mV 6%

Table 1: Hysteresis setting versus
voltage at TP1.
Free download pdf