Arduino与Proteus仿真实例-L293D驱动直流电机仿真

L293D驱动直流电机仿真

L293D 是市场上最受欢迎的驱动程序之一。 L293D成为用户首选的驱动器有几个原因,例如:价格便宜(与其他驱动器相比)、合适的形状和尺寸、易于控制、无需保护电路和二极管、无需散热器和良好的电阻 温度和高速变化。 该IC可以设置电压在5V到36V之间,电流高达600mA的电机。 但是,它可以在 100 微秒内承受高达 1200 mA 的电流并且不重复。 该 IC 的频率为 5 kHz。

每个输出都是一个完整的图腾柱驱动电路,带有一个达林顿晶体管接收器和一个伪达林顿源。 驱动程序成对启用,驱动程序 1 和 2 由 1,2EN 启用,驱动程序 3 和 4 由 3,4EN 启用。 L293 和 L293D 的工作温度范围为 0°C 至 70°C。

在这里插入图片描述

L293D 的其他重要功能包括:

  • 宽电源电压范围:4.5V 至 36V
  • 独立的输入逻辑电源
  • 内部ESD保护
  • 高抗噪输入
  • 每通道输出电流 1 A(L293D 为 600 mA)
  • 每通道峰值输出电流 2 A(L293D 为 1.2 A)
  • 用于电感瞬态抑制的输出钳位二极管 (L293D)

L293D的引脚功能如下:

在这里插入图片描述

L293D的控制真值表如下:

在这里插入图片描述

1、仿真电路原理图

在这里插入图片描述

2、仿真代码实现

本次使用到如下开源库:

演示代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/\*
\* Bidirectional Motor Control with standalone L293
\*
\* Example of using L293 library to control one or more DC Birirectional Motors with the standalone configuration of the L293
\*
\* Created by Giuseppe Masino, 25 may 2016
\* Author URL http://www.facebook.com/dev.giuseppemasino
\*
\* This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
\* To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
\* -----------------------------------------------------------------------------------
\*
\* Things that you need:
\* - Arduino\Genuino MEGA2560
\* (any Arduino\Genuino board can be used, the important is that the L293 pin 1 is connected to a PWM-enabled pin of Arduino)
\* (on the Arduino MEGA2560 all pins from 2 to 13 are PWM-enabled)
\* (use of pin 13 is discouraged because it can cause issues when the board resets)
\*
\* - L293
\* - A DC Birirectional Motor (max 5V-4mA)
\*
\* -----------------------------------------------------------------------------
\*
\* The circuit ( standalone version ):
\* - Arduino pin 2 -> L293 pin 1
\* - Arduino pin 3 -> L293 pin 2
\* - Arduino pin 4 -> L293 pin 7
\* - Arduino GND -> L293 pin 4, 5
\* - Arduino 5V -> L293 pin 16, 8
\*
\* - L293 pin 3 -> a terminal of the motor
\* - L293 pin 6 -> the other terminal of the motor
\*
\* The circuit ( twoWire version ):
\* https://github.com/qub1750ul/Arduino\_L293/blob/master/extras/L293\_twoWire.svg
\*
\*/

// by default this example uses the standalone version of the library
// comment out the following row to switch to the twoWire version
#define use\_standalone

// import the library in the sketch
#include <L293.h>

// give a name to the pins that we use
const int IN1 = 2; // that is the pin that we use to control the motor's speed
const int IN2 = 3; // this is the pin that we use to tell the motor to go forward
const int EN1 = 4; // this is the pin that we use to tell the motor to go reverse

const int IN3 = 6; // that is the pin that we use to control the motor's speed
const int IN4 = 7; // this is the pin that we use to tell the motor to go forward
const int EN2 = 5; // this is the pin that we use to tell the motor to go reverse

L293 motor1( EN1, IN1, IN2 );
L293 motor2( EN2, IN3, IN4 );


void setup()
{
// nothing to do in setup()
}

void loop()
{
motor1.forward( 255 ); // set the direction and the speed of the motor
motor2.forward( 255 ); // set the direction and the speed of the motor
delay( 1000 ); // wait for 1 second before doing else
motor1.back( 255 ); // set a new direction and the speed of the motor
motor2.back( 255 ); // set a new direction and the speed of the motor
delay( 1000 ); // wait for 1 second before doing else
motor1.stop(); // stop the motor
motor2.stop(); // stop the motor
delay( 1000 ); // wait for 1 second before doing else

// now the loop restarts
}

3、仿真结果

在这里插入图片描述

文章来源: https://iotsmart.blog.csdn.net/article/details/121403001