Basic learning of hardware knowledge

Input and output of GPIO, relay, triode, PWM, MOS tube.

I have not systematically studied professional hardware knowledge, and I can only learn from my predecessors in the process of practice. If there is any problem, please correct me. The routine schematic diagram of the template is placed at the end.

Table of contents

1. GPIOs

1.1 The difference between input and output

1.2 input

1.2.1 Current flow and resistance distinguish between pull-up and pull-down inputs

1.2.2 Floating input

2. Transistor

3. Relay

Four, MOS tube

4.1 Judgment of three poles

4.2 Determination of N-channel and P-channel

4.3 Judgment of input, output and diode

4.4 Turn-on condition

5. PWM

Routine schematic


Positive pole, negative pole, ground, low level, high level.

The negative pole is generally grounded (not only, some negative poles are connected to the power supply), the positive pole is generally connected to the power supply, the low level is similar to the ground (but higher than the ground), and the high level is generally similar to the power supply voltage. Whether the low level is effective or the high level is effective depends on how the hardware circuit is designed, so some buttons are pressed to be 0, and some buttons are pressed to be 1.

1. GPIOs

The GPIO modes we usually use: input (pull-up, pull-down, floating), output

1.1 The difference between input and output

In my opinion, the input is the acquisition and control of the level status of the GPIO port; the output is the control of the circuit level by the GPIO.

1.2 input

1.2.1 Current flow and resistance distinguish between pull-up and pull-down inputs

Take the button as an example, OPEN-MCU is the button, GND is at the bottom, the current flows from top to bottom, and is grounded through the resistor, so this is a pull-down resistor, and the GPIO mode is a pull-down input. When the button is pressed, the level is high level, that is, the high level is effective. Therefore, when the pull-up resistor is pressed, the level is low.

1.2.2 Floating input

Simple understanding:

active high

When pulling down the input, the button is pressed, the level is high, and the button is released, the level is low.

When floating input, press down, the level is high, release the key, no level.

2. Transistor

Transistors are divided into PNP and NPN, both of which act as switches for conduction, with voltage as the conduction condition.

b: Base e: Emitter c: Collector

    NPN                                                                                                                       PNP

                                                                        

NPN: The arrow is facing outward, the voltage at the beginning of the arrow is higher than the voltage at the end of the arrow, the triode is turned on, and the voltage of b is higher than that of e.

PNP: The arrow is facing inward, the voltage at the beginning of the arrow is higher than the voltage at the end of the arrow, the triode is turned on, and the voltage of e is higher than that of b.

3. Relay

M+/S and M-/S are GPIO switches to control the pull-in direction of the relay.

VBAT- (ground) is on the top, the current is from bottom to top, the resistance is pull-down, the GPIO mode is pull-down input (floating input is also OK), and the high level is active.

 When both ends are not pressed, that is, low level or no voltage, the triode has no voltage difference and does not conduct.

When M+/S is pressed, M-/S is not pressed, a circuit is formed as shown in the figure below, and the relay forms a circuit 3-4, pulls in 2-9 to form 2-10.

 After the relay is closed, the PWM square wave duty ratio input under D6 is the same as that of the upper circuit, then it will rotate forward, if it is different, it will reverse, so as to use the relay to control the forward and reverse rotation of the motor.

Four, MOS tube

MOS is divided into NMOS and PMOS, and it acts as a switch on the condition of voltage.

4.1 Judgment of three poles

G pole (gate) - gate.
S pole (source)—the source, whether it is a P-channel or an N-channel, the intersection of two lines is the S pole.
D pole (drain) - the drain, whether it is a P channel or an N channel, is the D pole on the side of the separate lead.

4.2 Determination of N-channel and P-channel

The arrow pointing to the G pole is the N channel,
and the arrow pointing away from the G pole is the P channel

4.3 Judgment of input, output and diode

 The diode is in the same direction as the arrow, the input end is the direction of the diode arrow, and the other end is the output end.

4.4 Turn-on condition

N-channel: G pole voltage > S pole voltage

P channel: G pole voltage < S pole voltage

The voltage at the end of the arrow > the voltage at the beginning of the arrow (opposite to the voltage of the triode conduction condition)

5. PWM

 When the PWM has no input, that is, the low level, the Q6 triode will not conduct if there is no voltage difference, and Q4 will not conduct if there is no voltage difference, that is, the MOS tube will not conduct in the same way.

 When the PWM input is at a high level, the triode and the MOS tube are turned on, and the PWM input is used to make each switch (the triode and the MOS tube be turned on). After the PWM turns on the MOS tube, it forms a loop with the upper relay voltage and works normally. The PWM control switch (high level) drives the switch to open to make the motor rotate. The greater the period of the high level open time, that is, the greater the duty cycle, the faster the motor speed.

(1)→(2)→(3)→(4) After 1 is turned on, 2 is turned on, 3 is turned on, and finally 4 is turned on.

 Q5 is not used in PWM work, so why is Q5 triode used?

When the PWM works normally, the Q5 transistor is blocked. During the power-on process of the board, there is voltage in the circuit, and Q5 will be turned on to ground for quick discharge.

Routine schematic diagram:

Guess you like

Origin blog.csdn.net/qq_51679917/article/details/130265164