用户工具

站点工具


en:ocrobot:modules:l298p

L298P Motor Shield

Introduce

L298P motor shield is a extension of arduino , using complete photoelectric electrical isolation design, expand under the shield and all optical coupling isolation on main control board, power supply part respectively independent power supply, motor drive two road, safe and reliable, strong anti-jamming capability.

Parameter

Limit the input voltage: 24 v Limiting current: 2 a Reliable working voltage (no auxiliary cooling) : 12 v Reliable working current (no auxiliary cooling) : 1 a The picture

Introduce

function motorA motorB direction D12 D13 speed(PWM) D3 D11 enable(not working) D9 D8

Refer to the above the pin definition of function is introduced, we can accurate control the motor.. First keeping low voltage to all enable pin, make sure the motor can be used, and then determine the high and low voltage level of direction pin, confirm the direction, keep electro motor working at full speed with digitalWrite () at pwm pin, other speed using the analogWrite () to set. The sample code

A motor full speed working

/*
 作者:迷你强
 时间:2013年8月31日
 IDE版本号:1.0.4
 发布地址:www.geek-workshop.com
 作用:电机驱动板演示程序,让A路电机全速正转与反转
*/
void setup()
{
  pinMode(12,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(9,OUTPUT);     //启用电机A的三个管脚,全部设置为输出状态
}
 
void loop()
{
  digitalWrite(9, LOW);       //松开电机A的制动
  digitalWrite(3, HIGH);      //采用全功率输出
  digitalWrite(12, HIGH);     //设置方向为正向
  delay(1000);                 //运行1秒
  digitalWrite(9, HIGH);     //电机停止运行
  delay(1000);               //维持1秒钟
  digitalWrite(9, LOW);       //松开电机A的制动
  digitalWrite(3, HIGH);     //采用全功率输出
  digitalWrite(12, LOW);     //设置方向为反向
  delay(1000);                //运行1秒
}

B motor full speed working

/*
 作者:迷你强
 时间:20111年8月111日
 IDE版本号:1.0.4
 发布地址:www.geek-workshop.com
 作用:电机驱动板演示程序,让A路电机全速正转与反转
*/
void setup()
{
  pinMode(13,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(8,OUTPUT);     //启用电机B的三个管脚,全部设置为输出状态
}
 
void loop()
{
  digitalWrite(8, LOW);       //松开电机A的制动
  digitalWrite(11, HIGH);      //采用全功率输出
  digitalWrite(13, HIGH);     //设置方向为正向
  delay(1000);                 //运行1秒
  digitalWrite(8, HIGH);     //电机停止运行
  delay(1000);               //维持1秒钟
  digitalWrite(8, LOW);       //松开电机A的制动
  digitalWrite(11, HIGH);     //采用全功率输出
  digitalWrite(13, LOW);     //设置方向为反向
  delay(1000);                //运行1秒
}

A motor half speed working:

/*
 作者:迷你强
 时间:2013年8月31日
 IDE版本号:1.0.4
 发布地址:www.geek-workshop.com
 作用:电机驱动板演示程序,让A路电机半功率正转与反转,如果发现电机无法转动,请适当调高输出功率 范围0-255
*/
void setup()
{
  pinMode(12,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(9,OUTPUT);     //启用电机A的三个管脚,全部设置为输出状态
}
 
void loop()
{
  digitalWrite(9, LOW);       //松开电机A的制动
  analogWrite(3, 128);      //50%功率输出
  digitalWrite(12, HIGH);     //设置方向为正向
  delay(1000);                 //运行1秒
  digitalWrite(9, HIGH);     //电机停止运行
  delay(1000);               //维持1秒钟
  digitalWrite(9, LOW);       //松开电机A的制动
  analogWrite(3, 128);     //50%功率输出
  digitalWrite(12, LOW);     //设置方向为反向
  delay(1000);                //运行1秒
}

B motor half speed working:

/*
 作者:迷你强
 时间:20111年8月111日
 IDE版本号:1.0.4
 发布地址:www.geek-workshop.com
 作用:电机驱动板演示程序,让B路电机半功率正转与反转,如果发现电机无法转动,请适当调高输出功率 范围0-255
*/
void setup()
{
  pinMode(13,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(8,OUTPUT);     //启用电机B的三个管脚,全部设置为输出状态
}
 
void loop()
{
  digitalWrite(8, LOW);       //松开电机A的制动
  analogWrite(11, 128);      //50%功率输出
  digitalWrite(13, HIGH);     //设置方向为正向
  delay(1000);                 //运行1秒
  digitalWrite(8, HIGH);     //电机停止运行
  delay(1000);               //维持1秒钟
  digitalWrite(8, LOW);       //松开电机A的制动
  analogWrite(11, 128);     //50%功率输出
  digitalWrite(13, LOW);     //设置方向为反向
  delay(1000);                //运行1秒
}
en/ocrobot/modules/l298p.txt · 最后更改: 2023/06/07 04:23 由 127.0.0.1