0% found this document useful (0 votes)
41 views7 pages

RadioKot - Function Generator - Frequency Meter On MAX038

Uploaded by

mb_raghavendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views7 pages

RadioKot - Function Generator - Frequency Meter On MAX038

Uploaded by

mb_raghavendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Search the site

Home Schemes Laboratory A rticles Tutorial Links Directory CatA rt A bout the Forum
project

bestchange.ru AD

BestChange.ru — мониторинг обменных пунктов


Актуальные курсы в надёжных обменниках без скрытых комиссий. Более 1 млн отзывов

Select Language
RadioCat > Circuits > Digital devices > Measuring equipment >
Pow ered by Translate
Add a link to the discussion of A D • H Y B RI D . A I
Article tags: Add tag
the article on the forum

Function Generator / Frequency Counter on MAX038

Author: Pushok62
Published 10/29/2015
Created with KotoRed .

Function Generator / Frequency Counter on Maxim MAX038 and Atmel ATmega16

(based on the project "PIC-GEN Frequency Generator / Counter" by John Becker, EPE Online, July 2000 – www.epemag.com – 518)

Universal tool for the workshop

The original "PIC-GEN" project [1] is a very flexible and inexpensive working tool obtained by combining the wide capabilities of the MAX038 pulse generator
chip and the PIC16F877 microcontroller (MC). The variant considered below (let's call it, for example, "FG/CM") considers the adaptation of this project to the

ATmega16 MCU [6] without deterioration or with improvement of characteristics. The description is prepared on the basis of the translation of the original
article, with changes concerning the features of this implementation, while the numbering of the circuit elements for ease of comparison is left the same.

The MAX038 microcircuit [7] is a high-frequency precision function generator that generates triangular, sinusoidal and rectangular pulses at the output in a
frequency band from 0.1 Hz to approximately 10 MHz, divided in the design under consideration into 8 overlapping frequency ranges. The range and shape of
the signal are selected using the MC by pressing the control buttons. The frequency is smoothly adjusted within the selected range using a potentiometer
located on the front panel.

The alphanumeric LCD module displays information about frequency, range and inclusion of the output divider with an attenuation factor of 10.

The generator has 4 outputs:

direct output with signal amplitude of 1V;

output with DC isolation, smooth amplitude adjustment up to ±2V and the ability to stepwise attenuate it by 10 times;

pulse output with logic levels from 0V to 5V;

pulse output with a fixed frequency of 3.2768 MHz and logic levels from 0V to 5V.

The MK in combination with the functions of selecting the frequency range and the generator signal shape is also used as a frequency meter, switched by a
switch to control the frequency of the signal generated by the MAX038, or a signal from external sources. Two external inputs are provided: one for pulse
signals with logic levels from 0V to 5V, the other is a universal one for AC signals, which, thanks to the use of an additional amplifier-shaper, has a sensitivity
of about 0.2V.

Function Generator MAX038

The MAX038 chip provides signal generation with an upper frequency of at least 20 MHz, and in some cases up to 40 MHz. The upper frequency limit of the
chip depends not only on the accuracy of current control through its terminals used to set the frequency, but also on the associated capacitances, including
those formed by the printed circuit board tracks. In the described design, it was possible to obtain a maximum output frequency of about 10 MHz.

The MAX038 microcircuit in the device operates under the control of a microcontroller with 4 input/output ports, providing automated switching of frequency
range capacitors, selection of the signal shape, attenuation coefficient of the output divider, and also performing the functions of a frequency meter and
output to an LCD display.

The schematic diagram shows that half of the terminals of the MAX038 chip, designated as IC2, are grounded, and it can be correctly concluded that not all
of its capabilities are used. In this design, only those control terminals are used that set the frequency and waveform. The selection of one of the eight
frequency ranges is carried out according to the value of the capacitance connected to the “C OSC” terminal. Smooth frequency adjustment is carried out
by changing the current passing through potentiometer VR1, connected to the I IN terminal. Resistor R2 limits the maximum current flowing, while resistor R1
sets the minimum current.

Frequency selection

Eight capacitors C11..C18 are used to set the frequency ranges. The common connection point of these capacitors is connected to the pin of the IC2
microcircuit "C OSC" (5). Individual pins of capacitors C12..C18 are connected to the PA port of the microcontroller IC5. Capacitor C11 is permanently
connected to the ground bus.

Initially, the seven pins of the MCU are configured as inputs. In this "Z" state, they effectively hold the open circuit, having a very high impedance. As a
result, the MAX038 ignores these capacitors.

To include one of the seven port-controlled capacitors in the circuit, the corresponding output of the MC is set to output mode with a logical 0 (0V) state.
As the value of the selected capacitance increases, the output frequency of IC2 decreases.

Capacitor C11 is the control component for the highest frequency range. It should be noted that its nominal capacitance of 10pF will be perceived as higher
by the MAX038 due to the (unpredictable) capacitance of the circuit near the "C OSC" pin. Capacitor C11 can be omitted if you want to try to increase the
maximum achievable frequency.

The upper frequency limit depends not only on the location of the capacitors C12..C18 on the board (the closer they are to the MC pins, the better), but
also on their sizes (it is better if they are smaller). The maximum frequency is affected by all the specified capacitors, even if they are disabled by software,
which can be explained by the influence of the internal input capacitances of the MC inputs. An attempt to connect the capacitors through additional
electronic keys (BSS138 field-effect transistors and ADG702 analog switches were tested) showed that the input capacitance of the MC pins has a smaller
effect.

Pressing the pushbutton switches S1 and S2 causes the MK to shift the frequency range down or up, respectively, in an 8-step cycle.

The nominal values ​of the capacitors were chosen to provide a 10-fold frequency difference between adjacent ranges and to take into account
manufacturing tolerances, which can be particularly large for electrolytic capacitors.

Potentiometer VR1 provides a frequency span adjustment from 1 to 50. For example, if the minimum current through VR1 and R2 produces a frequency of 1
kHz, the maximum current will result in 50 kHz oscillation. The bandwidth can be reduced by increasing the value of R1, although this will raise the lower
frequency.
Selecting the signal shape and level

The device provides a choice of one of three signal forms: sinusoidal, triangular and rectangular. The choice is made in accordance with the binary code
supplied to the inputs A1 and A0 of the MAX038 microcircuit. The code is formed by the MC through the corresponding pins PA0, PB1 as follows:

A1 A0 Form

0 0 Rectangular

0 1 Triangular

1 x Sine Wave

Pressing the S4 button causes the MC to cycle through the three specified signal shape selection codes.

The signal of the selected shape is fed to the "OUT" pin of IC2 and has a fixed amplitude of ±1V symmetrically relative to 0V. The output has a very low
impedance (typically 0.1Ω) and can be taken directly from the SK5 connector.

The same signal is amplified by operational amplifier IC3a in non-inverted mode. The gain is set to 2, resulting in a signal swing of ±2V at the output.

Then the signal through the divider R17, R18 with the attenuation coefficient of 10, switched off programmatically by short-circuiting the resistor R17 by the
analog switch IC9 of the ADG702 type [10], goes to the repeater IC3b. The analog switch is controlled by the logical levels 0 and 5V, coming to its control
input "IN". When the level at the control input "IN" is low, the output "D" is connected to the output "S", thereby short-circuiting the resistor R17 and
switching off the divider, when it is high, the outputs "D" and "S" are transferred to a high-impedance state (opened), which leads to switching on the divider,
and as a result the output signal level at the connector SK3 decreases by 10 times.

Since the IC9 microcircuit is designed to work with analog signals operating within the range from 0 to 5 V, then for working with a signal of both polarities
coming from the output of IC3a, a power supply bias circuit of the microcircuit on resistors R20..R22 and a shunt capacitor C35 is introduced into the circuit.
As a result, supply voltages of –2.5V and +2.5V, symmetrical with respect to 0V, are supplied to the microcircuit, and it successfully switches both positive
and negative half-waves of the signal. To control the microcircuit, the levels at the input "IN" are also shifted: the low control level corresponds to –2.5V,
the high level - +2.5V, which is ensured by elements R23..R25, VT1. When a high logical level of 5V is acting at the output of MK PD4, the key on transistor
VT1 is closed, a voltage of –2.5V is supplied to the input "IN" of the switch through resistor R25, and the switch is turned on. When the logic level at the
output of the PD4 microcontroller is low, the VT1 transistor opens, supplying a voltage of +2.5V to the “IN” input of the switch through a divider formed by
resistors R24, R25, and turning off the switch.

Pressing the S8 button causes alternation of logic levels at the specified MC output, which results in switching the divider on or off. ADG701, ADG801 (with
control signal inversion "IN") or ADG802 can be used as an analog switch of the output divider.

Capacitors C3, C34 provide DC decoupling of the IC3b output, and potentiometer VR2 enables smooth adjustment of the output amplitude on connector SK3
from zero to maximum.

The use of a high-frequency (bandwidth up to 300 MHz) operational amplifier AD8056A [9] as IC3a,b allowed amplification of the entire frequency range of
the generator. Good results were also obtained with a dual operational amplifier of the EL2244 type (bandwidth up to 120 MHz).

Frequency meter

Although the MCU can be programmed to function as a frequency counter by polling the state of one pin, the maximum frequency measurable by this method
is very limited. To measure high-frequency signals, an external counter is used as a prescaler, the output of which is regularly monitored at a slower interval.

The role of such a counter is performed by a 12-bit microcircuit IC6 of the 74HC4040 type. Its terminals are connected to the terminals of the MC PB0, PD7,
PC0..PC7. The circuit diagram shows that the order of the MC terminals used does not match the order of the counter terminals. This is done intentionally to
simplify the layout of the printed circuit board, and is taken into account in the software for the correct interpretation of the input binary values.

Compared to the original circuit, the last three digits Q11, Q10, Q9 of the IC6 counter are not used. Q8 is used as the last digit, which changes its state with
a frequency 512 times lower than the input frequency. The signal from it goes to the PB0 / T0 pin of the MC, which is also the input of the built-in 8-digit
counter/timer 0. The value of the counter/timer 0 is incremented each time the state of the specified pin changes from high to low. When the counter/timer
0 overflows, the MC registers this, calling the appropriate interrupt processing subroutine, which in turn increments the value of the internal program counter.
Thus, the frequency counter is made up of 3: the external 9-digit counter IC6, the 8-digit counter/timer 0, and the internal program counter.

Before the next measurement cycle, the internal program counter, counter/timer 0 and external counter IC6 are reset (the latter via the PC2 MC output).

With a regularly controlled periodicity of 1 or 10 seconds, selected by the S3 button (sampling time), the MC reads the full 9-bit sequence of the IC6 outputs
and the value of the counter/timer 0. The frequency value is calculated based on these values ​and the state of the internal program counter. A 4-byte
variable is used to store the entire result, taking into account the maximum sampling interval of 10 seconds. The upper limit of the measured frequency using
the described counting circuit is determined only by the frequency capabilities of the IC6 and IC7 microcircuits. By reducing the number of polled outputs of
the IC6 microcircuit, it was possible to free up two MC pins (PB4, PD4), which are used to control the output divider. Probably, the number of used IC6
outputs can be reduced even more (by 1-3 digits) without deteriorating the device characteristics, but this possibility has not been tested.

In the original design, the internal program counter change signal coming from the IC6 counter output was registered exclusively by software. Testing of such
a method on the Atmega16 MC, including using the external INT0 interrupt, showed low results. In particular, underestimation of readings began to appear at
a frequency at the MC input of more than 5 kHz. The limit of such a method, apparently, can be considered an MC input frequency of about 20 kHz, after
which the error associated with missing pulses increases even more (at frequencies above 50 kHz, pulse counting stops altogether). This is consistent with
the statement of the author of the original design about the successful measurement of frequencies of about 40 MHz (when using all 12 bits of IC6 at the MC
input in this case, a signal with a frequency of about 10 kHz will act).

During the experiments, a drawback was also revealed, related to the error of software generation of the count strobe, fed to input 5 of the IC7a gate.
During debugging, the sampling duration (1 or 10 seconds) was generated using timer/counter 1 using the counter overflow interrupt. Due to the instability of
the software opening and closing moments of the IC7a gate, related to the limited clock frequency of the MC, when the frequency of the input signal
increased, the value of the IC6 counter bounced.

The problem was solved by using the hardware output OC1A (PD5) of timer/counter 1 to generate the counting signal. To implement this feature,
timer/counter 1, which operates with a prescaler of 1024 (the input signal cycle duration is 0.3125 μs), is switched to the "ClearTimeronCompare (CTC)"
mode. The essence of this mode is that the process of increasing the value of the TCNT1 counter continues until it matches the preset value of the output
comparison register OCR1A, which determines the pulse duration. After this, the value of the TCNT1 counter is automatically reset, and the OC1A output of
the MC is switched to the state specified when timer/counter 1 was started, with an automatic call to the interrupt processing subroutine by coincidence.

Before the frequency measurement starts, timer/counter 1 generates a short preparatory pulse, during which the frequency counters are initialized, and upon
completion, the OC1A output is automatically switched to the logical one state, allowing pulses to pass through the IC7a gateway to the IC6 counter input.
In this case, the coincidence interrupt processing subroutine restarts timer/counter 1 with a new OCR1A register value, which determines the counting
interval duration (for 1 second, the value is 3199, for 10 seconds, 31999). The frequency measurement process itself begins, upon completion of which the
OC1A output is automatically set to a logical zero state, locking the IC7a gateway. At the same time, the coincidence interrupt processing subroutine of
timer/counter 1 is called, which stops it until the next forced restart, and calculates the full value of the frequency counter. After the obtained value is
displayed on the indicator, the entire cycle is repeated.

With this method of forming the measurement interval, it was possible to eliminate the chatter of its duration and obtain stable meter readings.

For accurate generation of measurement intervals of 1 or 10 seconds, it is necessary that the frequency value of the quartz resonator X1, expressed in Hz,
be a multiple of 1024. The upper limit of this value is determined by the maximum value of the 16-bit timer/counter 1, capable of providing the generation of
a measurement interval of 10 seconds, and is (65536 / 10) * 1024 = 6 710 886.4 Hz (where 1024 is the prescaler coefficient of the counter/timer 1). For
example, quartz resonators with frequencies of 6.144 MHz, 6.4 MHz, 6.5536 MHz would be suitable. Since the measurement accuracy does not increase with
increasing clock frequency with the method described above, the latter is left equal to 3.2768 MHz.

Frequency measurement input

There are three sources of the measured signal, described below. The signals from all three sources enter the already discussed counter IC6 via the Schmitt
trigger IC7a. The signal sources are switched using switches S5 (selection of the signal from the generator or from external sources) and S6 (selection of an
external source with a digital or analog signal).

External digital signals with logical levels from 0V to 5V are fed to the frequency meter via connector SK1 (logical or digital input) and then to switches S5,
S6. To prevent accidental entry of signals above or below the 0V/5V limits to the input (4) of the Schmitt trigger IC7a, a limiting circuit is introduced into the
circuit, consisting of a resistor R30 with a parallel-connected capacitor C36 and protective diodes VD2, VD3. These elements are brought out directly to the
input connector SK1.

Analog or digital signals with a lower level are fed through the SK2 connector (universal or analog input) to the board of a separate amplifier-shaper (input
block), located at the SK2 connector.

The amplifier-shaper circuit is based on the input node of the digital frequency meter described in [2], [3]. In the absence of an input signal, its output must
have a logical zero level, so an inverting transistor switch is added to the circuit output.

Since the main output signal from the MAX038 is generally analog with an amplitude swing of ±1V, it is first converted to digital form using the Schmitt trigger
unit IC7c to calculate its frequency. The potential of one of its inputs (13) is shifted by half the supply voltage (2.5V) through a voltage divider formed by
resistors R8 and R9; the other input (12) is supplied with a voltage of +5V. The signal from the generator is connected to the shifted trigger input through
capacitors C10, C30, which provide DC decoupling. The trigger is capable of responding to a signal with an amplitude of 2 to 5 V.

The output signal from the generator output goes to switch S5, which switches its passage to counter IC6 through valve IC7a.

Logical output

The signal taken from switch S5 and fed to the input of gate IC7a is also fed to buffer element IC7d, and from its output to connector SK7. This allows the
signal generated by MAX038 to be used as a 5V square wave regardless of the shape of the generated signal, and also to convert an external analog signal
i t l i l ith 5V i (th idth f th di it l l ill d d th t f th i l)
into a pulse signal with a 5V swing (the width of the digital pulses will depend on the nature of the signal).

The MAX038's own square wave signal on the SYNC pin is not used due to its instability.

Output 3.2768 MHz

The MK operates at a frequency of 3.2768 MHz, determined by the quartz resonator X1. Although this frequency can be taken directly from the MK OSC2 pin,
it is brought out to the external connector SK4 through the buffer IC7b. The output is a 5V square wave.

Display module

The liquid crystal display (LCD) is used to display the frequency and sampling interval of the frequency counter, as well as the selected waveform and
frequency range number as a digit from 0 to 7, where 0 corresponds to the lower frequency range. The displayed information has the form:

Sine 25138 Hz

Diap5 ∆T=1s Del10

Where:

line 1 from the left: the selected signal shape ("Sine", "Triangle" or "Straight");

line 1 middle/right: frequency value in hertz;

line 2 from the left: selected frequency range (8 options);

line 2 in the middle: counting time (interval) (2 options);

line 2 on the right: output divider attenuation factor (2 options).

The LCD display is designated on the diagram as X2. It is controlled by a standard 4-bit scheme via the MK PB and PD ports. The LCD screen contrast is
adjusted using VR3. A Russified MT-16S2H-2YLG [11] or MT-16S2D-3YLG indicator with green backlighting is used (the second one is slightly smaller in height,
and its contacts are located on the side). Codes for forming the image of the symbol "∆" are loaded into the indicator's character generator programmatically.
To display the number "10", a single symbol built into the character generator is used, which allows all the necessary information to fit into the second line of
the indicator.

When you press the S3 button and turn on the power, the message “Counting...” appears on the screen until the first frequency count on the selected
counting interval.

power unit

The device is powered by a single-polar 8V DC source. The original design assumed the ability to power the device from a battery. However, due to the fact
that the current consumed by it turned out to be relatively large (about 250 mA), it was decided to limit the device to the option of powering it only through
a step-down transformer with a rectifier (DB102) and a smoothing capacitor (1000µ x 16V). If it is necessary to power from a battery, it is advisable to use a
separate DC-DC converter unit with an output voltage of +8V using the step-up circuit ("Step-up converter"), for example, on the MC34063A microcircuit.

The IC4 and IC8 stabilizer microcircuits are used in a TO220 case (small radiators would not hurt them).

Instead of the MAX660 voltage converter microcircuit (IC1), which according to the passport data has a maximum input and output voltage of only 6V (in the
original it was used at a voltage of 9V), the MC34063A microcircuit [8] is used (you can also use MC33063A or NJM2406AD) with an inverting connection
scheme. The output voltage of this unit is determined by the formula:

A ready-made choke of the RLB0912-101KL or RLB0914-101KL type, which has low DC resistance, can be used as L1. In the interference suppression filter of
the negative power supply arm of the IC2 microcircuit, instead of the resistor R3 with a nominal resistance of 10 Ohm excluded from the circuit, the choke L2
of the EC24-330K type can be used.

Connecting to the programmer

The MK is programmed directly on the printed circuit board. For this purpose, 6 signals according to the IDC6 (Atmel) standard are output to the TB2
connector, intended for connecting the programmer (the “Master Kit NM9211” programmer was used [5]): Data output MISO (1), Positive power supply VCC
(2), Clock signal SCK (3), Data input MOSI (4), Reset line RES (5), Negative power supply GND (6).
Miscellaneous

Resistors R10..R14 are grounded to create proper bias on the corresponding pins of the MK when the control buttons are not pressed.

Only HC versions of the chips (74HC4040 and 74HC132) should be used as IC6 and IC7. They are usually capable of handling signals above 40 MHz.

Numerous bypass capacitors along the power supply chain are used at "strategic" points on the PCB
Numerous bypass capacitors along the power supply chain are used at strategic points on the PCB.

The resistance values ​of resistors VR3 and R29 must be the same and can be in the range of 10..50 kOhm.

A power (SMD) diode is soldered parallel to the power connector terminals on the bottom of the board, protecting the installed radio components from
accidental polarity reversal when connecting an external voltage source.

Links

Original development: https://www.epemag.com/lib/free_projects/picmicro/0700%20-%20PIC-Gen%20Frequency%20Generator.pdf

S. Biryukov. Digital frequency meter. "Radio", No. 10, 1981, p.44: ftp://ftp.radio.ru/pub/arhiv/1981/10.djvu

Amplifier-shaper for frequency meter: https://www.s-led.ru/998-usilitel-formirova...astotomera.html

AVR Studio 4.19 (build 730) https://www.atmel.com/ru/ru/tools/studioarchive.aspx

NM9211 - ATMEL microcontroller programmer https://masterkit.ru/shop/removed/28032

ATmega16 Description: https://www.atmel.com/Images/doc2466.pdf

Description of MAX038: https://datasheets.maximintegrated.com/en/ds/MAX038.pdf

Description of MC3x063A: https://www.ti.com/lit/ds/symlink/mc34063a.pdf

Description of AD8056A: https://www.analog.com/media/en/technical-documentation/data-sheets/AD8055_8056.pdf

Description of ADG702: https://www.analog.com/media/en/technical-documentation/data-sheets/ADG701_702.pdf

Description of LCD: https://www.melt.com.ru/docs/MT-16S2H.pdf

Converting a 32-bit binary number to a BCD buffer: https://we.easyelectronics.ru/Soft/preobrazuem-v-stroku-chast-1-celye-chisla.html

Files:
Modified main PCB (jumper added)
PCBs in Sprint Layout 5 format
Schematic diagram
Schematic diagram of the input block
Program text in C++
Installation view
External appearance

All questions in the Forum .

Like +1
How do you like this article? Did this device work for you?

15 7 21

A D • 16+ AD AD AD

The site's functionality has been tested in the following browsers:


IE8.0, Opera 9.0, Netscape Navigator 7.0, Mozilla Firefox 5.0
Adapted to work with screen resolutions of 1280x1024 and higher.
At lower resolutions, horizontal scrolling may occur.
For all questions, please contact Kot: [email protected]
©2005-2024
bestchange.ru
playhop.com
BestChange.ru — mt4trading.ru hotproekt.ru
Play now! Solitaire Klondike - Deluxe
мониторинг обменных Шаблоны рабочей и проектной
Solitaire Klondike - Deluxe is one of the Прибыльный индикатор
most popular logical single-player car пунктов без перерисовки. WINRATE 87,5%. документации AutoCAD
Find out more Узнать больше Узнать больше Узнать больше

You might also like