KS0298 Keyestudio quick connectors Motor Drive Shield: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
(Created page with " thumb|700x|right|Keyestudio quick connectors Motor Drive Shield <br> == Overview == There are many ways to drive the motor. Our robot uses the most...")
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:


[[image:KS0435-3.png|thumb|700x|right|Keyestudio quick connectors Motor Drive Shield ]]
[[image:Ks0298-1.png|thumb|800x|right|Keyestudio quick connectors Motor Drive Shield ]]


<br>
<br>
Line 9: Line 9:
We have designed the motor driver shield based on the L298P circuit. <br>
We have designed the motor driver shield based on the L298P circuit. <br>
The stackable design can make it be plugged directly into the Arduino, reducing the technical difficulty of using and driving the motor.<br>
The stackable design can make it be plugged directly into the Arduino, reducing the technical difficulty of using and driving the motor.<br>
Direct stack the motor driver shield onto UNO R3 board, after the BAT is powered on, turn the Slide button ON, to supply the power for both keyestudio motor driver shield V2 and UNO R3 board. <br>
Direct stack the motor driver shield onto UNO R3 board, after the BAT is powered on, press the '''POWER button''', to supply the power for both keyestudio motor driver shield and UNO R3 board. <br>


For simple wiring, the motor driver shield comes with '''anti-reverse PH2.0-(2P/3P/4P/ 5P) interfaces'''. When connecting the motor, power supply and sensor modules, you just need to plug in directly. <br>
For simple wiring, the motor driver shield comes with '''anti-reverse PH2.0-(2P/3P/4P/ 5P) interfaces'''. When connecting the motor, power supply and sensor modules, you just need to plug in directly. <br>
[[File:Ks0298-3.png|550px|frameless|thumb]]


The Bluetooth interface on the motor driver shield is fully compatible with keyestudio Bluetooth module. When connecting, just plug Bluetooth module into the corresponding interface. <br>
The Bluetooth interface on the motor driver shield is fully compatible with keyestudio Bluetooth module. When connecting, just plug Bluetooth module into the corresponding interface. <br>


At the same time, the motor drive shield has brought out extra digital and analog ports in '''2.54mm pin headers''', so that you can continue to add other sensors for experiments extension. <br>
At the same time, the motor drive shield has brought out extra digital and analog ports in '''2.54mm pin headers''', so that you can continue to add other sensors for experiments extension. <br>
The motor drive shield can access to 4 DC motors. The motor connector A and A1, connector B and B1 are separately in parallel, with the same motion rule. <br>
The motor drive shield can access to 4 DC motors. The motor connector A and A1, connector B and B1 are separately in parallel, with the same motion law. <br>
The shield comes with 4 fixing holes of 3mm, easy to mount on other devices.
The shield comes with 4 fixing holes of 3mm, easy to mount on other devices.


<br>[[File:KS0435-2.png|600px|frameless|thumb]]<br>
<br>[[File:Ks0298-2.png|550px|frameless|thumb]]<br>




Line 37: Line 38:
<br>
<br>
== PINOUT Diagram ==
== PINOUT Diagram ==
<br>[[File:KS0435-4.png|800px|frameless|thumb]]<br>
<br>[[File:Ks0298-4.png|700px|frameless|thumb]]<br>




<br>
<br>
== Hookup Guide==
== Hookup Guide==
<br>[[File:KS0435-5.png|600px|frameless|thumb]]<br>
<br>[[File:KS0435-5.png|650px|frameless|thumb]]<br>
 
 
<br>
 
== Motor state settings ==
<br>[[File:Ks0298-6.png|600px|frameless|thumb]]<br>
 


<br>
<br>
== Test Code ==
== Test Code ==
<pre>
<pre>
void setup(){
int E1 = 9; //  set the speed pin of motor A as D9
   pinMode(4, OUTPUT);
int E2 = 5; //  set the speed pin of motor B as D5
   pinMode(2, OUTPUT);
int M1 = 2; // set the direction pin of motor A as D2
int M2 = 4; // set the direction pin of motor B as D4
       
void setup(void)
{
   pinMode(M1,OUTPUT); // set M1 as OUTPUT mode
  pinMode(M2,OUTPUT); // set M2 as OUTPUT mode
  pinMode(E1,OUTPUT); //  set E1 as OUTPUT mode
   pinMode(E2,OUTPUT); //  set E2 as OUTPUT mode
}
void advance(void)        // set the forward motion
{
  digitalWrite(M1,HIGH);  // motor A turns forward, the wheel will go forward.
  digitalWrite(M2,HIGH);  // motor B turns forward, the wheel will go forward.
  analogWrite(E1,150);    // speed of motor A(can be adjusted according to the actual speed of motor. Turn up the value to accelerate, lower the value to decelerate.)
  analogWrite(E2,150);    // speed of motor B(can be adjusted according to the actual speed of motor. Turn up the value to accelerate, lower the value to decelerate.)
void back(void)        // set the backward motion
{
digitalWrite(M1,LOW);  // motor A turns reverse and the wheel will go backward
digitalWrite(M2, LOW);  //  motor B turns reverse and the wheel will go backward
analogWrite(E1,150);    //  speed of motor A
analogWrite(E2, 150);    //  speed of motor B
 
void turnL(void)    // set the left turn
{
  digitalWrite(M1,LOW);    // motor A turns reverse and the wheel will go backward
  digitalWrite(M2, HIGH);  // motor B turns forward and the wheel goes forward, the smart car will turn left.
  analogWrite(E1,150);  // speed of motor A
  analogWrite(E2, 150);  // speed of motor B
}
}


void loop(){
void turnR(void)           //  set the right turn
  digitalWrite(4,HIGH);
{
  analogWrite(5,100);
  digitalWrite(M1,HIGH);   // motor A turns forward and the wheel will go forward
  digitalWrite(2,HIGH);
  digitalWrite(M2,LOW);   // motor B turns reverse and the wheel goes backward, the smart car will turn right.
  analogWrite(9,100);
  analogWrite(E1,150);     // speed of motor A
  delay(2000);
  analogWrite(E2, 150);   // speed of motor B
  digitalWrite(4,LOW);
}
  analogWrite(5,100);
 
  digitalWrite(2,LOW);
void stopp(void)   // set the STOP
  analogWrite(9,100);
{
  delay(2000);
  digitalWrite(M1,LOW); // motor A turns reverse
  digitalWrite(4,LOW);
  digitalWrite(M2, LOW); //  motor B turns reverse
   analogWrite(5,100);
  analogWrite(E1, 0);     //  speed of motor A, speed as zero, means stop
  digitalWrite(2,HIGH);
  analogWrite(E2, 0);     // speed of motor B, speed as zero, means stop
  analogWrite(9,100);
}
  delay(2000);
 
  digitalWrite(4,HIGH);
void loop()  
  analogWrite(5,100);
{
  digitalWrite(2,LOW);
advance();  // go forward
  analogWrite(9,100);
delay(1000); // delay1S
  delay(2000);
back();     //backward
  analogWrite(5,0);
delay(1000);// delay1S
   analogWrite(9,0);
 
  delay(2000);
turnL();   //turn left
delay(1000);//delay1S
turnR();   //turn right 
delay(1000); //delay1S
stopp();  // stop
delay(1000);// delay1S
}
}
</pre>
</pre>
Line 81: Line 124:
<br>
<br>
== Test Result ==
== Test Result ==
Done wiring, stack the motor drive shield onto the UNO control board; connect UNO to computer’s USB port with USB cable to upload the code. <br>
Stack well the drive shield onto UNO R3 board, and upload the above code to the board, then press down the POWER button.   <br>
Upload success, turn the Slide switch ON; 2 motors will simulate the smart car movement. Turn forward for 2 seconds, backward for 2 seconds, and then rotate to left for 2 seconds, rotate to right for 2 seconds, stop for 2 seconds, alternately and circularly.<br>
The 2 motors simulate the motion of smart car. Go forward for one second, backward for one second, and then turn left for one second, turn right for one second and stop one second, alternately repeating. 
<br>[[File:Motor 2.jpg|550px|frameless|thumb]]<br>




<br>
<br>
== Resource ==  
== Resource ==  


https://drive.google.com/open?id=1upaMVPVRjMjo9RGnhfdJh01JSdnL4EUN
https://fs.keyestudio.com/KS0298
 




<br>
<br>
==Get One Now ==
*[ Official website]
*[ Get one now on aliexpress store]


  [[Category: Shield]]
  [[Category: Shield]]

Latest revision as of 09:08, 5 March 2021

Keyestudio quick connectors Motor Drive Shield


Overview

There are many ways to drive the motor. Our robot uses the most commonly used L298P solution.
L298P is an excellent high-power motor driver IC produced by STMicroelectronics. It can directly drive DC motors, two-phase and four-phase stepping motors. The driving current up to 2A, and output terminal of motor adopts eight high-speed Schottky diodes as protection.

We have designed the motor driver shield based on the L298P circuit.
The stackable design can make it be plugged directly into the Arduino, reducing the technical difficulty of using and driving the motor.
Direct stack the motor driver shield onto UNO R3 board, after the BAT is powered on, press the POWER button, to supply the power for both keyestudio motor driver shield and UNO R3 board.

For simple wiring, the motor driver shield comes with anti-reverse PH2.0-(2P/3P/4P/ 5P) interfaces. When connecting the motor, power supply and sensor modules, you just need to plug in directly.
thumb

The Bluetooth interface on the motor driver shield is fully compatible with keyestudio Bluetooth module. When connecting, just plug Bluetooth module into the corresponding interface.

At the same time, the motor drive shield has brought out extra digital and analog ports in 2.54mm pin headers, so that you can continue to add other sensors for experiments extension.
The motor drive shield can access to 4 DC motors. The motor connector A and A1, connector B and B1 are separately in parallel, with the same motion law.
The shield comes with 4 fixing holes of 3mm, easy to mount on other devices.


thumb



Technical Details

  • Logic part input voltage: DC5V
  • Driving part input voltage: DC 7-12V
  • Logic part working current: <36mA
  • Driving part working current: <2A
  • Maximum power dissipation: 25W (T=75℃)
  • Working temperature: -25℃~+130℃
  • White connector: PH2.0- (2P/3P/4P/ 5P)
  • Pin/female header spacing:2.54mm
  • Fixing hole diameter: 3mm



PINOUT Diagram


thumb



Hookup Guide


thumb



Motor state settings


thumb



Test Code

int E1 = 9; //  set the speed pin of motor A as D9
int E2 = 5; //  set the speed pin of motor B as D5
int M1 = 2; // set the direction pin of motor A as D2
int M2 = 4; // set the direction pin of motor B as D4
        
void setup(void)
{
  pinMode(M1,OUTPUT); // set M1 as OUTPUT mode
  pinMode(M2,OUTPUT); // set M2 as OUTPUT mode
  pinMode(E1,OUTPUT); //  set E1 as OUTPUT mode
  pinMode(E2,OUTPUT); //  set E2 as OUTPUT mode
}
void advance(void)        // set the forward motion
{
  digitalWrite(M1,HIGH);  // motor A turns forward, the wheel will go forward.
  digitalWrite(M2,HIGH);  // motor B turns forward, the wheel will go forward. 
  analogWrite(E1,150);    // speed of motor A(can be adjusted according to the actual speed of motor. Turn up the value to accelerate, lower the value to decelerate.) 
  analogWrite(E2,150);    // speed of motor B(can be adjusted according to the actual speed of motor. Turn up the value to accelerate, lower the value to decelerate.) 
}  
void back(void)        // set the backward motion
{
 digitalWrite(M1,LOW);   // motor A turns reverse and the wheel will go backward
 digitalWrite(M2, LOW);   //  motor B turns reverse and the wheel will go backward
 analogWrite(E1,150);     //  speed of motor A
 analogWrite(E2, 150);    //  speed of motor B
}  

void turnL(void)     // set the left turn 
{
   digitalWrite(M1,LOW);    // motor A turns reverse and the wheel will go backward 
   digitalWrite(M2, HIGH);  // motor B turns forward and the wheel goes forward, the smart car will turn left.
   analogWrite(E1,150);  // speed of motor A
   analogWrite(E2, 150);  // speed of motor B
}

void turnR(void)            //  set the right turn 
{
   digitalWrite(M1,HIGH);   // motor A turns forward and the wheel will go forward 
   digitalWrite(M2,LOW);    // motor B turns reverse and the wheel goes backward, the smart car will turn right.
   analogWrite(E1,150);     // speed of motor A
   analogWrite(E2, 150);    // speed of motor B
}

void stopp(void)   // set the STOP
{
   digitalWrite(M1,LOW);  // motor A turns reverse
   digitalWrite(M2, LOW);  //  motor B turns reverse
   analogWrite(E1, 0);      //  speed of motor A, speed as zero, means stop
   analogWrite(E2, 0);      // speed of motor B, speed as zero, means stop
}

void loop() 
{ 
advance();   // go forward
delay(1000); // delay1S
back();      //backward
delay(1000);// delay1S

turnL();    //turn left
delay(1000);//delay1S
turnR();    //turn right  
delay(1000); //delay1S
stopp();   // stop
delay(1000);// delay1S
}


Test Result

Stack well the drive shield onto UNO R3 board, and upload the above code to the board, then press down the POWER button.
The 2 motors simulate the motion of smart car. Go forward for one second, backward for one second, and then turn left for one second, turn right for one second and stop one second, alternately repeating.
thumb



Resource

https://fs.keyestudio.com/KS0298