Contacts

Digital tachometer based on PIC16F628 microcontroller. A simple universal tachometer based on the ATtiny2313 microcontroller. Radio engineering, electronics and diy circuits Simple tachometer on the peak controller

Good afternoon.
I am submitting for your consideration a diagram of a simple digital tachometer on AVR ATtiny2313, KR514ID2, and the optocoupler designed by me.
I will make a reservation right away: there are many similar schemes on the Internet. Each implementation has its own pros and cons. Perhaps my version will suit someone more.

Perhaps I'll start with those. tasks.
Task: you need to make a digital tachometer to control the speed of the electric motor of the machine.
Introductory conditions: There is a ready-made reference disk for 20 holes from laser printer... There are many optocouplers from broken printers. Average (working) revolutions 4,000-5,000 rpm. The error in the displayed results should not exceed ± 100 revolutions.

Limitation: the power supply for the control unit is 36V (the tachometer will be installed in the same housing with the control unit - more on that below).

Small lyrical digression. This is my friend's machine. The machine is equipped with a PIK-8 electric motor, the revolutions of which are controlled according to a modified and found scheme on the Internet. At the request of a friend, a simple tachometer for the machine was developed.

Initially, it was planned to use ATMega16 in the circuit, but after considering the conditions, it was decided to limit ourselves to ATtiny2313, which operates from an internal (RC) generator at a frequency of 4 MHz.

General scheme as follows:

As you can see, nothing complicated. To convert the binary code into a seven-segment one, I used the KR514ID2 decoder, this gives three advantages at once.

  • Firstly, saving space in the ATtiny2313 memory by reducing the working code (since the procedure for programmatically converting a binary code into a seven-segment code is absent in the firmware as unnecessary).
  • Secondly: reducing the load on the ATtiny2313 outputs, since LEDs "illuminate" KR514ID2 (when the number 8 is highlighted, the maximum consumption will be 20-30 mA (typical for one LED) * 7 = 140-210 mA which is "a lot" for ATtini2313 with its full passport maximum (loaded) consumption of 200 mA).
  • Thirdly, the number of "occupied" legs of the microcontroller has been reduced, which gives us the opportunity in the future (if necessary) to upgrade the circuit by adding new features.

Assembling the device implemented on a breadboard. For this, a fee from a non-working microwave oven that was lying around in the bins was dismantled. The digital LED indicator, key transistors (VT1-VT4) and limiting resistors (R1-R12) were taken as a kit and transferred to new board... The entire device is assembled, if the necessary components are available, with smoke breaks in half an hour. Paying attention: the KR514ID2 microcircuit has a positive power leg - 14, and a minus - 6 (marked in the diagram)... Instead of KR514ID2, you can use any other binary code decoder in a seven-segment, powered by 5V. I took what was at hand.
The pins "h" and "i" of the digital LED indicator are responsible for two points in the center between the numbers, they are not connected as unnecessary.
After assembly and firmware, provided there are no installation errors, the device starts working immediately after switching on and does not need to be configured.

If it is necessary to make changes to the tachometer firmware, an ISP connector is provided on the board.

In the diagram, the pull-up resistor R12, rated 30 kOhm, is selected empirically for a specific optocoupler. As practice shows, it may differ for different optocouplers, but an average value of 30 kΩ should ensure stable operation for most printer optocouplers. According to the documentation for the ATtiny2313, the value of the internal pull-up resistor is from 20 to 50 kOhm, depending on the implementation of a particular batch of microcontrollers, (page 177 of the ATtiny2313 data sheet), which is not quite suitable. If anyone wants to repeat the circuit, they can first include an internal pull-up resistor, perhaps for you, it will work for your optocoupler and your MK. It didn't work for me for my set.

This is what a typical optocoupler from a printer looks like.

The optocoupler LED is powered through a 1K limiting resistor that I placed directly on the optocoupler board.
To filter voltage ripples, there are two capacitors in the circuit, electrolytic at 220 μF x 25V (which was at hand) and ceramic at 0.1 μF, ( general scheme the inclusion of the microcontroller is taken from the ATtiny2313 passport).

To protect against dust and dirt, the tachometer board is covered with a thick layer of automotive varnish.

Replacement of components.
You can use any four-digit LED indicator, either two doubles or four single ones. At worst, assemble the indicator on separate LEDs.

Instead of KR514ID2, you can use KR514ID1 (which contains current-limiting resistors inside), or 564ID5, K155PP5, K155ID9 (with parallel connection of the legs of one segment), or any other binary-to-seven-segment converter (with appropriate changes in the connection of the microcircuit pins).

Provided that the installation is correctly transferred to the ATMega8 / ATMega16 MK, this firmware will work as on the ATtiny2313, but you need to correct the code (change the names of the constants) and recompile. No comparison was made for other AVR MCUs.

Transistors VT1-VT4 - any low-current operating in key mode.

Principle of operation based on counting the number of pulses received from an optocoupler in one second and recalculating them to display the number of revolutions per minute. For this, an internal counter Timer / Counter1 is used, which operates in the mode of counting pulses arriving at the T1 input (output PD5 leg 9 MK). To ensure stability of operation, the mode of software bounce suppression is enabled. The seconds are counted by Timer / Counter0 plus one variable.

RPM calculation, on what I would like to dwell on, occurs according to the following formula:
M = (N / 20) * 60,
where M is the calculated revolutions per minute (60 seconds), N is the number of pulses from the optocoupler per second, 20 is the number of holes in the reference disk.
Total, simplifying the formula, we get:
M = N * 3.
But! The ATtiny2313 microcontroller lacks a hardware multiplication function. Therefore, offset summation was applied.
For those who do not know the essence of the method:
The number 3 can be expanded as
3 = 2+1 = 2 1 + 2 0 .
If we take our number N, shift it to the left by 1 byte and add another N shifted to the left by 0 bytes - we get our number N multiplied by 3.
In the firmware, the AVR ASM code for a two-byte multiplication operation looks like this:

Mul2bytes3:
CLR LoCalcByte // clear working registers
CLR HiCalcByte
mov LoCalcByte, LoInByte // load values ​​obtained from Timer / Counter1
mov HiCalcByte, HiInByte
CLC // clean up the life of the transfer
ROL LoCalcByte // Shift Through Carry Bit
ROL HiCalcByte
CLC
ADD LoCalcByte, LoInByte // add up taking into account the carry bit
ADC HiCalcByte, HiInByte
ret

Performance check and accuracy measurement was carried out as follows. A cardboard disc with twenty holes was glued to the fan of the computer cooler. Cooler rotations were monitored via BIOS motherboard and were compared with the indicators of the tachometer. The deviation was about 20 rpm at 3200 rpm, which is 0.6%.

It is quite possible that the actual discrepancy is less than 20 revolutions, because motherboard measurements are rounded within 5 revolutions (based on personal observations for one specific board).
The upper limit of measurement is 9,999 rpm. The lower limit of measurement, theoretically from ± 10 revolutions, but in practice was not measured (one pulse from the optocoupler per second gives 3 revolutions per minute, which, taking into account the error, theoretically should correctly measure the speed from 4 revolutions per minute and above, but in practice this the indicator must be overestimated at least twice).

I will dwell separately on the issue of nutrition.
The whole circuit is powered from a 5V source, the estimated consumption of the entire device does not exceed 300 mA. But, according to the terms of the TK, the tachometer should be structurally located inside the engine speed control unit, and the unit receives from the LATR constant pressure 36V., In order not to pull a separate power wire, an LM317 is installed inside the unit in the passport connection, in the mode of lowering the power supply to 5V (with a limiting resistor and a zener diode to protect against accidental overvoltage). It would be more logical to use a PWM controller in the step-down converter mode, like the MC34063, but it is problematic to buy such things in our city, therefore, they used what they could find.

Photo tachometer board and finished device.


More photos







Unfortunately, now it is not possible to take pictures on the machine.

After the layout of the boards and the first trial assembly, the box with the device went to paint.

If your tachometer does not work immediately after switching on, with a knowingly correct installation:

1) Check the operation of the microcontroller, make sure that it works from the internal generator. If the diagram is assembled correctly, the dial should display four zeros.

2) Check the level of pulses from the optocoupler, if necessary, select the value of the resistor R12 or replace the optocoupler wiring diagram. The option of reverse connection of the opto-transistor with a pull-up to the minus is possible, with the internal pull-up resistor MK turned on or not. It is also possible to use a transistor in a key (inverting) mode of operation.
optocoupler

  • AVR
  • Add tags

    The tachometer is designed to measure the rpm of almost any engine. Starting from a moped 1-cylinder two-stroke engine and ending with a 16-cylinder 4-stroke engine. Indication on a 4-digit digital indicator, measurement accuracy 50
    rpm.

    After turning on the power, the tachometer immediately begins to measure the revolutions. Pressing the button for the first time will display the set number of pulses per 1 revolution (by default, 2 pulses per 1 revolution, which corresponds to a 4-stroke 4-cycle engine). The display will be P-2.0. Pressing the button again will cycle through all the allowable values ​​- from 0.5 to 8 pulses per 1 revolution. Let it seem a little strange - 0.5 impulses, but this only means that 1 impulse will be in 2 revolutions. After setting the required number of pulses, after about 5 seconds, the device will write the changes to the non-volatile EEPROM memory (i.e. when you turn on the power again, you do not need to set the number of pulses again), and will switch to the speed measurement mode with the newly set number of pulses.

    Printed circuit board with two parts

    Photo by lawyer

    What is it at all tachometer? A tachometer is a device used to measure the rpm (revolutions per minute) of any rotating body. Tachometers are made on the basis of contact or contactless. Non-contact optical tachometers usually use a laser or infrared beam to control the rotation of any body. This is done by calculating the time taken for one rotation. In this material, taken from one English site, we will show you how to make a portable digital optical tachometer using Arduino Uno... Let's consider an extended version of the device with an LCD display and a modified code.

    Microcontroller tachometer circuit

    Parts list for schematic

    • Microcircuit - Arduino
    • Resistors - 33k, 270 ohm, 10k potentiometer
    • LED element - blue
    • IR LED and photodiode
    • 16 x 2 LCD screen
    • 74HC595 shift register

    Here, instead of a slit sensor, an optical one is used - the reflection of the beam. This way they don't have to worry about the thickness of the rotor, the number of blades does not change the reading, and it can read the drum rpm - but the slot sensor cannot.

    So, first of all for the sensor you need an emitting IR LED and a photodiode. How to assemble it - shown in step by step instructions... Click on the photo to increase the size.

    • 1. First you need to sand the LED and photodiode to make them flat.
    • 2. Then fold the strip of paper sheet as shown in the figure. Make two such structures so that the LED and photodiode fit snugly into it. Glue them together and paint them black.
    • 3. Insert LED and photodiode.
    • 4. Glue them together with super glue and solder the wires.

    Resistor ratings can vary depending on which photodiode you are using. The potentiometer helps to decrease or increase the sensitivity of the sensor. Solder the sensor wires as shown in the figure.

    The tachometer circuit uses a 74HC595 8-bit shift register LCD display 16x2. Make a small hole in the case to fix the LED indicator.

    Solder a 270 ohm resistor to the LED and insert into pin 12 of the Arduino. The sensor is inserted into a cube tube to give additional mechanical strength.

    That's it, the device is ready for calibration and programming. You can download the program at this link.

    Video of the homemade tachometer


    Security device with high voltage- electric hedgehog. Today we will continue talking about the structures that are needed to protect our home. The device that we will now consider is intended for the protection of an apartment, office, summer house and a car. The device is called - a high-voltage electric hedgehog!

    This digital tachometer is suitable for counting the number of revolutions of almost any type of internal combustion engine. The tachometer measurement error is only 50 rpm. A four-digit LED display is used to display the result.
    To set the operating mode, you must use the "Select" button. The first press displays the current operating mode on the display. The default mode of operation is the third, when the transmitter emits two pulses per revolution of the flywheel. Accordingly, the inscription R-2.0 will appear on the display.

    Each subsequent press of the button switches the tachometer operating mode to the next one. There are nine of them in total: 0.5, 1, 2, 3, 4, 5, 6, 7, 8 pulses / revolution, respectively, they set the number of pulses issued by the sensor per one turn of the flywheel. The higher the number of pulses, the more accurate the measurement is.

    After selecting the operating mode, you must wait 5-10 seconds. During this time, the tachometer will record the operating mode in the microcontroller memory and switch to the operating mode. In the future, the tachometer will immediately switch to operating mode when power is applied. If it becomes necessary to readjust the tachometer, press the "Select" button and adjust the tachometer again.

    It is worth paying attention to the parameters and structure of the input circuit. For a specific type of ignition, some adjustments to the ratings are possible, due to different devices ignition in different types auto. This is necessary so that the tachometer works well with fundamental harmonics and does not respond to higher harmonics. Without such an adjustment, accurate operation of the tachometer is impossible.

    The updated firmware version includes the indicator test function. This is required to perform a two second sensor failure detection test.

    Attached files:

    Firmware

    Simple monoblock car amplifier on TDA1560Q Car throttle-free PSU on IRS2153 for laptops and mobile phones External USB connector in the car radio

    A simple universal tachometer on the ATtiny2313 microcontroller

    This simple tachometer on ATtiny2313 can count the number of revolutions of any engine, be it multiphase, multi-stroke, etc. It can be useful in motor vehicles to display the engine speed. In this case, it does not matter at all how many strokes or cylinders the engine has. It can also be used in conjunction with electronic motor controllers, whether single or three phase.

    The tachometer circuit is very simple - one ATtiny2313 microcontroller and a four-character LED indicator. For the sake of simplicity, there are no transistor switches. The indicator can be used both with a common cathode and with a common anode - this is selected in the source. The tachometer can count revolutions both per second and per minute, which makes it completely versatile.

    Additionally, the device has the ability program control brightness: normal and low. If the jumper is open, the normal brightness is set. When the contacts are closed, the brightness decreases.


    Click to enlarge
    Let's go directly to the diagram. If the device is connected directly to a TTL motor controller, then the pulses can simply be applied to pin 6 of the microcontroller. Otherwise, you should run simplest converter level on the transistor.

    To obtain and stabilize the supply voltage of +5 volts, linear regulator 1117 with low dropout for greater efficiency.

    An indicator from a microwave oven with a common anode is used as an LED indicator. Since it already contains 220 Ohm resistors, they are not provided on the printed circuit board.


    On the top side printed circuit board there are as many as 10 jumpers, but they are very easy to install.


    SMD components are installed on the reverse side: these are two 22 pF capacitors for a quartz resonator, a stabilizer microcircuit and filter capacitors.

    The crystal resonator for the ATtiny2313 microcontroller can be set to 8 or 4 MHz, this is set in the source and controls the prescaler.

    The display mode of revolutions - per second or per minute - is set similarly in the source. To display the number of revolutions per minute, the calculated number of revolutions per second is simply programmatically multiplied by 60. It is possible to programmatically round off the calculated values. These nuances are commented in source code.

    When flashing the microcontroller, it is necessary to install fuses:

    CKSEL1 = 0
    BODLEVEL0 = 0
    BODLEVER1 = 0
    SPMEN = 0

    The source is written in C in Codevision AVR. It was borrowed from another project - a tachometer for a three-bladed helicopter.

    Briefly about the setting: it is necessary to determine in advance how many pulses per 1 revolution will be supplied to the tachometer input. For example, if their source is a three-phase motor controller on the LB11880, then it outputs by three pulse per spindle revolution. Therefore, you should specify this value in the source code.

    The choice of indicator - with a common anode or with a common cathode (unnecessary value - comment out):

    // # define Anode
    #define Cathode

    Number of tachometric impulses per 1 shaft revolution:

    #define byBladeCnt 2

    Selecting the frequency of the quartz resonator - 0x00 for 4MHz, 0x01 - for 8MHz:

    #define Prescaler 0x01

    RPM display selection:

    lTmp = (62500L * 60L * (long) wFlashCnt);

    To display the number of revolutions per second, you need to remove the multiplication by 60:

    lTmp = (62500L * (long) wFlashCnt);

    In order to disable rounding of values, you need to comment out the following lines:

    If (byDisplay> 4)
    {
    wRpm ++;
    R + = 10;
    }

    Since this particular design uses a very specific indicator, no PCB layout is applied.



    Did you like the article? Share it