THE DIGITAL FREQUENCY COUNTER on the single-crystal microcontroller AT89c51

THE DIGITAL FREQUENCY COUNTER on the singlecrystal microcontroller AT89c51 Range of measurement of frequencies ...................... 1 Hz ... 1 GHz ...
Author: Cameron Harris
9 downloads 0 Views 263KB Size
THE DIGITAL FREQUENCY COUNTER on the singlecrystal microcontroller AT89c51 Range of measurement of frequencies ...................... 1 Hz ... 1 GHz A range of measurement of instability ........................ +/10 МHz Quantity of bits of the indicator (99.999.999) ............................ 8 A discretization of counting............................................... 1 Hz Time of measurement ....................................................... 1 sec Sensitivity ........................................................ 100 ... 200 mV This frequency counter was developed in far 1994. Though the subsequent years similar constructions have appeared many, in my opinion, and in XXI century the instrument is absolutely not obsolete, and on some parameters even exceeds later developments. After the publication I have received weight of responses among which practically there were no censures on quality of operation of the instrument and difficulty with adjustment. For the given frequency counter the program " the New Year's souvenir " which outputs on the indicator dynamical a picture is developed. So, among other things, it can decorate your radiolaboratory in "New year". Frivolously? But it is no secret, as the most perfect computers frequently are used only as toys. A principle of operation of the frequency counter – classical: measurement of quantity (amount) of impulses of an entry signal for the fixed time slice. Such interval selects 1 second that provides accuracy of counting  1 Hertz. It is quite enough of it for the majority of the purposes. Power supply 5v on all chips is brought to output with maximum number. Output incorporates to a common wire about twice smaller number. Between chains of power supply it is necessary to include 2. 3 bypass capacitors 0,01. 0,1Мк. Chain C4, R1 is necessary for reset at inclusion of the network. Now it is possible to gain the microcontroller with the built  in memory of 87C51 programs or AT89C51. Between Р0.0  Р0.7 and 5v it is desirable to include tightening resistors 10к though as practice has shown, the instrument is normal works and without them. The entrance signal through condenser C1 acts on base of transistor VT1 (look Frequency Prescaller schematics) which strengthens an entrance sig nal up to a level necessary for normal work of microcircuit D1. Microcircuit D1 MC12080 (look at Motorola datasheet) represents a highfrequency divider of frequency which factor of division is equal 10. In view of that in used

microcontroller AT89c51 the maximal frequency of accounting input (en trance) Т1 f=Fqz/24 where Fqz – frequency of used quartz, and in frequency meter Fqz=6,144 МГц, the signal from a highfrequency divider acts on the additional divider of frequency representing decimal counter D4. Lines dF and F (outputs 12 and 13 DD1) are connected to two buttons on closure without the fixing, installed on a front panel. The second contacts of these buttons are connected to a common wire. At shortterm pressing dF button the frequency counter passes in the mode of measurement of instabil ity of frequency. Thus on the indicator the difference between current value of frequency and that which was at the moment of transition in this mode is output. In high bit the sign of deviation of frequency is displayed, therefore the range of measurement of deviation is equal 10 MHz. At pressing F button the instrument comes back in the mode of measurement of frequency. This mode is installed and at powerup. The line 1/10 (output 14 DD1) is connected to free contact of the entry plug. She(it) is intended for convenience of operation at usage of an external MICROWAVE of a divider on 10. On an answer part of the plug the cross connection between this contact and the contact connected to a common wire is put. Thus, at connection of an external divider on 10, expanding a range of frequencies up to 1000 Мгц this line incorporates to a common wire. Thus layout of decimal points on the indicator in appropriate way varies. By opera tion without the MICROWAVE of a divider, i.e. at measurement of frequen cies up to 100 Мгц this contact should remain free. With an external MICRO WAVE a divider the price of rightmost  10 Hertz. For support of electromagnetic compatibility an initial winding of the transformer it is desirable to make the electrostatic screen from a copper foil. It is possible to connect to the frequency counter and LED indicators practi cally any type for which to the right of digit are a point. It is better, if color of a luminescence will be red as light emitting diodes of other color consume the greater current in 1,52 times. On circuit given connection of indicators with the common cathode below is shown, For connection of the indicator with the common anode  simply swap chips  registers. The important feature of the frequency counter is that in it is possible to use a quartz resonator on any frequency in a range 5. 12 Мгц. Optimal value 6. 8 Мгц, in my opinion, is.

10

9

8

7

6

5

4

3

1

Frequency Meter. MAIN MODULE

H

COAX PLUG

1

Freq OUT 1:1

1

3

GND F

3

1

COAXIAL CABLE

2

Freq IN

2

External (remote) sampler

G

R3 100E

GND

Control wire

1

Enable Devider 1:10

2

2

GND

3

3

Freq IN

4

4

VCC

X5.3

5

GND

X2.1

1

Frequency Prescaller Devider 1:10 Freq OUT / 10

COAX PLUG

1

D

G

X5.2

DF

X2.4

F

VCC

E

3

X2.3

3

1

X3.2

COAXIAL CABLE

X3.1

GND

GND Control wire

VCC

D

4

VCC

5

5 Volts Power supply

C

X2.2

F

3 2

Freq IN

1

H

X5.1

2 2

E

POWER SUPPLY

VCC

GND C

VCC 5V

1

B

2

12 V

9-12 V

GND

B

Title

A

BLOCK DIAGRAM

Size A

10

9

8

7

6

5

Document Number

Date:

4

Wednesday, March 27, 2002

3

Sheet

2

1

Rev 1.0 of

1

1

A

10

9

8

C2 0.01 uF

7

6

H C3 0.01 uF

C1 1500 pF

X1A

G

,1 * 1'

5

C4 1500 pF

R1 8.2K

R4 390E

R2 8.2K

C5 1500 pF

2 1 R3 8.2K

C5 1000 pF

E

2

1

H

D1 MC12080

1 8

R6 50E

R5 33E

IN1 IN2

C7 1000 pF

C6 33 pF

5 VD1 MBD101

3

C8 0.1 uF

VT1 BFR34A

F

4

Frequency Prescaller

VCC

2

SW1 SW2 SW3

3 6 7

OUT

4

G

C9 10 pF

GND

VD2 MBD101

9&&

6 5 4

,1 X5B

R7 820E

* 1'

F

E

Schematics of external (remote) sampler

Control wire

VT1 MOSFET N

1

3

1

1 COAXIAL CABLE

2

C1 0.15 uF

D

VT2 R3* 820K

R3 100E

3

9&&

6 5 4

,1

2

VD1 MBD101 C2 68 pF

BFX73 BFY78, 2SC390, 2N3600

X5B

D

* 1'

R1 20K

COAX PLUG

VD2 MBD101

R4 1.3M

R5 220E

R6 56E

C3 68 pF

C

C

5 Volts Power supply DA1

1

POWER C5

C4 "Power"

0.1uF

10uF

IN

B

7805

OUT

3

2

XA3

GND

B

VCC C7

C8

C10

C11

0.1uF

0.1uF

0.1uF

0.1uF

A

10

9

8

7

6

5

Title

Frequency Prescaller & Schematics of external (remote) sampler

Size A

Document Number

Date:

4

Wednesday, March 27, 2002

3

Rev 1.0 Sheet

2

1

of

1

1

A

5

4

3

2

1

VCC

R11 8.2K

*1'

C6 47uF

C8

C7 47uF

C9

R13 10K

C10 VT1 MM1748A

150pF

4700pF

VD2 1N3593

R14 33E

D1 C11 150pF In1

D2B

D2A

4

1

6 3

5

2

In1 In2 DF F DL In3

74AC132 D2C

74AC132 9

8 10 In2

74AC132

D3A 2

D

3 1 4

B

12

D

CLK

11

CLK

CLR PRE

13 10

Q Q

5 6

2

CLR

Q Q

10 11 12 13 14 15 16 17

P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD

30 29

ALE/PROG PSEN

3 4 5 6

CLK

12

CLR

A

   



5

P00 P01 P02 P03 P04 P05 P06 P07

3 4 7 8 13 14 17 18

D1 D2 D3 D4 D5 D6 D7 D8

1 2 3 4 5 6 7 8

P10 P11 P12 P13 P14 P15 P16 P17

VCC GND

11 1

LE OE

19 18

XL1 XL2

31 9

C1 24 pF QA QB QC QD

11 10 9 8

In3 R1 8.2K

XL2

VCC GND

11 1

LE OE

+ C4 10uF

C

R2 - R9 Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7

2 5 6 9 12 15 16 19

300E

300E

300E

300E

300E

300E

X4

8

74HC533 VCC P00 P01 P02 P03 P04 P05 P06 P07

A_F A_G A_E A_D A_C A_B A_A A_H

300E

300E

1 RN1 2 3 4 5 6 7 8 9 10K

9 8 7 6 5 4 3 2 1 С H A E D G B F

VCC

1 3 5 7 9 11 13 15 17 2 4 6 8 10 12 14 16

K_8 K_7 K_6 K_5 K_4 K_3 K_2 K_1 A_C A_H A_A A_E A_D A_G A_B A_F

B

A

Title

X3A VCC GND

4

D0 D1 D2 D3 D4 D5 D6 D7

RST

DF F DL GND

2 1

VCC RST

3 4 7 8 13 14 17 18

C3 10 pF

C2 4-15pF

K_1 K_2 K_3 K_4 K_5 K_6 K_7 K_8

2 5 6 9 12 15 16 19

74HC373 P10 P11 P12 P13 P14 P15 P16 P17

6MHz

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8

D6

XL1

74AC393

5 4 3 2 1

DF F 1/10 GND

XTAL1 XTAL2

P00 P01 P02 P03 P04 P05 P06 P07

ZQ1

CLR PRE

13

P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7

39 38 37 36 35 34 33 32

AT89C51

X2A

    

P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7

EA/VPP RST

9 8

D4B QA QB QC QD

74AC393

P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15

74AC74

D4A CLK

D5

21 22 23 24 25 26 27 28

D3B

74AC74

1

D

4700pF

VD1 1N3593

C

GND

3 x TOT3361AN

,1

R10 220E 3 2 1

+

X5A

+

9 && D

R12 390E Schematisc of 3xTOT3361AH-1N

C5 0.1uF

Size A 3

Date:

Frequency Meter up to 1 GHz (main module) Document Number Monday, March 25, 2002 2

Rev Sheet

1

1

of

2

Duration of an interval of measurement is determined by two constants  К1 and К2. The program is constructed in such a manner that admits multi ple correction of these values. For adjustment it is extremely desirable to have possibility to take advan tage of the factory checked up frequency counter. In the beginning it is nec essary to measure frequency of generation of quartz in the given circuit(scheme). For this purpose the exemplary frequency counter connect through the capacitor 23 pF to output 18 or 19 DD1 (C3  on the average position). As a last resort, at absence of the exemplary instrument, it is possi ble to accept for calculation value of frequency of generation of quartz from 1 kHz (for quartz 6 Mhz) up to 5 Khz (for quartz 12 MHz) above that on it is written. For example, for quartz 8 Mhz at calculation it is necessary to accept frequency of generation about 8002000 Hz. Then we are set by value К1 in limits from 8 up to 16 and it is calculated К2. К2 = 7 + 65536 * (K1) – f/12 , where f  frequency of used quatz, Hz. К2 can accept value from 0 up to 65535, and К1  from 1 up to 255. If K2 it turns out negative or more than 65535, we are set by other value K1 and we repeat calculation. And so until value K2 in limits from 0 up to 65535 will turn out. Obtained values K1 and K2 by rules of mathematics it is translated in the sexadecimal form. K2 it is necessary to approximate to the nearest odd value. Odd! In authoring variant for f=6144600 Hz К2 = 12245 = 2FD5H, К1=8. Con stant К1 is stored in cell 01B1H, high byte К2  in cell 01B2H, low byte К2  in 01B3H. Increase K2 on 1 will result in decrease of instrument readings on 1020 Hz for измеряемой frequencies about 10 MHz (or on 1  2 Hz for fre quency 1 MHz). After start and adjustment of the instrument it is necessary to measure fre quency of any generator and to compare indications to the exemplary frequency counter. This measurement should be carried out on frequency not less than 10 мгц. If not it will be possible to achieve identical indications rotation C3, it is necessary to correct values of constants К1 and К2. At usage of unitary pro grammed ROM it is necessary "to hammer" in cells 01B1H, 01B2H, 01B3H in zero, and values К1 and К2 to write, since cell 01B4H in the sequence which have been mentioned above. This operation can be spent multiply. The frequency counter can be used not only on direct assignment, but also as " the New Year's souvenir ". Rate of execution of the program " the New Year's souvenir " is determined by constant K3 stored(kept) in cell 045AH. It settles up under the empirical formula: K3 = 13,3 * F,

where F  frequency of used quatz, MHz Special here it is not required to accuracy, the calculated value should be approximated to an integer and to translate in the sexadecimal form. For ex ample, for F=12Mhz K3=0A0H, for 10Mhz  085H, and for 6,144Mhz  052H. In cells 045BH and 045CH for built  in ROM occurring "New year" is written in the binarydecimal form. The information in three listed cells can be ad justed, "hammering" in their zero and writing new values in subsequent. Only it is important to observe the order  K3, then 2 most significant digits of year and 2 low digits of year. Is admitted(allowed,valid) to adjust only year, leaving K3 constant. At usage of the frequency counter on direct assignment the given program in any way does not show itself and is started, only if to include power supply at pressed "dF button. On the indicator in this case there is a year written in ROM. If to hold the button pressed more 2 sec, the score of years  1997 starts, then 1998 etc. Having waited the necessary date it is necessary to release the button after that the program outputting on the indicator a little bit sequentially changed each other of dynamical pictures is started. What? Make  will see! Program (ch2.zip) Translation: Cius Serge, Moldova [email protected] Author of construction: [email protected] http://www.kirov.ru/~ra4nalr

My LED matrixindicator

# 5

5

5

5

5

5

5

5