Abstract: The introduction uses the Intel8253 microcomputer interface circuit to have the pulse width modulating wave, and uses the L298N bridge-type driver, realizes to direct current machine’s one simple effective PWM velocity modulation method.
Key word: Intel8253; L298N: Pulse width modulation: PWM
1 introduction
The pulse width modulation (Pulse Width Modulation-PWM) will be refers to the output signal fundamental period to be fixed, action cycle’s size will control the output through the adjustment fundamental period. The principle is switching valve’s in one cycle breakover time is t, the cycle is T, then electrical machinery both sides average voltage U=Vcc t/T=aVcc. And, a=t/T (dutyfactor), Vcc is the supply voltage. Electrical machinery’s rotational speed and the electrical machinery both sides’ voltage becomes the proportion, but the electrical machinery both sides’ voltage and the control profile’s dutyfactor is proportional, therefore electrical machinery’s speed and the dutyfactor become the proportion, the dutyfactor are bigger, electricity turning point quicker.
PWM often substitutes for number/mold switch (DAC) to use in the power output control, the direct current machine and alternating current machine’s speed control is the most common application. Usually PWM coordinates the bridge-type driving circuit to realize the direct current machine velocity modulation, is simple, and the governor deflection is big.
Figure 1
2 Intel8253 internal structures and working pattern
2.1 Intel8253 internal structures
Intel8253 is the microcomputer periphery interface circuit, the interior contains 3 each other independent 16 subtraction counter. Each counter may by the software determination be 16 binary subtraction counter or the decimal base 4 BCD subtraction counter. Each counter has 6 kind of different working patterns, also determined by the software. Each counter has clock input end (CLK), gating signal input end (GATE) and out-port (OUT). Read-write by A1. Pins and so on A0, RD, WR and CS control, mainly uses to control Intel8253 the data and the order reads, reads and forbids. In Intel8253 pin arrangement like chart l U3 shows.
2.2 and PWM related working pattern
With the PWM related working pattern is pattern l and the pattern 2.
(1) pattern 1
When some counter establishes after the pattern 1, the microcomputer may send in through two output orders 16 bit data M this counter. By now this counter’s out-port and did not have any response. Once this counter’s gating input end pulse rise along at the appointed time, its out-port outputs a width is the MT negative going pulse immediately, as shown in Figure 2.
(2) pattern 2
When some counter establishes after the pattern 2, the microcomputer may through two output orders 16 bit dataⅣSends in this counter. After the output order had ended, this counter outputs the cycle is the NT continual square-wave immediately, as shown in Figure 3.
If 0 and the counter 1 establishes separately 8253 counters in the pattern 2 and the pattern 1, and the connection according to shown in Figure 4, may obtain a very simple pulse-duration modulation generator. Before the work starts, first constantⅣSends in the counter 0, sends in again constant M counter 1 (M<N), therefore the counter 0 will output the cycle will be the NT continual square-waves. The counter 1 gating input end every other NT time receives one time is jumping the signal. Therefore, every other NT time counter l will output a width will be the Mr negative going pulse. Therefore, through changes M and N may obtain a dutyfactor adjustable PWM wave.
2.3 PWM procedures
The Intel8253 read-write control logic by pins and so on A1, A0, RD, WR and CS controls, port select signal A1, A0 decided that 3 counters, which do control in the register to carry on the work, A1, A0:00-10 the CPU choice add a #2 counter to carry on read/write, 11 CPU reads in the control word Intel8253.
The Intel8253 control register is as follows:
|
SC1 |
SC0 |
RW1 |
RW0 |
M2 |
M1 |
M0 |
BCD |
M2, M1, MO:000-101 choice working pattern 0-5
SCl, SC0:00-10 choice counter #o-#2,11 returns reads the order
The BCD:0 correspondence binary system counting, 1 corresponds the BCD counting
RWl, RW0:00 locks in the counter stable reading, 01 read-only/write the low 8 bytes, 10 read-only/write the high 8 bytes, 1l reads first/writes the low 8 bytes, latter reads/writes the high 8 bytes.
…….
mov dptlr,#Ofe03h: To 8253 control register initialization
nov a,#34h choice counter 0, working patterns 2
after movx@dotr, a reads first/writes low 8, reads/writes high 8
mov dptr,#0fe00h: 0 deliver low 8 bit data 80H to the counter
nov a,#80h
movx@dptr, a
mov dptr,#0fe00h: 0 deliver high 8 bit data 00H to the counter
nov a,#00h
movx@dptr, a
nov dotr,#Ofe03h: To 8253 control register initialization
mov a,#72h choice counter 1, working pattern l
movx@dptr’, a
mov dpu,#0fe01h; 1 delivers low 8 bit data 20H to the counter
nOV a,#20h
movx@dptr, a
nov dptr,#Ofe01h: 1 delivers high 8 bit data 00H to the counter
nov a,#00h
movx@dptr, a
……
According to the above procedure, may obtain the dutyfactor is
a=t/T=0020H/0080H=25%
Likewise. 0 and the counter 2 establish separately the Intel8253 counter in the pattern 2 and the pattern 1, and connection method may also obtain another PWM2 according to Figure 4.
3 L298N driver’s principle and application
L298N is the SGS Corporation’s product, the interior contains 4 channel logic driving circuit. Is one kind of two phase and the four-phase electrical machinery’s special-purpose driver, namely contains two H bridge’s high voltage big electric current complete in both bridge-type driver, the receive standard TTL logic level signal, may actuate 46V, the 2A following electrical machinery. Its pin arrangement like chart 1 U4 shows, 1 foot and 15 feet may draw out the connection electric current sampling resistor alone, forms the electric current sensing letter
Table 1 1298N logical function
|
ENA(B) |
INl(IN3) |
IN2(IN4) |
Electrical machinery operational aspect |
|
H |
H |
L |
Clockwise |
|
H |
L |
H |
Reverse |
|
H |
With IN2(IN4) |
With INl(IN3) |
Fast stop |
|
L |
X |
X |
Stop |
Number. L298 may actuate 2 electrical machinery, between OUTl, OUT2 and OUT3, OUT4 meets 2 electric motors separately. 5th, 7, 10, 12 feet meet the input control level, controls the electrical machinery the reverse, ENA, ENB is meeting the control to enable the end, controls the electrical machinery to stop the extension. 1298 logical function like table 1 arranges in order.
As shown in Figure 1: Intel8253 outputs two group of PWM waves, each group of PWM wave uses for to control an electrical machinery’s speed. Other two I/O mouth may control the electrical machinery the reverse. The control method and the control circuit are quite simple. Namely P10, P11 control the first electrical machinery’s direction, the input: PWMl controls the first electrical machinery’s speed; P12, P13 control the second electrical machinery’s direction, input PWM2 control the second electrical machinery’s speed.
Because electrical machinery in normal work time is very big to power source’s disturbance, only uses when group of power sources will interfere with monolithic integrated circuit’s normal work. Therefore selects the double power source power supply. A group of 5V power source for the monolithic integrated circuit and the control circuit power supply, other group of 5V, the 9V power source gives L298N VSS, the VS power supply. Uses up the pair in the control section and between the motor-driven part to separate, in order to avoid influence control section power source’s quality.
Figure 1 is one realizes the intelligent compact car’s application electric circuit. D1, Q1 are a pair of infrared emission receive to the tube, with LM324 constitution electro-optic sensing examination electric circuit. May realize automobile’s acceleration, the deceleration through Intel8253 and 1298N, to check stop, and may realize counterclockwise and functions and so on right-turn through two electrical machinery’s different rotational speeds.