Production of power carrier communication switch circuit based on 51 microcontroller
Source: InternetPublisher:D先生 Keywords: Power communication power Updated: 2021/05/01
1. Schematic diagram:
![Production of power carrier communication switch circuit based on 51 microcontroller](http://www.eeworld.com.cn/circuit/upload/ff62fcb6b292cff4c963a059e9697209/63f6543f9801b9f9a3aeff6106d3428f.bmp)
2. C program source code
/*
This program has been debugged and run by me personally. If you have any questions, please contact
QQ: 286288986
*/
#include //Predefined header file
#define uchar unsigned char //Macro definition
sbit keyin=P3^3; //Key definition
sbit LED=P3^5; //Indicator light definition
uchar a; //Receive data register
void main() //main function
{
keyin=1; //Set the key port to 1
led=1; //turn off the led light
TMOD=0x20; //Select mode 2 in timer/counter 1
SP=0x60; //Set the heap extraction address
TH1=0xfd; //Baud rate 9600bit/s
TL1=0xfd;
SCON=0x50; //Serial communication mode 2, allowing sending and receiving
TR1=1; //Start the counter
while(1) //Loop
{
if(keyin==0) //Determine whether the key is pressed, if so, process the key
{
SBUF=0x00; //Receive data processing
while(TI==0); //Clear the receive flag after sending
TI=0;
}
if(RI==1) //Whether to receive
{
RI=0; //Clear the reception flag after receiving
a=SBUF; //Read received data
if(a==0) //Judge whether the received data is correct
{
if(led==1) //Invert the correct LED light
led=0;
else
led=1;
}
}
}
}
3. Assembly program
/*
This program has been debugged by me personally. If you have any questions while studying,
QQ: 286288986
*/
ORG 00H
JMP START //Start
ORG 10H //Start address
START:
MOV SP,#60H //Set the heap address
MOV SCON,#50H //Serial communication mode 2, allowing sending and receiving
MOV TMOD,#20H //Select mode 2 in timer/counter 1
MOV TH1,#0FDH //Baud rate 9600bit/s
MOV TL1,#0FDH
SETB TR1 //Start the counter
SETB P3.3 //Switch input port is set to 1
SETB P3.5 //LED display off
SCAN:
JB RI,UART //Determine whether to receive
JNB P3.3,KEYIN //Determine whether the key is pressed, if so, process the key
JMP SCAN //Not key scan
KEYIN:
MOV A,#5AH //Send data into A
MOV SBUF,A //Send data
WAIT: // Waiting to send
JBC TI,SCAN //Clear the TI flag after sending
JMP WAIT
UART: //Receive data processing
MOV A,SBUF
CJNE A,#5AH,ERROR //The simple address code is set to 5AH, the user can define it at will
CLR RI //Clear the receive flag bit
CPL P3.5 //Light up
ERROR:
JMP SCAN //Return to scan
END
- Redundancy principle of power management system, a redundant design strategy in outdoor power BMS
- How about the boost converter TPS61299?
- ISO113 circuit that can reduce power consumption
- Single-power supply circuit for ISO122P/ISO124
- Detailed explanation of 5v charger circuit diagram
- Low cost and high performance LED constant current power supply
- Miniature polarity reversal power supply using MAX1721
- Integrated regulated power supply with continuously adjustable output voltage
- USB power socket using the car battery
- Detailed explanation of mobile phone charger circuit diagram
- Portable device charging power circuit design
- Voltage stabilization control circuit in power circuit
- Commonly used power circuits in printers
- 3-phase CPU power circuit using HIP6301 and HIP6601 chips
- 2-phase CPU power supply circuit using HIP6302 and HIP6602 chips
- Warm current power circuit a
- Simple dual-channel variable DC power supply circuit
- Diamond differential input power amplifier power circuit
- audio power circuit
- AC-DC conversion power supply-inverter power supply circuit