Application of the counters

By Omron Automation and Safety 976

Application of the counters

In logic algebra and computer operations, a counter is a device that stores the number of occurrences of a particular event or process, often associated with a timer signal. The most common type is a sequential logic circuit with a "clock" input line and multiple output lines. The value of the output line represents the number in binary or BCD counting system. Each pulse applied to the clock input either increments or decrements the counter.

 

Counting is one of the simplest basic operations. The counter is the logic circuit to realize this kind of operation. The counter mainly counts the number of pulses in the digital system to realize the functions of measurement, counting and control. At the same time, it also has the function of frequency division. The counter is composed of the basic counting unit and It is composed of some control gates, and the counting unit is composed of a series of various types of flip-flops with the function of storing information. These flip-flops include RS flip-flops, T flip-flops, D flip-flops, and JK flip-flops.

 

A counter circuit is usually formed by cascading multiple flip-flops. Counters are used extensively in digital circuits, both as integrated circuit chips and as part of larger integrated circuits.

 

Ⅰ. The trigger type of the counter

 

1. RS trigger

 

An RS flip-flop is a basic digital electronic logic element used to store the state of a bit. It consists of two complementary inputs (R and S) and two outputs (Q and ~Q).

 

R stands for Reset and S stands for Set. When R and S are low at the same time, the RS flip-flop maintains its current state. When R is high and S is low, the RS flip-flop resets its state to 0. When R is low and S is high, the RS flip-flop sets its state to 1. The behavior of the RS flip-flop when both R and S are high is undefined and should be avoided.

 

2.T flip-flop

 

A T flip-flop is a basic digital logic element used to store and control the state of a bit. It is a special form of RS flip-flop with a single input (T) and two outputs (Q and ~Q).

 

The input T of the T flip-flop is called the "Toggle" input. When T is low, the T flip-flop keeps its current state unchanged. When T is high, the output state of the T flip-flop will flip (from 0 to 1, or from 1 to 0).

 

3.D flip-flop

 

D flip-flop (D flip-flop) is a basic digital logic element used to store and control the state of a bit. The input terminal D of the D flip-flop is used to input data. When D is low, the D flip-flop keeps its current state unchanged. When D is high, the output state of the D flip-flop will be updated to the input value.

 

4. JK flip-flop

 

The inputs J and K of a JK flip-flop are called the "activate" inputs. When J and K are low at the same time, the JK flip-flop keeps its current state unchanged. When J is high and K is low, the output state of the JK flip-flop will flip (from 0 to 1, or from 1 to 0). When J is low level and K is high level, the output state of the JK flip-flop will also flip. The behavior of the JK flip-flop is undefined when both J and K are high and should be avoided.

 

Ⅱ. Working principle of the counter

 

A counter is a digital circuit used to record and display the number of discrete events. It can be incremented or decremented according to the specified rules, and can be reset to the initial value under certain conditions.

 

A common counter is a binary counter, which represents the count value in binary. A binary counter consists of multiple flip-flops (such as D flip-flops or JK flip-flops), each of which represents a binary bit.

 

Ⅲ. Function of the counter

 

1. Timing control: The counter plays a key role in the timing control circuit. It can be used to generate specific timing signals, such as the frequency division ratio in a clock divider, to control the operating speed of the system by dividing the clock signal into a lower frequency signal. Counters can also be used to generate periodic pulse signals, sequence control, state transitions, etc. The most widely used sequential logic circuit in digital electronic technology. Counters can not only be used to count clock pulses, but also can be used for frequency division, timing, generation of beat pulses and pulse sequences, and digital operations. However, the calculation results cannot be displayed, and generally can only be displayed through an external LCD or LED screen.

 

2. Counting function: The most basic function of the counter is to record and represent the number of discrete events. It can be incremented or decremented according to the specified rules, and the count value can be displayed in some form. Counters can be used to count the number of devices, the time unit of a timer, the number of events from a motion sensor, etc.

 

3. Position and step control: The counter can be used in position and step control systems. For example, in robot control, a counter can track the number of steps a robot takes to determine its position and motion. In stepper motor control, a counter is used to control the number of steps and direction of rotation of the stepper motor.

 

4. Frequency measurement: The counter can be used to measure the frequency of the signal. By inputting a signal into a counter, the counter records the number of pulses of the signal within a certain time, and then calculates the frequency of the signal. This is very useful in the field of test and measurement, such as audio, wireless communication, electronic equipment testing and so on.

 

5. Memory addressing: The counter can be used for memory addressing and access control. In a memory system, a counter can be used as an address generator to generate different address signals to access data in the memory.

 

Ⅳ.Application field of counter

 

1. Counters are used to measure time, such as in devices such as timers, stopwatches, clocks, and timers. They can accurately record elapsed time and provide timing control functions.

 

2. The counter can be used to track the number of steps and control the movement of the stepper motor. They are widely used in areas such as robot control, automation and position detection.

 

3. The counter can be used to measure the frequency and period of the signal. They are used for frequency measurement and time measurement in the fields of electronic measuring instruments, wireless communication equipment, audio equipment, etc.

 

4. The counter can be used as a frequency divider to divide high frequency signals into lower frequency signals. This is common in communication systems, digital circuits, and is used to reduce clock frequency, divide signals, and generate different frequency timing signals.

 

5. The counter can be used as an address generator for access control in memory systems. They are used to generate a sequence of memory addresses such that data in memory can be read or written sequentially.

 

6. Counters can be used to implement state machines and sequence control logic. Certain state transitions and control actions can be triggered by incrementing or decrementing the value of the counter.

 

7. Counters can be used to count the number of occurrences of a particular event. For example, counters can be used to count the usage time of electronic equipment, the number of vehicles passing by, the number of events detected by sensors, etc.

 

Ⅴ.Counters & Tachometers

 

Counters can be used to measure the rotational speed of rotating objects. By using a sensor to detect the pulse signal generated by the object every revolution or every fixed angle, the counter can record the number of these pulses and calculate the rotational speed. By measuring the time interval and number of pulses, the value of the rotational speed can be obtained.

 

A tachometer is a special counter designed to measure and display the rotational speed of an object. It usually includes a sensor to detect the pulse signal generated by the rotating object, and input these pulses into the internal counter. The tachometer continuously records the number of pulses and calculates the tachometer according to a preset time interval. Results can be shown on the tachometer's display in units of revolutions per minute (RPM) or revolutions per second.

 

Tachometers are often used for engine speed measurement of vehicles, speed monitoring of rotating equipment, operating speed monitoring of fans, motors and other equipment. They provide a convenient and accurate method of measuring the velocity of rotating objects and are used in a wide variety of industrial, mechanical and vehicular applications.

 

Ⅵ. Types of counters

 

1. Asynchronous counter

 

The simplest asynchronous counter is a D flip-flop with an inverted output fed back to the D input. The circuit can store one bit, so it can count from zero to one before it overflows (restarts from 0). The counter increments every clock cycle and overflows two clock cycles, so it transitions from 0 to 1 and 1 to 0 every cycle. The asynchronous counter generates a new new clock at half the frequency of the input clock with a 50% duty cycle.

 

Asynchronous counters are characterized in that the clock input of each flip-flop is directly connected to the output of the previous flip-flop. When the output of a flip-flop changes, it immediately affects the counting state of the next flip-flop.

 

There are a few issues with asynchronous counters to consider. Due to the different delays of the cascaded flip-flops, it may cause the counter to generate a short-term unstable state during the counting process. This unstable state is called the "ripple" effect of the counter and can cause errors or impulse noise on the counter output. To solve this problem, the unstable state can be eliminated or suppressed by adding appropriate logic gates.

 

2. Ring counter

 

A ring counter is a special counter whose counting status is circulated among flip-flops to form a ring structure. In a ring counter, the output of each flip-flop is connected to the input of the next flip-flop, and the output of the last flip-flop is connected to the input of the first flip-flop, forming a ring loop.

 

A ring counter is a circular shift register in which only one of the flip-flops is a high output, and the rest are low outputs. The shift register is formed by cascading flip-flops. If the output of the last flip-flop is connected to the input of the first flip-flop, a ring is formed.

 

The characteristics of the ring counter include: it is composed of multiple flip-flops cascaded without complicated logic circuits; the counter can count in an infinite loop, thereby realizing continuous counting operations; the counting order of the ring counter is determined by the way the flip-flops are connected, which may not be conventional sequence of binary counts.

 

3. Johnson register

 

A Johnson register is a special type of counter. Johnson counters, also known as tail-switched ring counters, twisted ring counters, and walking ring counters, are modified ring counters in which the output of the last flip-flop is inverted and then connected to the first trigger.

 

The initial state of the Johnson counter is defined by the user. The output of only one flip-flop is 1, and the output of the rest of the flip-flops is 0. This 1 will move in a circular fashion in the counter. When the flip-flop's clock signal arrives, the output of the current flip-flop is passed to the input of the next flip-flop. However, unlike a general ring counter, the input of the next flip-flop of the Johnson counter is obtained by connecting the outputs of multiple flip-flops through an XOR logic gate. This connection makes the counting order of the Johnson counter different from that of the binary counter. When the counter reaches its maximum value, i.e. when the output of the last flip-flop is 1, its output is fed back to the input of the first flip-flop. In this way, the counter will continue to count cyclically, realizing counting in an infinite loop.

 

4. Decimal counter

 

A decimal counter is a system for counting in decimal form. It is capable of incrementing or decrementing from 0 to 9 and expresses the count value in decimal digits.

 

Each digit of the decimal counter needs to count from 0 to 9, and then return to 0. The general binary four-digit counter can count one digit in decimal. If the counting method of binary code decimal is used, just like the picture on the right Add NAND gate, its input is FF2 and FF4, and the output is the CLR input of each gate. For each pulse signal, the counter will add 1. When added to binary 1010 (decimal 10), all gates will be cleared to zero. This signal is also a carry signal after processing, indicating that it has counted to ten.

 

A decade counter usually consists of four binary counters, each representing a decimal bit. These four binary counters are usually called BCD (Binary Coded Decimal) counters. Each BCD counter is capable of counting numbers from 0 to 9.

 

5. Synchronous counter

 

A synchronous counter is a type of counter that updates the count value synchronously based on a clock signal. Unlike the asynchronous counter, the counting operation of the synchronous counter is controlled by the clock signal, so that the counting is performed on a specific clock edge or the rising/falling edge of the clock pulse.

 

The initial state of the synchronization counter is user-defined. The output of each flip-flop represents a binary bit, which can be set to an arbitrary initial value. Synchronous counters receive an external clock signal as input to control the counting operation. The clock signal is usually a periodic square wave signal. The counting rule of the counter is determined by the connection mode of the flip-flop and the logic circuit. A common synchronous counter is a binary counter, where each flip-flop represents a binary bit. Depending on the rules, the counter can be incremented or decremented in binary.

 

6. Preset counter

 

A preset counter is a special type of counter with the ability to preset an initial count value. Unlike normal counters, preset counters allow the count value to be set to a specific predefined value before counting starts.

 

Preset counters contain one or more additional inputs, called preset inputs. The preset input allows the user to pre-enter a specific count value into the counter. When the preset input signal receives the preset value, the count value of the preset counter is immediately updated to the preset value. This allows the counter to start counting from a specified initial value instead of zero.

 

 

Frequently Asked Questions

 

1. What factors affect the working speed of the counter?

 

The operating speed of the counter is limited by the clock frequency; the design and implementation of the counter will affect its logic delay; the counting scale and number of bits of the counter will also affect the operating speed; changes in ambient temperature and power supply voltage may affect the performance and speed of the counter .

 

2. How to implement a down counter?

 

In binary counters, negative numbers can be represented using two's complement. When the counter reaches 0, the decrement is achieved by inverting the counter's complement. The counter must be set to the complement of the maximum value before the decrement operation.

 

The output of the flip-flop using an asynchronous counter is connected inversely. Similar to a synchronous counter, counting down is achieved by connecting the output of each flip-flop to the inverting input of the next flip-flop.

 

3. How to solve the counter overflow problem?

 

By increasing the number of bits in the counter, the counting range of the counter can be extended, thereby delaying the occurrence of overflow. For example, expanding from a 4-bit counter to an 8-bit counter increases the counting range to larger values and reduces the chance of overflow.

 

By means of software or hardware, limit the counting range of the counter to avoid overflow. For example, in a specific application scenario, the maximum and minimum values of the counter can be set, and when the counter reaches these values, stop counting or take other measures.

Categories

Top