EM78P447S MCU and its infrared remote control in DC motor
1 Main features of EM78P447S
The EM78 series of single-chip microcomputers are 8-bit cost-effective single-chip microcomputers manufactured by Taiwan Elan Electronics Co., Ltd. using CMOS technology. This series of microcontrollers generally have built-in watchdog counter (WDT), RAM, ROM, programmable timer/counter, prescaler and 5-layer stack. Most commands of this series of devices only require two oscillation cycles, and at the same time have internal and external interrupts, low-voltage detection reset, programmable I/O, internal pull-up resistors and open collector output, SLEEP mode and other functions. In addition, the EM78P447S microcontroller has the advantages of simple programming, fast speed, low power consumption, and low cost, and can be widely used in toys, home appliances, industrial control, etc.
The main performance characteristics of EM78P447S are as follows:
●Working voltage range: 2.5-5.5V;
●Permissible temperature range: 0-70℃;
●Operating frequency range:
Quartz oscillator type: the range at 5V is DC-20MHz,
The range at 3V is DC-8MHz;
RC oscillator type: the range at 5V is DC-4MHz,
The range at 3V is DC-4MHz;
●One-time programmable ROM up to 4k×13bit;
●The internal RAM is 148×8bit;
●With 5 layers of stack;
●Contains a watchdog timer (WDT) that can be programmed by yourself and an 8-bit prescaler;
●With 24 bidirectional tri-state I/O pins;
●I/O in sleep state can be planned;
● There are ten
TCC: External counting input pin;
OSCO: Oscillation output pin; VDD: Positive power input pin;
OSCI: Crystal oscillator or RC oscillator input pin;
NC: empty foot;
RESET: Reset input terminal, active low;
VSS: ground pin;
INT: External interrupt input pin, the falling edge input is valid;
P50~P57: Bidirectional I/O pin;
P60~P67: Two-way I/O pins, which can be programmed with internal boost resistance through software;
P70~P77: Bidirectional I/O pins, among which P74 and P75 can be programmed with internal boost resistance through software; P76 and P77 can be set as open collector output pins through software; P70 and P71 can be used as R-Option Input pin.
I/O pins with lifting resistance and waking up the CPU;
●There are two I/O pins with R-Option function. When two or more application programs are put into the same single-chip microcomputer through R-Option function, the same input pin can be used to judge which program to choose. In other words, the R-Option function is to set selectable pull-down resistors on two I/O pins of EM78P447S, so as to determine the state of the pin by whether the user connects a pull-down resistor (usually 510kΩ), and then determine which one is running A program
●There are two output pins that can be programmed as open collector;
●The signal source and trigger source can be selected through an 8-bit timer/counter (TCC), and 8-bit prescaler can be performed;
●With overflow interrupt function;
●It has functions such as power-on reset, low-level detection reset, RESET pin input low-level reset, and WDT timeout reset;
●Most instructions only need two oscillation cycles;
●With low-level sleep mode;
●With TCC overflow interrupt, external INT pin input pulse interrupt and execution of INT instruction software interrupt function;
●Use 32-pin DIP package.
2 Pin function and register of EM78P447S
2.1 Pinout of EM78P447S
Figure 1 shows the pin arrangement of EM78P447S. The functions of each pin are as follows:
2.2 Registers in EM78P447S
EM78P447S contains 9 operational registers. Among them, indirect addressing register R0 (IAR), timer/counter R1 (TCC), program counter R2 (PC), status register R3 (STATUS), RAM selection register R4 (RSR), I/O port register R5 (PORT5), The addresses of 8 registers, such as R6 (PORT6) and R7 (PORT7), are respectively 00H to 07H in order, while the address of the interrupt status register R3F (ISR) is 3FH.
Among the 148 general-purpose registers (RAM) of the EM78P447S, there are registers with addresses from 08H to 1FH and 4 register banks with addresses from 20H to 3EH (4 page addresses are determined by bit 6 and bit 7 of R4).
In addition, there are 7 special function registers in EM78P447S. Including accumulator A, control register CONT, input / output control registers IOC5, IOC6, IOC7 (respectively control port5, port6, port7 input / output mode), WDT control register IOCE and interrupt mask register IOCF.
2.3 Introduction to EM78P447S instructions
The EM78P447S MCU has 45 single words and 58 instructions. These 58 instructions include 19 logic instructions, 11 arithmetic instructions, 4 bit instructions, 4 transfer instructions, 10 control instructions, and 10 jump instructions. Table 1 shows the classification of these instruction words by function.
The commands of EM78P447S microcontroller mainly have the following features:
●Except for the instruction to change the program counter, which requires two instruction cycles, the remaining instructions are all single instruction cycles;
●Each bit of the register can be directly set, cleared or tested by bit-type instructions;
●I/O registers corresponding to IO pins can also be accessed as general registers. In other words, the instructions used to access general registers and I/O are exactly the same.
3 Application in DC motor remote control system
The remote control system designed with EM78P447S as the main controller can realize the remote control of the forward, reverse and stop of the DC motor. The remote control system consists of three parts: transmitting module, receiving input module and single-chip processing output module.
3.1 Launch module
The transmitter module in the remote control system designed by the author adopts 3V working voltage. There are three ping-pong keys K0, K1, K2 on the circuit board, which can be used to control the forward, reverse and stop operation of the motor. When it is necessary to transmit, use the dedicated chip PT2248 and the peripheral amplifier circuit to amplify the signal, and then infrared emission can be carried out. Its hardware circuit schematic diagram is shown as in Fig. 2.
3.2 Receiving input module
The receiving module in this remote control system uses 5V working voltage, and there is a receiver on the circuit board, which can be used to receive the signal transmitted by the transmitting module. An amplifier circuit can be used to amplify the received signal and transmit it to the receiver dedicated chip PT2249A, and then send it to the single-chip microcomputer after processing by 74LS04. Three LEDs can be used to respectively correspond to the three buttons of the transmitting module to display the operation. When a certain key is pressed, the corresponding light-emitting diode glows. Its hardware circuit is shown as in Fig. 3.
3.3 Single-chip processing output module
The single-chip processing output module adopts 5V working voltage. The three ping-pong keys K3, K4, K5 on the module correspond to the three keys K0, K1, and K2 on the transmitter module, which can be used to control the forward, reverse and stop of the motor . These three keys can replace K0, K1 and K2 for operation when the remote control has problems or is lost, so it is very convenient and practical.
The P5.0 to P5.2 pins on the single-chip microcomputer are used as the signal input terminals of the motor forward, reverse and stop respectively, and the P6.0 and P6.1 pins are respectively used as the signal output terminals of the motor forward and reverse. To stop the motor operation, just send the invalid signal to P6.0 and P6.1. After the output signal of the single-chip computer is reversed by 74LS04 and sent to ULN2003A for amplification, the relay can be driven to make the DC motor perform corresponding operations.
In addition, two LEDs can be used to display the operation. In this way, when the motor is rotating forward or reverse, one of the diodes will light up, and when the stop button is pressed, neither of them will light up. Its hardware circuit is shown as in Fig. 4.
4 System software design
This design uses the development tool EMC of the EM series single-chip microcomputer as the programming tool, and the main program continuously monitors the status of the ping-pong key. When a key is pressed and released, its corresponding motor is started, and then the system returns to the state of detecting the key to determine whether to maintain the running state or switch to another state.
It should be noted that when the mechanical switch is pressed or released, the button will bounce on the contact due to mechanical elasticity. This fast beating CPU will be fully detected, so there will be an error situation where the user only presses the switch once, and the CPU considers it to be pressed many times.