Contacts

Do-it-yourself pulse counters circuits. Design Bureau online. Reversible serial counter

This device is designed to count the number of revolutions of the shaft of a mechanical device. In addition to simple counting with indication on the LED display in decimal numbers, the counter provides information about the number of revolutions in a binary ten-bit code, which can be used in the design of an automatic device. The counter consists of an optical speed sensor, which is an optocoupler consisting of a constantly glowing IR LED and a photodiode, between which there is a disk of opaque material in which a sector is cut out. The disk is attached to the shaft of a mechanical device, the number of revolutions of which must be counted. And, a combination of two counters - a three-digit decimal counter with output to seven-segment LED indicators, and a ten-digit binary counter. The counters operate synchronously, but independently of each other. The HL1 LED emits a continuous light stream, which enters the photodiode through a slot in the measuring disk. When the disk rotates, impulses are generated, and since there is only one slot in the disk, the number of these impulses is equal to the number of revolutions of the disk. The Schmitt trigger on D1.1 and D1.2 converts voltage pulses on R2, caused by a change in the photocurrent through the photodiode, into logic level pulses suitable for perception by counters of the K176 and K561 series. The number of pulses (number of disk revolutions) is simultaneously counted by two counters - a three-decade decimal counter on chips D2-D4 and a binary counter on D5. Information about the number of revolutions is displayed on a digital display, composed of three seven-segment LED indicators H1-H3, and in the form of a ten-bit binary code, which is removed from the outputs of the counter D5. Resetting all counters to zero at the moment the power is turned on occurs simultaneously, which is facilitated by the presence of element D1.3. If you need a zero button, it can be connected in parallel with capacitor C1. If you need the reset signal to come from an external device or logic circuit, you need to replace the K561LE5 microcircuit with K561LA7, and disconnect its pin 13 from pin 12 and C1. Now zeroing can be done by applying a logical zero from an external logical node to pin 13 of D1.3. The circuit can use other seven-segment LED indicators similar to ALS324. If the indicators have a common cathode, you need to apply zero, not one, to pins 6 D2-D4. K561 microcircuits can be replaced with analogues of the K176, K1561 series or imported analogues. LED - any IR LED (from the remote control of the equipment). Photodiode - any of those used in remote control systems of TVs of the USCT type. The setting consists of setting the sensitivity of the photodiode by selecting the value of R2.

Radioconstructor No. 2 2003 p. 24

Often, when operating a microcontroller device, there is a need to count “anthropomorphic” time - how many fractions of a second the LED should glow, the maximum period of double-click time, etc. In general, count not only nano- and microseconds, but also tens of milliseconds, or even seconds , minutes and even hours (I'm afraid to say about days...).
At the same time, in microcontrollers it is often necessary to simultaneously deal with microseconds - pulse periods, anti-bounce waiting, etc.
There are also devices that operate continuously for many hours and even days - aviation equipment, automobile equipment, downhole devices (sometimes we are talking about continuous operation for several days). In these cases, overflow of timers and 8-bit variables is unacceptable.
I would like to combine all this into one elegant and universal solution - to have a means of measuring time with microsecond accuracy that does not overflow for several days.
Why not? I suffered for some time and came up with a solution for 8-bit AVR microcontrollers. To do this, I used an 8-bit timer-counter and a 4-byte variable. I don’t currently work with PICs and AT89, and I’m not familiar with other embedded platforms. However, if readers help, I’ll do it for them too.
Advantages – the code is highly repeatable (I’m already making the 5th device with it); ease of operation (interrupts are not used for the client part of the work); the client part of the code is conditionally platform-independent; in the interrupt - one summation operation (but, however, for a 4-byte value); there is no external device - a real time timer.
I found only one drawback - one such useful and always needed timer is busy...
The article will be of interest primarily to beginners - I didn’t discover America here.

Theory

So, I have at my disposal a device based on Atmega16A with 12MHz quartz. Let's take its timer-counter 0. This is an eight-bit timer - that's enough for us. Why? We count:
  1. we take 12 MHz from quartz and take the division factor by 8 - we get a frequency of 1500 KHz;
  2. We take the CTC mode (reset on coincidence) and set the interrupt to coincide with 150 - we get the interrupt frequency of 10 KHz;
  3. on this very interrupt we increment the variable (an increment is obtained every 0.1 milliseconds);
  4. if it is an unsigned 32-bit value, it will overflow after approximately
    • 429496729.6 milliseconds;
    • 42949.7 seconds;
    • 7158.3 minutes;
    • 119.3 hours;
    • 4.97 days.
In other words, this solution creates a timer with an accuracy of 0.1 milliseconds for (almost) 5 days (we must, however, take into account that real quartz has an error - more on that later). And if you also analyze the value of timer 0 itself - it is incremented every 2/3 microseconds - then you can get a counter with an accuracy of 0.67 microseconds.
Enough? Behind my eyes. Using a 0.1 millisecond counter, in my projects I:
  • I count the duration of glow and pauses between LEDs;
  • I take into account timeouts when working with UART, USB;
  • I set all sorts of situations in the test equipment - complex spatio-temporal combinations;
  • I maintain specified time intervals when polling the ADC and other sensors;
  • I tell the computer the time of my (the device’s) operation and transmit information at a given time interval;
  • Taking into account the counter down to the microsecond, I carry out anti-bounce control when pressing keys, analyzing pulses in long lines.
And all this easily fits into ONE ATmega16 CONTROLLER! Moreover, this is not Assembler, but cross-platform C! And no external real-time counter!
Not bad, right?

Setting up for AVR

How to do all this in AVR?
First of all, we create an external variable, which I call “DeciMilliSecond”:
// in main.h typedef unsigned long dword; // unsigned 32-bit integer extern volatile dword dmsec; // 0.1msec // in main.c volatile dword dmsec;
As @no-smoking correctly pointed out, this variable must be volatile so that the compiler does not try to optimize it.
I initialize this variable in a function:
dmsec = 0;
Next, I set the operating mode of timer 0:
// . timer 0 – 0.1msec Timer0_Mode (TIMER_Mode_CTC | TIMER0_Clk_8);
Timer0_Cntr(149);
Timer_Int(Timer0_Cmp); At the same time, in some MCU_init.h I declare everything that is needed:<< 1) // совпадение таймера 0 // . TCCRn #define WGM1 (1 << 3) #define CS1 (1 << 1) // . источник сигнала для таймера 0 #define TIMER0_Clk_8 CS1 // предделитель 8 // . режим работы таймера #define TIMER_Mode_CTC WGM1 // CTC (сброс при совпадении) // . настройка таймера #define Timer_Int(Mode) TIMSK = (Mode) #define Timer0_Mode(Mode) TCCR0 = (Mode) #define Timer0_Cntr(Cntr) OCR0 = (Cntr)
// in mcu_init.h #include
// . TIMSK #define Timer0_Cmp (1
Well, then, when possible, I enable interruptions:
#asm("SEI") It remains to describe the interruption. This is easier than everything before:
#include

interrupt Timer0_Compare (void) ( ++dmsec; )

That's it, the timer is described, configured and running!

Setting for PIC

PR2 = 75 - the value at which the timer will reset and generate an interrupt
T2CON.T2CKPS = 2 - prescaler 1:16
T2CON.T2OUTPS = 0 - without postscaler
T2CON.TMR2ON = on - timer is enabled

IPR1.TMR2IP = 1 --high priority interrupt
PIR1.TMR2IF = off -- reset the interrupt flag
PIE1.TMR2IE = on -- enable interrupt when TMR2 and PR2 coincide
INTCON.GIE = ​​on -- enable interrupt processing

As you can see, the prescaler here is 2 times larger, therefore PR2 is 2 times smaller.
These settings will generate interrupts with a frequency of 10 kHz at a system frequency of 48 MHz (the timer is set to Fosc/4) - the standard frequency for USB Full Speed.

Usage

The code for the client of this timer is cross-platform (except for accessing the value of timer 0 in AVR).
Here is a snippet of the USB sharing code:
#include "main.h" // here is the dmsec variable, next_USB_timeout #include "FT245R.h" // here are functions for working with the USB module #include "..\Protocol.h" // here is the microcontroller-computer exchange protocol // * * // ** Analyze USB packets // ** void AnalyzeUSB (void) ( #define RECEIVE_BYTE(B) while (!FT245R_IsToRead)\ ( if (dmsec > end_analyze) return; )\ B = FT245_ReadByte (); #define RECEIVE_WORD(W) // similar for 2 bytes #define RECEIVE_DWORD(W) // similar for 4 bytes dword end_analyze, d; NewAnalyze: if (!FT245R_IsToRead) // no packets return; end_analyze = dmsec + max_USB_timeout; for the current analysis next_USB_timeout = dmsec + MaxSilence_PC_DEV; // timeout for general exchange RECEIVE_BYTE (b) // packet header switch (b) ( case SetFullState: RECEIVE_DWORD (d); // read the word is_initialized = 1; // process ChangeIndicator () ; break; ) // switch (pack) goto NewAnalyze; #undef RECEIVE_BYTE // cancel #define #undef RECEIVE_WORD #undef RECEIVE_DWORD )
The macro functions RECEIVE_BYTE, RECEIVE_WORD, RECEIVE_DWORD implement reading procedures taking into account the timeout for a given exchange phase. As a result, if something hangs on the other side, the microcontroller will not go into hibernation. Please note - WatchDog is not needed! And all thanks to the variable/constant max_USB_timeout, which sets the timeout with an accuracy of 0.1 milliseconds.
The analysis of “silence on air” using the next_USB_timeout variable is implemented in the same way. This allows the microcontroller 1) to know that the computer has disappeared somewhere, 2) to signal this somehow (in my case, the “error” LED lights up). The MaxSilence_PC_DEV constant/variable allows you to vary the concept of “silence” within the widest range – from a fraction of a millisecond to several days.
All other points are implemented similarly.
If you need to use a microsecond counter, then a comparison function appears there:
#define GetUSec(A,B) ( #asm ("CLI"); A = dmsec; B = TCNT0; #asm ("SEI"); ) // ** // ** Time difference between events accurate to 2/3usec // ** dword Difference (dword prev_dmsec, byte prev_usec) ( dword cur_dmsec; byte cur_usec; ​​dword dif; // . note the current time GetUSec (cur_dmsec, cur_usec); // calculate the difference dif = cur_dmsec - prev_dmsec; dif<<= 8; if (cur_usec < prev_usec) dif += 255 + (dword) cur_usec - prev_usec; else dif += cur_usec - prev_usec; return dif; }
The function is passed the previous point in time - the previous value of dmsec and timer 0.
First, we use the GetUSec macro to stop interrupts so that the value of dmsec and the counter are not corrupted at the time of copying. And copy the current time.
Next, we convert the time difference to a 2/3 microsecond format, taking into account overflow.
Well, let's return this time.
And then we use this in a regular if to control anti-bounce and other measures. Just don’t forget to also pause interrupts when marking the current moment in time - or better yet, use the GetUSec macro.

results

This timer turned out to be an extremely convenient solution for me. I think it will be useful to you too. And I used it in my following projects:
  • Switchboard fencing situations. This is a hefty half-meter board with three controllers - ATmega128 as the central one and ATmega64 as two auxiliary ones (right and left sides). There is no galvanic connection between the three controllers and their components - power supply is based on ionistors, communication through optocouplers. The central controller charges groups of some ionistors and at this time powers both sides from other ionistors. Here we had to create a multi-stage algorithm for switching all this in order to minimize the interconnection. In particular, we are talking about the coordinated work of 8 relays - timers work here for 3.3 ms (guaranteed relay response time). Well, in fact, both sides control 10 relays and about half a hundred multiplexers. All this equipment works with clearly defined time characteristics (with an accuracy of 1 ms, maximum duration is 6 seconds). Well, and, in the end, banal timeout for USB, UART.
  • Depth sensor. Here I am solving another problem (a project in progress). There are two conductors (many meters long) that define the situation “shift up by 1 cm” and “shift down by 1 cm”. There are many ways to set a direction. In any case, these are certain combinations of impulses. Using this timer, I determine bounce and the duration of a stable pulse. The maximum permissible bounce time (10 microseconds is enough here), anti-bounce wait, and minimum/maximum pulse duration are set from the computer. Well, there is a debug mode - the sensor becomes a logic analyzer. This allows you to debug the operation of the line and adjust the coefficients. Well, again timeout, LEDs.
  • Analog signal sensor. A banal 8-channel ADC. Here I use a timer to maintain the necessary pauses.
Dear habra users from other platforms can tell me the initialization code for the corresponding timer, as well as the rules for accessing it - I’ll add it here. It may be necessary to select different times for other platforms. But in any case, it should be something within a few units of microseconds for the timer itself and something a multiple of 100 microseconds for the counter variable. Because, as it turns out, sometimes one millisecond is not enough.

The design is made on only one K561IE16 chip. Since, for its correct operation, an external clock generator is needed, in our case we will replace it with a simple blinking LED. As soon as we supply voltage to the timer circuit, capacitance C1 will begin to charge through resistor R2, so a logical one will briefly appear at pin 11, resetting the counter. The transistor connected to the meter output will open and turn on the relay, which will connect the load through its contacts.


The second trigger of the K561TM2 microcircuit is used here, which is not involved in the first circuit. It is switched on in series with the first trigger, forming a two-bit binary counter, which differs from the “typical” one only by the presence of a delay circuit R3-C2 in the first trigger link. Now the state of the trigger outputs will change according to the binary code. When the power is turned on, both flip-flops are set to the zero state so that this happens, the R input of the second flip-flop is connected to the same input of the first. Now the C1-R2 circuit acts on both flip-flops, resetting them to zero when power is applied. With the first press of the button, trigger D1.1 is set to the single state, and lamp H1 is turned on.

The first counter described below is a random number generator. It can be used to determine the order of moves in various game situations, as a lottery machine, etc. The generator uses integrated circuits of the K155 series. A rectangular pulse generator with an operating frequency of the order of several kilohertz is assembled using elements DD1.1 -DD1.4 of the K155LN1 integrated circuit.


When you press the SB1 toggle switch, the button contacts close and pulses from the generator output follow to the input of the first of 4 series-connected JK flip-flops. Their inputs are switched so that JK flip-flops essentially operate in counting mode. The input of each trigger is connected to the inverse output of the previous one, so they all switch at a fairly decent frequency, and the LEDs HL1...HL4 flash in accordance with it.

This process continues as long as SB1 is pressed. But as soon as it is released, all the triggers will find themselves in some kind of stable state. In this case, only those LEDs that are connected to the outputs of the triggers that will be in the zero state 0 will light up.

Each LED is assigned its own numerical equivalent. Therefore, to determine the winning combination, it is necessary to sum up the numerical values ​​of the lit LEDs.

The random number generator circuit is so simple that it does not require any adjustment and starts working immediately when power is supplied. Instead of JK flip-flops, the K155IE5 binary counter can be used in the design.

The machine has two identical channels, each of which contains a clock generator based on elements DD1.1 - DD1.4 (DD2.1 - DD2.4), a four-bit binary counter DD3, DD5 (DD4, DD6), control circuits based on DD8.1 , DD8.2 (DD8.3, DD8.4), indication units DD10.1 (DD10.2).


The control module (DD7), which implements the “exclusive OR” formula, combines both channels. The operating logic of DD7 is very simple: if two identical logical levels come to the input of an element, then a logical level of 0 is formed at its output, otherwise 1.

When the power is turned on and the “Reset” button (SB1) is pressed, triggers DD3...DD6 switch to the single state and the LEDs go out. In parallel, a logical 1 is formed at the outputs DD8.1 and DD8.3, allowing the start of clock generators. Pulses from their outputs follow to the triggers and provoke their synchronous switching. The corresponding LEDs also flash. The switching speed of the latter can be controlled by resistances R1 and R2 located in the players’ consoles.

If the player, believing that the states of the LEDs of both channels are equivalent, presses the SB2 button. Then a logical zero is formed at the output of the DD8 element, locking the generators and fixing the states of the triggers. Level one is formed at the output of DD8.2 and blocks switching of the trigger to DD8.3, DD8.4 and allows the indication to operate. Thanks to this, you can find out which of the two players will press the button faster.

Logic levels from the inverse outputs of the triggers go to the control unit DD7.1 - DD7.4, where comparison takes place. If they are equivalent, then a logical zero level appears at the outputs of the control node elements.

Inverting DD9.1-DD9.4, it causes a high level to appear at the output of the OR circuit (VD1-VD4). Thus, both units will simultaneously be only at the DD10.1 input. A logical zero is formed at its output and the HL9 LED begins to light, indicating the victory of the player who pressed the SB2 button.

If, when SB2 was pressed, the logical levels were different, then a zero level is formed at the output of the OR circuit. In this case, a single level is supplied only to input DD10.2, and the corresponding LED lights up, indicating the victory of the other player.

The circuit will behave similarly if you press the SB3 button first. The switching time of DD8.1 - DD8.4 is quite low so the possibility of failure is almost eliminated.

The circuit has an automatic power-off unit after half an hour, but if desired, it can be disconnected earlier by touching the sensor with your finger.

To assemble the structure, you need seven transistors and three ICs: K155LAZ, and K155IE8.

The set-top box consists of a sound signaling unit on VT1, VT2 and DD1 - DD3 and a power switching unit on VT3-VT7.


The sound alarm circuit consists of a clock generator on DD1.1, DD1.2 and VT1. It generates rectangular pulses with a repetition rate of about 1 Hz.

After turning on the power, the clock generator begins to send clock pulses, and the reset pulse generated by the circuit R4, C2 resets the counter and the flip-flop that controls the division factor.

The logical one level comes from the sixth output of the trigger DD3.1, and blocks the diode VD1, including the tone generator on DD1.4 and transistor VT2. In parallel, the pulses follow to the tenth input of the DD1.4 element from a clock generator with a frequency of one Hz, turning on and off the tone generator, which generates an intermittent sound signal.

In addition, the logical level 1 coming from output 6 of the trigger sets the counter division factor to sixteen. After the 17th pulse arrives at the counter input, a positive pulse is generated at the output of six DD2, switching DD3.1 to the single state. From output 6, a low level of this trigger blocks the operation of the tone generator and sets the counter division factor to 64. After the arrival of the next 64 pulses, a positive pulse is generated at the counter output, switching the DD3.1 trigger to the zero state. The trigger output enables the tone generator and sets the division factor to sixteen. Thus, the set-top box generates an intermittent tone sound signal lasting 16 seconds every 64 seconds. In this mode, the set-top box can operate until the power is turned off.

The sound alarm circuit is powered through an “electronic switch” and an automatic power switching device, using transistors VT3-VT7. In addition, this module limits the current consumption of the set-top box in standby mode at the microampere level, which makes it possible not to use a mechanical power switch in the design.

To turn on the set-top box, we briefly close points A and B. At the same time, a positive voltage potential goes to the base VT3 through resistance R9 and the composite transistor formed at VT4-VT5 is unlocked, providing a voltage divider current on resistors R10, R11. The voltage drop across R10 and the collector-emitter section VT5 unlocks the composite transistor VT6-VT7.

The supply voltage passes through VT7 to the sound alarm unit. In parallel, through R6, R7 and the collector-emitter section VT3, capacitance C4 is charged. Due to the voltage drop in the capacitance charging circuit, the composite transistor VT4-VT5 is kept open, ensuring the operation of the composite transistor VT6-VT7.

As capacitance C4 is charged, the potential at point R6, VD2, C4, R7 drops and at a certain value, the composite transistor VT4-VT5 is locked, occupied and VT6-VT7 is closed, turning off the power supply circuit for the sound alarm.

The C4 capacity quickly discharges and the set-top box goes into sleep mode. The operating time is set by resistance R6 and capacitance C4, and for the indicated ratings the time is 30 minutes. You can also turn off the power manually by touching the touch contacts E1, E2.

The negative voltage potential, through the resistance of the skin surface and R8, reaches the base of transistor VT3, unlocking it. The voltage at the collector drops sharply and closes the composite transistor VT4-VT5, which closes VT6, VT7.

Everyone knows why a microcalculator exists, but it turns out that in addition to mathematical calculations, it is capable of much more. Please note that if you press the “1” button, then “+” and then press “=”, then with each press of the “=” button the number on the display will increase by one. Why not a digital counter?

If two wires are soldered to the “=” button, they can be used as the input of a counter, for example, a turns counter for a winding machine. And after all, the counter can also be reversible; to do this, you must first dial a number on the display, for example, the number of turns of the coil, and then press the “-” button and the “1” button. Now, each time you press “=” the number will decrease by one.

However, a sensor is needed. The simplest option is a reed switch (Fig. 1). We connect the reed switch with wires parallel to the “=” button, the reed switch itself stands on the stationary part of the winding machine, and we fix the magnet on the movable one, so that during one revolution of the coil the magnet passes near the reed switch once, causing it to close.

That's all. You need to wind the coil, do “1+” and then with each turn, that is, with each turn the display readings will increase by one. You need to unwind the coil - enter the number of turns of the coil on the microcalculator display, and make “-1”, then with each revolution of unwinding the coil, the display readings will decrease by one.

Fig.1. Connection diagram of the reed switch to the calculator.

And, suppose you need to measure a large distance, for example, the length of a road, the size of a plot of land, the length of a route. We take a regular bicycle. That's right - we attach a non-metallic bracket with a reed switch to the fork, and we attach the magnet to one of the spokes of the bicycle wheel. Then, we measure the circumference of the wheel, and express it in meters, for example, the circumference of the wheel is 1.45 meters, so we dial “1.45+”, after which with each revolution of the wheel the display readings will increase by 1.45 meters, and as a result, the display will show the distance traveled by the bike in meters.

If you have a faulty Chinese quartz alarm clock (usually their mechanism is not very durable, but the electronic board is very reliable), you can take a board from it and, according to the circuit shown in Figure 2, make a stopwatch out of it and a calculator.

Power is supplied to the alarm clock board through a parametric stabilizer on the HL1 LED (the LED must have a direct voltage of 1.4-1.7V, for example, red AL307) and resistor R2.

The pulses are generated from the control pulses of the stepper motor of the clock mechanism (the coils must be disconnected, the board is used independently). These pulses travel through diodes VD1 and VD2 to the base of transistor VT1. The alarm board supply voltage is only 1.6V, while the pulse levels at the outputs for the stepper motor are even lower.

For the circuit to work properly, diodes with a low level of forward voltage, such as VAT85, or germanium are required.

These pulses arrive at the transistor switch at VT1 and VT2. The collector circuit VT2 includes the winding of a low-power relay K1, the contacts of which are connected in parallel to the “=” button of the microcalculator. When there is +5V power, the contacts of relay K1 will close at a frequency of 1 Hz.

To start the stopwatch, you must first perform the “1+” action, then use switch S1 to turn on the power to the pulse shaper circuit. Now, with every second, the display readings will increase by one.

To stop counting, simply turn off the power to the pulse shaper using switch S1.

In order to have a count for reduction, you must first enter the initial number of seconds on the microcalculator display, and then do the “-1” action and turn on the power to the pulse shaper with switch S1. Now, with every second, the display readings will decrease by one, and from them it will be possible to judge how much time is left until a certain event.

Fig.2. Scheme for turning a Chinese hanger into a stopwatch.

Fig.3. Scheme of an IR beam intersection counter using a calculator.

If you use an infrared photo sensor that works at the intersection of the beam, you can adapt the microcalculator to count some objects, for example, boxes moving along a conveyor belt, or, by installing the sensor in the aisle, to count people entering the room.

A schematic diagram of an IR reflection sensor for working with a microcalculator is shown in Figure 3.

The IR signal generator is made on an A1 chip of type “555” (integrated timer). It is a pulse generator with a frequency of 38 kHz, the output of which is connected via a switch to an infrared LED. The generation frequency depends on the C1-R1 circuit; when setting up by selecting resistor R1, you need to set the frequency at the output of the microcircuit (pin 3) to close to 38 kHz. The HL1 LED is placed on one side of the passage, putting an opaque tube on it, which must be precisely aimed at the photodetector.

The photodetector is made on the HF1 chip - this is a standard integrated photodetector of the TSOP4838 type for remote control systems for TVs and other home appliances. When a beam from HL1 hits this photodetector, its output is zero. In the absence of a beam - one.

Thus, there is nothing between HL1 and HF1 - the contacts of relay K1 are open, and at the moment of the passage of any object, the relay contacts are closed. If you perform the “1+” action on the microcalculator, then with each passage of an object between HL1 and HF1, the microcalculator display readings will increase by one, and from them you can judge how many boxes were shipped or how many people entered.

Kryukov M.B. RK-2016-01.

If you are faced with the task of implementing a pulse counter, counting tens, hundreds or thousands, then for this it is enough to use a ready-made assembly - the CD4026 microcircuit. Fortunately, the microcircuit practically eliminates all worries about wiring the microcircuit and additional matching elements. At the same time, one CD4026 counter is capable of “counting” only up to 10, that is, if we need to count up to 100, then we use 2 microcircuits, if up to 1000, then 3, etc. Well, let's say a few words about the chip itself and its functionality.

Description of operation of the CD4026 counter

Initially, we present the appearance and functional designation of the pins on the counter chip

Despite the fact that everything is in English, in principle everything here is clear! The counter readings increase by 1 unit each time a positive pulse arrives at the “clock” contact. In this case, a voltage appears at outputs a-g, which, when applied to a 7-segment indicator, will display the number of pulses.

The “reset” contact resets the counting readings when shorted to +.

The "disable clock" pin must also be connected to ground.

The “enable display” contact, in fact, contact 3 must be connected to the positive.

Contact “÷10” is actually output 5, sends a signal about the counter overflow, so that a similar counter can be connected to it and start counting for 10, 100, 1000...

The “not 2” contact takes the value LOW if and only if the counter value is 2. Otherwise, HIGH.

The operating supply voltage of the microcircuit is 3-15 V. That is, it has a built-in stabilizer. Now let’s talk about how to connect this microcircuit to the assembly, that is, about the circuit diagram.

Connection diagram for a pulse counter on a CD4026 chip

Take a look at the diagram. It counts light pulses of changes in resistance for a photoresistor. As a photoresistor, you can use, say, a 5516 photoresistor. So, due to a change in resistance, the potential at the base of the transistor also shifts. As a result, current begins to flow through the collector-emitter circuit, which means a pulse is supplied to input 1 of the microcircuit, which must be counted.
As soon as the first microcircuit counts 1 ten, then one pulse appears at pin 5 indicating the “overflow” of the counter. Ultimately, this impulse is supplied to a second microcircuit, which operates on exactly the same principle. But in this case, the microcircuit no longer counts units, but tens. If you add 3 microcircuits, then it will be hundreds, etc.

To reset to 0, just apply a plus to the legs of 15 microcircuits. The microcircuit is designed to work with a 7 segment indicator. When applied to one of the outputs of this indicator, we get the number we need. Take a look at the table...

In conclusion, I would like to say once again that the pulse counter in this case is functional and will require minimal costs and knowledge from you. What is also important is that the circuit does not need to be configured, at least the digital part. The only thing is that you may have to “play around” with resistors and a photoresistor at the input.

Did you like the article? Share it