Application of 8253 in automatic counting system of production line

Publisher:龙爱泉也Latest update time:2014-01-04 Source: hqewKeywords:Counters Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  In factory automation systems, it is often necessary to quantitatively package products or count the number of certain products produced on the assembly line at any time. To meet the needs of factory automation, we have designed an automatic counting system using microprocessors and chips such as 8253. This system has a simple circuit and low cost, and is suitable for use by small and medium-sized enterprises. 8253 is a programmable counter/timer with three independent 16-bit counter/timer channels inside. Each counter channel can work in 6 different ways and can count in binary or decimal. Its CLK0~CLK2 is the clock pulse input terminal of counter 0~2, GATE0~GATE2 is the gate pulse input terminal, and OUT0~OUT2 is the output terminal (see Figure 1). When 8253 is used as an external event counter, the counting pulses added to the CLK terminal are generated by external events, and the intervals of these pulses may not be equal. If it is to be used as a timer, an accurate clock pulse should be input to the CLK terminal. At this time, the timing time that 8253 can achieve is determined by the frequency of the counting pulse and the initial value of the counter. Timing time = clock pulse period tc × preset counting initial value n.
  The control logic of 8253 consists of 5 control signals and A0. The corresponding operations are shown in Table 1.

?

  RL1, RL0——Read/write operation bit. 00 means latched data, and the count value in the counter can be read at any time; 01 means read/write only the lower 8 bits, and the upper 8 bits are automatically set to 0; 10 means read/write only the upper 8 bits, and the lower 8 bits are automatically set to 0; 11 means read/write 16-bit data, first the lower 8 bits, then the upper 8 bits.
  M2, M1, M0——Working mode selection bit. 0~5 means modes 0~5. Mode 0, interrupt after counting; Mode 1, programmable single trigger operation; Mode 2, frequency division pulse generation; Mode 3, frequency division square wave generation; Mode 4, software trigger strobe; Mode 5, hardware trigger strobe. The working process of mode 0 is as follows: when the program sends a control word to put the selected counter in the set mode, the output of the counter is low; when the initial value of the counter is loaded into the selected counter, under the control of the external input gate high level, it can count down through the respective count pulses. At this time, its output is still "low". When the counter is reduced from the initial value to all "0", a high level output is generated, and this output signal is used to send a count-complete interrupt to the CPU; this interrupt request is maintained until the program loads the initial value into the counter again.
  BCD - counting mode selection bit. 1 means counting in decimal, and 0 means counting in binary. The circuit using the 8253 counting function is shown in Figure 1.

  When there is no workpiece passing between the LED light-emitting tube and the phototube, the light emitted by the LED can shine on the phototube, making the phototube conductive and the collector low. This signal is driven and shaped by 74LS14 and sent to CLK1 of 8253, making CLK1 of 8253 also low. When a workpiece passes between the LED light-emitting tube and the phototube, the light emitted by the LED is blocked by the workpiece, the phototube is cut off, the collector becomes high, and CLK1 of 8253 is also high. After the workpiece passes, CLK1 returns to low level. In this way, every time a workpiece passes, a positive pulse is input from CLK1. By counting this pulse by 8253, the number of workpieces can be counted.
  A1 and A0 of 8253 are connected to A2 and A1 of CPU address bus respectively. GATE1 is connected to +5V, and OUT1 is connected to an interrupt request input terminal IR2 of 8259A or an external interrupt input of 51 single-chip microcomputer as interrupt signal INT. The port addresses of 8253 designed in this system are 0350H, 0352H, 0354H, and 0356H respectively.

  When programming, you can choose counter 1 to work in mode 0. In the mode 0 working mode of 8253, there is a clock pulse delay from writing the initial count value into the counter to starting to count down by 1. If the initial count value is n=999, then after n+1, that is, 1000 pulses, the count value is reduced to 0, and a positive jump is output at the OUT1 terminal, which can be used as an interrupt request. In the interrupt service subroutine, the CPU can do other processing, such as sending the next package box.
  The initial value of the design number is 1999 (a package box is required to contain 2000 workpieces). Count in decimal, send the lower 8 bits first, then the upper 8 bits, and the control word is 01110001B.
  The initialization program is:
  MOV AL, 01110001B
 

  If we want to know how many workpieces are in the box before it is full in the automatic counting system, we can use the data latch function of 8253; since 8253 is a minus 1 counter, we can read the current value of the counter, and then subtract the current value from the full value to get the number of workpieces in the current box.
  At this time, the mode control word is 01000000B, and the program to achieve the above function is:
  

Keywords:Counters Reference address:Application of 8253 in automatic counting system of production line

Previous article:Measures for Cutting Off Interference Propagation Paths in Single-Chip Microcomputer Circuit Design
Next article:Intelligent sulfur determination instrument based on single chip microcomputer design

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

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号