How to drive LED lamp by single chip microcomputer

2022-07-25
  • Detail

A brief discussion on how the single chip microcomputer drives the LED lamp

in the figure in the previous section, the LED is connected in series with the resistor, the negative pole of the LED lamp is connected to the IO of the single chip microcomputer, and the other pin of the resistor is connected to the VCC. After programming, through proteus simulation, you can get the desired results. No problem

but why? Is there any other connection method? The positive pole of the LED lamp is connected to the IO of the single chip microcomputer, and the negative pole is connected in series with the resistance to GND. It seems that this method is also OK, but in practical application, the result of this method is: "shit! It doesn't work". Here we introduce a new problem - the driving ability of the single chip microcomputer

I think it should be well understood that people have limited tolerance, not to mention this small single-chip microcomputer

please see the two connection modes in the following figure

mode (1). When the IO output of the single-chip microcomputer is low, the LED light is on, and the current is square, as shown by the red arrow in the figure

mode (2) in the ideal state, the single chip microcomputer outputs a high level and lights up the LED. The current direction is shown as the arrow in the figure. However, although the ideal is plump, the reality is very skinny. For the 8051 single chip microcomputer, this mode may not light up the LED. Here we introduce the problem to be described in this article - the IO driving ability of the single chip microcomputer

2. Two concepts of driving capability ratio - perfusion current and pull current

1. Perfusion current: in the (1st) connection mode in the figure, when the single chip microcomputer outputs a low level, the current direction enters the single chip microcomputer from the outside, which is called perfusion current, and the current is provided by the external power supply

2. Pull current: in the connection mode (2) in the figure, rather than tailored according to the unique body structure of each patient, when the single-chip microcomputer outputs a high level, the current direction is output by the single-chip microcomputer to the outside, which is called pull current. The current is provided by the single-chip microcomputer. I understand it as "external components take power from the single-chip microcomputer"

after understanding these two concepts, it is necessary to first understand the internal structure of the IO port of the single chip microcomputer. Take the P1 port of the 80C51 single chip microcomputer as an example, as shown in the figure:

let's first care about the T and pull-up resistance in the figure. In order to better understand it, t is simplified as a switch, as shown in the figure below.

(1) when the single chip microcomputer outputs 0, t is closed and connected to GND. At this time, IO is equivalent to GND

(2) when the single chip microcomputer outputs 1, t is disconnected. At this time, VCC is connected to IO through resistance R

therefore, the above two connection modes are simplified to the following figure

a. figure (1) is the current filling connection mode. When t is closed, a DC path is formed, the LED meets the current requirements, the LED lights up, and the current direction is shown in the figure, I = VCC -vled/R1

b, figure (2) shows the connection mode of pulling current. When t is disconnected, R, R2 and D2 are connected in series to form a DC path. I = VCC - VLED/r+r2. R is the internal pull-up resistance of the single chip microcomputer, with a resistance value of hundreds of thousands of K. obviously, the current I is very small, which can not light the LED lamp

at this point, it may just be wishful thinking to see the key things, datasheet, evil English, as shown in the figure:

(1) the single chip microcomputer inputs a low level, allowing the maximum external injection current of 15ma

(2) when the 8-bit port of the single chip microcomputer outputs a low level at the same time, the sum of the maximum current is 26ma

(3) all IO outputs a low level at the same time, and the sum of the maximum current is 71ma

, The current filling mode can be calculated by connecting several LED lights. When the single chip microcomputer outputs a high level, the following figure shows what the hell is. It has almost no driving ability. It can be seen how much the pull-up resistance is inside the single chip microcomputer

to sum up, it is suggested that when designing the circuit, we should first look at the datasheet in the manufacturing materials, calculate the driving capacity, and then draw the circuit diagram to avoid the cumbersome task of changing different experimental accessories in the same space when stretching and contracting twists and turns, and then programming and debugging. The problem should not be big

III. perhaps this is a correct way to connect LED lights.

the single chip microcomputer can drive oneortwo LED lights. When multiple LED lights need to be driven, the external driver must be added to provide the current required by the external current. The common way is to add the driver chip to the external circuit, such as 74HC373, non gate, tri state gate, BJT, etc. the following example is the circuit using triode to drive LED lights, as shown in the figure

the single chip microcomputer only controls the on/off of the triode without providing the driving current. When the output is high, the triode is turned on to form a DC path, and the LED light is on; When the MCU output is low, the triode is cut off, which can be understood as open circuit and LED is off. There is no problem connecting multiple LEDs like this

however, it is not so easy to earn a salary. He is a hard pressed engineer engaged in the medical device industry. In recent years, the state has imposed strict control on product registration, one of which is EMC

the method in the above figure is applied to the product. When the system is powered on, the LED flashes. This... This is not an experiment. This phenomenon is absolutely not allowed in the product. The reason is that at the moment of power on, the manufacturer should also consider the dynamic performance and synchronization of the machine movement. The IO output of the single-chip microcomputer cannot immediately reach the value initialized in the program. In addition, the impact of the power supply and the interference of other signals on the PCB board cause the triode to turn on instantaneously, and the LED light flashes; In addition, when ESD or EFT is applied to the system, the LED light is also dry lit, and the result is - unqualified. Finally, change the following figure to solve the problem

add capacitor C, absorb peak voltage, pass

Copyright © 2011 JIN SHI