Driving and use of relays in proteus

When carrying out the proteus simulation drive relay, because the first time I contacted and learned the relay, I encountered the problem that it could not be driven regardless of the power drive or the triode amplification drive, so I checked the information of the relay and the default settings in proteus, and found that it was proteus The default driving voltage of the middle relay is 12V, so we need to change the default of the relay to 5V or change the power supply to 12V .

Now let's look at driving a relay with two triode methods

1. It is driven by direct power supply, and then uses NPN as a switch. The principle is very simple.

When the IO port outputs a high level 1, the triode will be turned on, at this time the relay switch is closed and the LED is on. as the picture shows

When the IO port outputs a low level of 0, the triode will be cut off, at this time the relay switch is turned off, and the LED is off. as the picture shows

2. Use the triode PNP amplification to drive the relay to work. The working principle is to amplify the current output by the IO port through the triode to drive the relay to work, as shown in the figure. Note: The diode next to the relay here is to protect the relay, it needs to be added in the actual circuit, here is a supplement.

code show as below:

#include<reg51.h>
sbit jidianqi=P2^0;
//延时程序:由 Delay参数确定延迟时间
void delay(unsigned int m)
{
 unsigned int i;
 for (;m>0;m--)
 {
 for(i=0; i<54; i++) ;
 }
}
void main()
{
  while(1)
  {
    jidianqi=1;
	delay(1000);
	jidianqi=0;
	delay(1000);
  }
}

My level is limited, the above information is for reference only, if there are any mistakes and inadequacies, please advise.

In addition, it is not easy to create, please do not plagiarize, if it is helpful to everyone, I hope everyone can like it, thank you~

Guess you like

Origin blog.csdn.net/OMGMac/article/details/115032492