Home > Basic Circuits >Logic Circuits > Presettable 8-bit counter circuit

Presettable 8-bit counter circuit

Source: InternetPublisher:黄土马家 Keywords: counter Updated: 2024/10/14

Figure 2 is the logic structure of 74LS164. It has two serial data input terminals, which can be used in parallel, or one of them can be used as a data input enable terminal. The input serial data is shifted and latched at the rising edge of the clock.

Figure 3 shows the pinout of 74LS164. The pin functions of 74LS164 are: A1 and A2 are serial data input terminals, QA to QH are 8-bit parallel data output terminals. The rising edge of the clock input terminal is valid, and the falling edge of the reset terminal is valid.



    
  

The tasks completed by the AT89S51 microcontroller are: (1) Scan the keyboard to obtain the required preset data. (2) Send the count value to the 8-bit LED display for static display. (3) Perform output control.

Software design ideas and solutions

First, check whether the keyboard is pressed. If it is pressed, the key flag is 1, otherwise it is 0. Then check the s9 key. If the s9 key is pressed, the working flag set_flag is inverted (0 or 1). Later, the program counts, displays the count, controls the output, or scans the keys S1 to S8, displays the preset value, etc. according to the working flag. In this design, keys S10 to S16 are not used. For programming convenience, the 8-bit count value and the 8-bit preset value are

The values ​​are stored in 8 variables. Although the RAM utilization is not high, it is easy for beginners to understand. When the preset value is displayed, the decimal point of the lowest digital tube on the display is lit to show the difference with the displayed count value. When the count value is equal to the preset value, the output (P3.4) is activated to control the load (motor, etc.) to act. Figure 4 is the main program state flow.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号