Application of 8253 in automatic counting system of production line

Publisher:SereneHarmonyLatest update time:2012-03-23 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Application of 8253 in automatic counting system of production line

This paper introduces an automatic counting system for production lines based on counter/timer 8253, and describes in detail the design principles and implementation methods of the system's software and hardware.
Keywords: counter/timer; automatic counting system

Application of 8253 in Automatic counting System of Pro duct Line
LI Lei, XUE Jianbo
(Henan Normal University, College of Physics and Information Engineering, XinXiang 453002, China)
Key words: counter/timer; automatic?counting system
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 small and medium-sized enterprises.
8253 is a programmable counter/timer with three independent 16-bit counter/timer channels. Each counter channel can work in 6 different ways and can count in binary or decimal. Its CLK0~CLK2 are the clock pulse input terminals of counters 0~2, GATE0~GATE2 are the gate pulse input terminals, and OUT0~OUT2 are the output terminals (see Figure 1). When 8253 is used as an external event counter, the count 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 depends on the frequency of the count pulse and the initial value of the counter, that is
,? Timing time = clock pulse period tc × preset count initial value n
The control logic of 8253 consists of 5 control signals and A0, and 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 decremented 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:
Reference address:Application of 8253 in automatic counting system of production line

Previous article:Vortex Flow Signal Processing Based on Spectral Analysis
Next article:Punching large circular holes in laminate

Latest Analog Electronics Articles
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号