2023-12-01
Pulse generator on PIC controller. Extended analogue of TL494
Such a device can be considered as some kind of analogue of a generator on the popular microcircuit TL494,
but having greater opportunities for the formation of impulses.
It can generate pulses on its two channels with independent duty cycle and a phase shift between them.
The first channel can generate pulses with a duty cycle of 1…99% and with a step of 1%, which at its maximum value and maximum frequency gives an output pulse with a length of about 200 ns.
The second channel generates pulses with a duty cycle of 3…93% and in increments of 3%.
The phase between these pulses is adjustable in 1% steps.
All specified adjustments are stored in the long-term memory of the microcontroller and are not reset when the power is turned off.
The generator frequency ranges are from 4 to 14 kHz, and from 14 to 54 kHz, but they can always be expanded.
In each range, the frequency is smoothly adjusted using a variable resistor.
Various drivers for controlling bipolar, IGBT and MOSFET transistors can be connected to the outputs of the generator presented here,
which makes it indispensable for building a large class of devices,
with the help of which you can, for example, study free energy phenomena without fear of burning expensive equipment.
The following video shows the capabilities of this simple generator connected to a dual beam oscilloscope.
Video from the oscilloscope screen demonstrating the capabilities of the pulse generator. The CHA and CHB channels are connected to the oscilloscope (Fig. 1)
The heart of the device is the microcontroller PIC16F684 in a 14-pin package.
Its maximum consumption, at maximum frequency, is only about 4 mA at 5 V supply.
and its cost is comparable to the TL494 chip.
The circuit uses two non-standard solutions for this type of microcontroller, which make it possible to obtain two independent channels and smooth frequency control using a variable resistor (R1).
Just like in the classic circuit with TL494, there are two control knobs here: variable resistor R1 (controls the frequency)
and encoder EN1,
which controls the duty cycle of the pulses and the phase between them (A-B-C).
This becomes possible due to its additional function - a button (S1-S2) that switches control modes (Fig. 1).
Fig.1. Schematic diagram of a pulse generator on the microcontroller DD1
|
By default, the first mode is enabled, in which by rotating the encoder knob we can adjust the duty cycle of pulses in the CHA channel.
By pressing the button on the encoder, we switch to the second mode, where we can adjust the duty cycle of the pulses in the CHB channel.
Another press of the button on the encoder switches us to the third mode, in which the phase between the pulses in these two channels is adjusted.
Switching control modes is accompanied by the corresponding LED lighting:
- D1 - adjusting the duty cycle of the first channel pulses (CHA),
- D2 - adjusting the pulse duty cycle of the second channel (CHB),
- D3 - adjust the phase difference between the pulses of two channels.
By default, the oscillator frequency range is from 14 to 54 kHz.
But if you close the contacts of switch SW1, the range will change to 4…14 kHz.
Following the same principle - adding frequency-setting capacitance C1 - you can expand the number of ranges, if necessary.
Saving pulse settings
The settings you set are saved quite simply: press the button on the encoder and, while the button is pressed, the encoder knob turns at least one position (in any direction).
In this case, all three LEDs D1-D3 will flash several times simultaneously. This completes the recording process.
Now, even if the power is turned off, all settings are saved.
Details
Below are the electronic parts and their possible replacements (in parentheses):
- DD1 - microcontroller PIC16F684 (SPIC16F684);
- EN1 - encoder with a button (switch), for example EC11;
- SW1 - any switch or button with a fixation, for example;
- D1-D3 - any LEDs for voltage below 4 Volt, for example.
Firmware file
The file for flashing the microcontroller can be downloaded from here.
It is very simple to flash a pic controller; separate note is dedicated to this.
Installation and configuration of the circuit
During installation, you need to pay attention only to the frequency-setting part: pin 2 of the RA5 controller, resistor R1 and capacitor C1.
For less interference, the distances between these elements should be as short as possible.
For a correctly assembled circuit and a firmware microcontroller, no settings are required.
Connect a dual-beam oscilloscope to channels CHA and CHB, and turn the encoder knob. Everything should start working right away.
Printed circuit board
Below is the PCB layout for the option with a power adapter.
Please note that the DD1 controller is used here in a DIP14 package.
The entire circuit can be powered from a 5-24 V voltage source.
Production version: PCB (open)
The production option provides a set of documentation for manufacturing a printed circuit board in production:
GERBER file for PCB, BOM file of the specification of components and a schematic diagram showing the values of the elements.
All this allows you to immediately order a PCB, for example, here, and then quickly assemble it.
What's next?
In this part, we looked at a schematic version of the generator, for which high accuracy of the setting frequency is not important.
But in this case, we can obtain any frequencies at its output using a fairly simple adjustment with a variable resistor.
In subsequent parts we will present circuit options with quartz frequency-setting circuits, where the accuracy will be determined by a quartz resonator.
However, all frequencies obtained in this way will be fixed and can be changed using a switch.