当前位置:网站首页>[Arduino experiment 17 L298N motor drive module]
[Arduino experiment 17 L298N motor drive module]
2022-07-03 01:12:00 【Zhang Xiaohua Soleil】
Catalog
Two 、 Experimental equipment and environment
3、 ... and 、 Key points of the experiment
Four 、 Experimental difficulties
5、 ... and 、 Experimental content
One 、 The experiment purpose
(1) be familiar with L298N Principle and function of motor drive module ;
(2) master L298N Program control method of driving motor ;
(3) be familiar with PS2 The principle and function of the two axis rocker sensor module ;
(4) To write L298N Motor drive control program .
Two 、 Experimental equipment and environment
Arduino UNO Kit 、Arduino IDE、 Computer 、L298N Driver module 、 DC motor 、 Potentiometer 、PS/3 Dual axis rocker sensor, etc
3、 ... and 、 Key points of the experiment
(1)L298N Principle and function of motor drive module ;(2)PS2 Principle of dual axis rocker sensor module ;(3)L298N Motor driver control
Four 、 Experimental difficulties
(1)L298N Program control of motor drive
5、 ... and 、 Experimental content
5.1 Experiment task
Task description :PS2 Two axis rocker test ;L298N DC motor drive circuit connection ;L298N DC motor driver programming and debugging
5.2 Experimental principle
1.PS/3 Two axis rocker Sensor
JoyStick The rocker is made of original high-quality metal PS2 Manufacture of rocker potentiometer , have (X,Y)2 Axis analog Output ,(Z)1 Road button digital Output ,3 The two signals are respectively connected to... Through DuPont line Arduino Sensor expansion board , Just occupy 2 An analog input port 、1 Digital input ports , You can control .

Technical specifications of rocker :
Power requirements :+3.3-5V
Analog output :X、Y2 Shaft analog output
Digital output :Z, Digital key output
PS/3 How the rocker works
The rocker is actually connected to by two potentiometers Arduino Analog input of , Their values range from 0 To 1023. When the control lever is kept in the center position of the vertical state , Potentiometer X/Y The value of the axis is 512 about . If the 512 The left and right values are centered , Shake the lever X Axis , The value is lower than 512 It can make the motor rotate in one direction , When the value is higher than 512 The rotation direction of the motor can be controlled to reverse ; take X Read value of axis 0-511 Change the mapping to 255-0,X Read value of axis 512-1023 It maps to 0-255, By converting to PWM The value controls the speed of the motor .
PS/3 rocker Z The axis is equivalent to a key switch , When the rocker is pressed vertically , Switch closed , When released, the switch opens .
2.H-Bridge The principle of forward and reverse rotation of bridge controlled DC motor
The rotation direction of the DC motor should be reversed , It is necessary to change the direction of DC current , By transistors (BJT or MOSFET) The four switching elements are similar H Structure , By activating two specific switches at the same time , Change the direction of current flowing through the motor , The drive motor changes the direction of rotation without switching leads .

adopt 4 Transistorized H Bridge connection , change A、B Direction of high and low level of control terminal , Realize the change of driving current direction , And change the rotation direction of the motor , As shown in the figure :
3.L298N Motor drive module
L298N yes ST A high voltage produced by the company 、 High current motor drive chip . The chip uses 15 Foot package . There are two H High voltage and high current full bridge driver of bridge , It can be used to drive DC motor and stepping motor 、 Inductive load such as relay coil .

L298NH Bridge dual motor drive module L298NH Bridge double motor drive circuit
L298N double H Technical specifications of axle drive module :
Driver chip : double H Bridge DC motor driver chip
L298N Drive end power supply range VS:+5V~ +35V
Power supply range of drive board VS:+7V~ +35V
Power supply range of logic part VSS:+5V ~ +7V( Power on board +5V)
Peak current range of logic part :0 ~ 36mA
Maximum power consumption :20W
Storage temperature :-25°C ~ +130°C
L298N How to use the driver module
L298N The drive module adopts standard logic level signal IN1\IN2\IN3\IN4 control ; It has two enable control terminals ENA\ENB, Without being affected by the input signal , can ( High level ) Allow or ( Low level ) Prohibit the driver from working ; Yes 5V Logic power input , Make the internal logic circuit work under low voltage .L298N The chip can drive a two-phase stepping motor or a four phase stepping motor , It can also drive two DC motors .
L298N Power supply of drive module . Connect to the independent power supply 12V Power supply input terminal input 7-12V Power supply voltage , The short-circuit jumper is in the short-circuit state , Can pass 5V Interface access Arduino Development board “Vin+GND” Port reverse Arduino for 5V electric . When the independent power supply is 12-24V When , The short jumper cap must be removed , At this time, the independent power supply supplies power to the logic circuit motor of the drive board , No external power supply output .
L298N The drive module controls the DC motor
L298N The drive module can drive two DC motors MA and MB.
Regulation and control of DC motor speed .① DC motor can pass IN1/IN2、IN3/IN4 Interface input PWM The signal controls the motor speed ;② You can also use the enable end ENA and ENB Input PWM PWM signal regulates and controls the speed of DC motor (ENA、ENA Short the jumper cap , by 5V, The motor operates at the highest speed ).
Forward and reverse rotation control of DC motor . Signal input terminal IN1=HIGH、N2=LOW perhaps IN1(PWM)>IN2(PWM), The motor MA Positive rotation ; Signal input terminal N1=LOW、IN2=HIGH perhaps IN1(PWM)>IN2(PWM), The motor MA reverse . DC motor MB Empathy .

4.PS2 Rocker control L298N Drive motor experimental circuit
Circuit diagram 
The circuit principle diagram

5.3 Experimental content
1.PS2 Parameter test of two axis rocker Sensor
step 1: Connecting circuits
step 2: Programming
int xPin = A0;
int yPin = A1;
int zPin = 2;
int xValue,yValue,zValue;
void setup() {
pinMode(zPin,INPUT);
Serial.begin(9600);
}
void loop() {
xValue = analogRead(xPin);
yValue = analogRead(yPin);
zValue = digitalRead(zPin);
Serial.print("X =:");
Serial.print(xValue);
Serial.print(" Y =:");
Serial.print(yValue);
Serial.print(" Z =:");
Serial.println(zValue);
delay(100);
}
step 3: Program testing
2.L298N Driver module test
Test task : Start positive transmission of single DC motor 、 stop it 、 reverse ; Potentiometer controls motor speed regulation
First, connect the DC motor in a single way A Drive circuit ,IN1、IN2 Input ground D5、D6 Interface , The sliding head pin of potentiometer is connected A0 Interface .
step 1: Connect the circuit as required
step 2: Write control program
Program example 1: Forward rotation of motor 、 stop it 、 reverse
int IN1=5;
int IN2=6;
void setup() {
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
digitalWrire(IN1,LOW);
digitalWrite(IN2,LOW);
}
viod loop() {
// Positive rotation 1 second
digitalWrire(IN1,HIGH);
digitalWrite(IN2,LOW);
delay(1000);
// stop it 1 second digitalWrire(IN1,LOW);
digitalWrite(IN2,LOW);
delay(1000);
// reverse 1 second , Stop the rotation as a transition before reversing the direction of rotation , To protect the circuit
digitalWrire(IN1, LOW);
digitalWrite(IN2, HIGH);
delay(1000);
// stop it 1 second
digitalWrire(IN1,LOW);
digitalWrite(IN2,LOW);
}
Program example 2: Potentiometer input PWM Signal speed regulation 
int IN1=5;
int IN2=6;
int dwqPin=A0;
int dwqValue;
int speedValue = 0;
void setup() {
Serial.begin(9600);
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(dwqPin,INPUT);
analogWrite(IN1,0);
analogWrite(IN2,0);
}
void loop(){
dwqValue = analogRead(dwqPin)
Serial.print("dwqValue =:");
Serial.print(analogRead(dwqValue));
Serial.print(" speedValue =:");
Serial.println(speedValue);
if (dwqValue > 512){ // The motor is turning forward , adjust speed
analogWrite(IN2,0);
speedValue = dwqValue - 512;
speedValue = map(speedValue,0,512,0,255);
analogWrite(IN1,speedValue);
delay(10);
}
else { // The motor reverses , adjust speed
analogWrite(IN1,0);
speedValue = map(dwqValue,0,512,0,255);
analogWrite(IN2,speedValue);
delay(10)
}
}
3. Experiment extension :PS2 The rocker controls the rotation of dual DC motors
Experiment task : adopt PS2 rocker X Shaft control motor A Speed of ,Y Shaft control motor B Speed of ,Z The shaft key controls the start of the motor 、 stop it .
L298N The drive module is connected to the double DC motor , among IN1=5,IN2=6,IN3=10,IN4=11;
PS2 Rocker's SX=A0,SY=A1,ZK=2.
5.4 experimental result
Conclusion : Starting forward rotation of single DC motor 、 stop it 、 reverse . Positive rotation 1 second , Then stop , Then reverse 1 second . Control the movement and stop of the trolley through the rocker .
reflection : Through this experiment , I learned a lot , I'm familiar L298N The principle and function of motor drive module have been mastered L298N Program control method of driving motor , I'm familiar PS2 The principle and function of the two axis rocker sensor module , Be able to write L298N Motor drive control program .
works :

5.5 Thinking questions
1. adopt PS2 Rocker control motor rotation experiment , You can use PS2 The rocker realizes the starting of the motor 、 stop it 、 Positive rotation 、 reverse 、 Speed regulation ? How to achieve ? Please draw the flow chart of program control .
边栏推荐
- Win10 can't be installed in many ways Problems with NET3.5
- Correctly distinguish the similarities and differences among API, rest API, restful API and web service
- MySQL
- Esp32 simple speed message test of ros2 (limit frequency)
- In the first half of 2022, there are 10 worth seeing, and each sentence can bring you strength!
- 这不平凡的两年,感谢我们一直在一起!
- Specified interval inversion in the linked list
- [AUTOSAR 11 communication related mechanism]
- 异步、邮件、定时三大任务
- (C语言)数据的存储
猜你喜欢
[AUTOSAR five methodology]

Kubernetes resource object introduction and common commands (V) - (NFS & PV & PVC)

12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
![[AUTOSAR twelve mode management]](/img/42/292e3da3f5d488a1e8c10ea9bbfbab.png)
[AUTOSAR twelve mode management]

Win10 can't be installed in many ways Problems with NET3.5

Linear programming of mathematical modeling (including Matlab code)
![[overview of AUTOSAR four BSW]](/img/19/c2273bbedb7f8d859e5a3805ed5740.png)
[overview of AUTOSAR four BSW]
![[AUTOSAR XIII NVM]](/img/38/805ab70f199e2cfad4d9dae0e2c1ff.png)
[AUTOSAR XIII NVM]

(C语言)数据的存储
![[AUTOSAR nine c/s principle Architecture]](/img/59/ce32c0ff58ef5d8385fe950136175b.png)
[AUTOSAR nine c/s principle Architecture]
随机推荐
leetcode-241:为运算表达式设计优先级
MySQL multi table joint deletion
Inversion de l'intervalle spécifié dans la liste des liens
(C language) data storage
[shutter] image component (configure local GIF image resources | load placeholder with local resources)
正确甄别API、REST API、RESTful API和Web Service之间的异同
合并K个已排序的链表
【爱死机】《吉巴罗》被忽略的细节
R language generalized linear model function GLM, (model fit and expression diagnostics), model adequacy evaluation method, use plot function and car package function
[case sharing] let the development of education in the new era advance with "number"
Explain the basic concepts and five attributes of RDD in detail
Understanding and distinguishing of some noun concepts in adjustment / filtering
MySQL基础用法02
leetcode:701. 二叉搜索树中的插入操作【bst的插入】
机器学习术语
Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
tail -f 、tail -F、tailf的区别
The arm core board / development board of Feiling equipped with Ti am62x made its debut in embedded world 2022
【FPGA教程案例5】基于vivado核的ROM设计与实现
[overview of AUTOSAR three RTE]