70 January & February 2021 http://www.elektormagazine.com
cies there is no problem. Signals with less than three zero-crossings
during the sampling period are treated as DC.The second question is how many samples will be taken in these
35 ms. A sampling frequency of 10 kHz or higher would be ideal. I have
chosen for 357 samples at 10.2 ks/s. This leads to a integer multiple
of samples for 50 and 60 Hz signals. These frequencies can then be
analyzed with the highest accuracy.There is a library with I2C commands in mikroBasic, but these are only
for an I2C master. For an I2C-slave I had to write my own procedures.
These procedures are needed to setup and control the communi-
cation with the main board, the I2C master. The latter just requests
and displays information from the satellite boards, (auto-) ranging
and offset, all signal processing, including sampling and filtering is
performed on the satellite board(s).Unfortunately I forgot some decoupling capacitors in the supply part,
these had to be added too. The part list for this project in Open Office
format can be downloaded from [2]. Order codes for Farnell are given,
but of course you can choose any supplier.
Software for the satellite board
The program is written in mikroBasic for PIC (V5.6.1) from MikroElektronika,
a programming language that is relatively easy to understand.
I wanted that a frequency range from (a bit) less than 50 Hz to a few
hundreds of Hz could be processed. Therefore, the signal needed to
be sampled for at least 30 ms. Then, at 50 Hz there are at least three
zero-crossings, so you can detect one period. But that is only true when
these zero-crossings are equidistant. With a duty cycle unequal to 50 %
at 50 Hz, 30 ms is not sufficient, that’s why I have chosen for 35 ms.
Then with a duty-cycle of less than 25 % there it is possible that the
frequency is not correctly determined at 50 Hz, with higher frequen-
Mikroe-240SMTLCD1CS1CS2GNDVCC R/W RSTVEELED+LED-TP1TP2
TP3TP4VORS D010
D111
D212
D313
D414
D515
D616
D717181920Y1X1Y2
X212345678
E
9
PIC18(L)F46K22TQMCLRIC5RC6
RC5
RC3RD0RD3
RD1
RD2RD7
RD6
RD5RE2RB5RB6RC0RC1RC7RC4RB7RE1RC2RD4VDDVSSRB4RB0RB1RB2
RB3VDDVSSRA2
RA1RA4RA0RA7
RA5
RA3RA6RE01 54 0
4 1
3 9
3 81 61 74 3
3 74 41 83 62 63 54 23 22 71 4
1 0
1 172 92 1
2 02 31 93 0
2 4
2 23 12 55
4
3
262 818
9R40
39
R41
39
C23
100nC24
100n+5VJ 5J 4
R34
100
10kR35MAX1MAX2R38
10kR39
10kJ 6
J 8J10
J11J12100 R37R36 100JP11
23
45
6RD0RD1RD2
RD3RD4
RD5RD6
RD7RD0RD1RD2RD3RD4RD5RD6RD7R14
39
C 8
100n+5VR15
10kR 7
120
R11
120
R16
120
R18
120+12V-INT5
BC848CT4BC858
T6BC858
T7BC848C T8
BC848CR2110k
R2210kR23
10kR25
10k
R29
10kR19
1kR20
1kR17 39R26
100k
R30
100kR 7
1kJ 2J 3
C17
100n
C19
100n+5VJ 7J 9(^2) RT
(^1) DT
GD2^5
(^3) OC
(^4) SS
GND^6
VCC^7
IC1GD1^8
UCC25600
R 610k
R 81k5
C 5 100n
C 3 100n
R 2
39
+12V-IN
T1
SBSH105
D
G
T3
BSH105S
D
G
T2
BSH105S
D
G
R10
0
C 6
470p
R12 10
R 4
100
R13
10k
C 7
100n
D 2
R 9
10k
R 5
2k2
C 4
100n
D 1
D1, D2 = PMEG3020EH
R 3
2k2
R 1
39
C 1
(^1000) 16V
1 X1 2
3 4
5 6
1 X3 2
3 4
5 6
1 X4 2
3 4
5 6
C 9
1
C14 1
C18
1
J 1
+5V
L78M12CV
IC2
C10
100n
C11
330n
C12
330n
L1 150 H
L2 150 H
X2
SJ1
L78M05ACDT
IC3
C15
330n
C16
330n
R24
39
+5V
190133-011
C 2
100n
C13
100n +12V-IN
Figure 3: Satellite board schematics.