Difference between revisions of "Motor Pro Shield"
Qian.zhang (talk | contribs) (→Introduction) |
Qian.zhang (talk | contribs) (→Schematic) |
||
Line 23: | Line 23: | ||
*[https://s3.amazonaws.com/linksprite/Shields/Motor+Pro+Shield/MotorProShield.PDF Motor Pro Shield Schematic] | *[https://s3.amazonaws.com/linksprite/Shields/Motor+Pro+Shield/MotorProShield.PDF Motor Pro Shield Schematic] | ||
+ | |||
+ | == Usage == | ||
+ | |||
+ | <syntaxhighlight lang="c"> | ||
+ | |||
+ | //Motor pro shield test code | ||
+ | |||
+ | int M1_AIN1 = 11; | ||
+ | int M1_AIN2 = 14; | ||
+ | int M1_BIN1 = 10; | ||
+ | int M1_BIN2 = 15; | ||
+ | |||
+ | int M2_AIN1 = 9; | ||
+ | int M2_AIN2 = 20; | ||
+ | int M2_BIN1 = 3; | ||
+ | int M2_BIN2 = 22; | ||
+ | |||
+ | int M1_R = 16; | ||
+ | int M1_L = 17; | ||
+ | int M2_L = 21; | ||
+ | int M2_R = 23; | ||
+ | |||
+ | void Setpin() | ||
+ | { | ||
+ | pinMode(M1_AIN2,OUTPUT); | ||
+ | pinMode(M1_BIN2,OUTPUT); | ||
+ | pinMode(M2_AIN2,OUTPUT); | ||
+ | pinMode(M2_BIN2,OUTPUT); | ||
+ | |||
+ | pinMode(M1_R,OUTPUT); | ||
+ | pinMode(M1_L,OUTPUT); | ||
+ | pinMode(M2_L,OUTPUT); | ||
+ | pinMode(M2_R,OUTPUT); | ||
+ | } | ||
+ | |||
+ | //****************************** | ||
+ | // MA1 and MB1 control function | ||
+ | //****************************** | ||
+ | void M1A_Forward(int speed) | ||
+ | { | ||
+ | analogWrite(M1_AIN1,speed); | ||
+ | digitalWrite(M1_AIN2,LOW); | ||
+ | } | ||
+ | void M1A_Reverse(int speed) | ||
+ | { | ||
+ | analogWrite(M1_AIN1,speed); | ||
+ | digitalWrite(M1_AIN2,HIGH); | ||
+ | } | ||
+ | void M1A_Stop() | ||
+ | { | ||
+ | analogWrite(M1_AIN1,0); | ||
+ | digitalWrite(M1_AIN2,LOW); | ||
+ | } | ||
+ | /******************************/ | ||
+ | void M1B_Forward(int speed) | ||
+ | { | ||
+ | analogWrite(M1_BIN1,speed); | ||
+ | digitalWrite(M1_BIN2,LOW); | ||
+ | } | ||
+ | void M1B_Reverse(int speed) | ||
+ | { | ||
+ | analogWrite(M1_BIN1,speed); | ||
+ | digitalWrite(M1_BIN2,HIGH); | ||
+ | } | ||
+ | void M1B_Stop() | ||
+ | { | ||
+ | analogWrite(M1_BIN1,0); | ||
+ | digitalWrite(M1_BIN2,LOW); | ||
+ | } | ||
+ | |||
+ | //****************************** | ||
+ | // M2A and M2B control function | ||
+ | //****************************** | ||
+ | void M2A_Forward(int speed) | ||
+ | { | ||
+ | analogWrite(M2_AIN1,speed); | ||
+ | digitalWrite(M2_AIN2,LOW); | ||
+ | } | ||
+ | void M2A_Reverse(int speed) | ||
+ | { | ||
+ | analogWrite(M2_AIN1,speed); | ||
+ | digitalWrite(M2_AIN2,HIGH); | ||
+ | } | ||
+ | void M2A_Stop() | ||
+ | { | ||
+ | analogWrite(M2_AIN1,0); | ||
+ | digitalWrite(M2_AIN2,LOW); | ||
+ | } | ||
+ | /******************************/ | ||
+ | void M2B_Forward(int speed) | ||
+ | { | ||
+ | analogWrite(M2_BIN1,speed); | ||
+ | digitalWrite(M2_BIN2,LOW); | ||
+ | } | ||
+ | void M2B_Reverse(int speed) | ||
+ | { | ||
+ | analogWrite(M2_BIN1,speed); | ||
+ | digitalWrite(M2_BIN2,HIGH); | ||
+ | } | ||
+ | void M2B_Stop() | ||
+ | { | ||
+ | analogWrite(M2_BIN1,0); | ||
+ | digitalWrite(M2_BIN2,LOW); | ||
+ | } | ||
+ | |||
+ | void Motor_test() | ||
+ | { | ||
+ | M1A_Forward(100); | ||
+ | delay(2000); | ||
+ | M1A_Stop(); | ||
+ | delay(1000); | ||
+ | M1A_Reverse(10); | ||
+ | delay(2000); | ||
+ | M1A_Stop(); | ||
+ | delay(3000); | ||
+ | } | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | Setpin(); | ||
+ | M1A_Stop(); | ||
+ | M1B_Stop(); | ||
+ | M2A_Stop(); | ||
+ | M2B_Stop(); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | M1A_Forward(100); | ||
+ | M1B_Forward(100); | ||
+ | M2A_Forward(100); | ||
+ | M2B_Forward(100); | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> |
Revision as of 07:32, 4 November 2014
Introduction
Motor Pro Shield is a 4 channel motor driver board which bases on TI - DRV8801. Specifically for pcDuino users to make their own robots, this shield provides rich interfaces.
- 4 Motor driver interface
- 4 Linker kit interface(ADC、UART、GPIO、PWM)
- 2 Ultrasonic interface
- 1 9-axis module interface
- 2 Infrared tube interface
- Independent switch for motor power supply
- Over current protection
Specification
Spec of DRV8801
Schematic
Usage
<syntaxhighlight lang="c">
//Motor pro shield test code
int M1_AIN1 = 11; int M1_AIN2 = 14; int M1_BIN1 = 10; int M1_BIN2 = 15;
int M2_AIN1 = 9; int M2_AIN2 = 20; int M2_BIN1 = 3; int M2_BIN2 = 22;
int M1_R = 16; int M1_L = 17; int M2_L = 21; int M2_R = 23;
void Setpin() {
pinMode(M1_AIN2,OUTPUT); pinMode(M1_BIN2,OUTPUT); pinMode(M2_AIN2,OUTPUT); pinMode(M2_BIN2,OUTPUT); pinMode(M1_R,OUTPUT); pinMode(M1_L,OUTPUT); pinMode(M2_L,OUTPUT); pinMode(M2_R,OUTPUT);
}
//****************************** // MA1 and MB1 control function //****************************** void M1A_Forward(int speed) {
analogWrite(M1_AIN1,speed); digitalWrite(M1_AIN2,LOW);
} void M1A_Reverse(int speed) {
analogWrite(M1_AIN1,speed); digitalWrite(M1_AIN2,HIGH);
} void M1A_Stop() {
analogWrite(M1_AIN1,0); digitalWrite(M1_AIN2,LOW);
} /******************************/ void M1B_Forward(int speed) {
analogWrite(M1_BIN1,speed); digitalWrite(M1_BIN2,LOW);
} void M1B_Reverse(int speed) {
analogWrite(M1_BIN1,speed); digitalWrite(M1_BIN2,HIGH);
} void M1B_Stop() {
analogWrite(M1_BIN1,0); digitalWrite(M1_BIN2,LOW);
}
//****************************** // M2A and M2B control function //****************************** void M2A_Forward(int speed) {
analogWrite(M2_AIN1,speed); digitalWrite(M2_AIN2,LOW);
} void M2A_Reverse(int speed) {
analogWrite(M2_AIN1,speed); digitalWrite(M2_AIN2,HIGH);
} void M2A_Stop() {
analogWrite(M2_AIN1,0); digitalWrite(M2_AIN2,LOW);
} /******************************/ void M2B_Forward(int speed) {
analogWrite(M2_BIN1,speed); digitalWrite(M2_BIN2,LOW);
} void M2B_Reverse(int speed) {
analogWrite(M2_BIN1,speed); digitalWrite(M2_BIN2,HIGH);
} void M2B_Stop() {
analogWrite(M2_BIN1,0); digitalWrite(M2_BIN2,LOW);
}
void Motor_test() {
M1A_Forward(100); delay(2000); M1A_Stop(); delay(1000); M1A_Reverse(10); delay(2000); M1A_Stop(); delay(3000);
}
void setup() {
Setpin(); M1A_Stop(); M1B_Stop(); M2A_Stop(); M2B_Stop();
}
void loop() {
M1A_Forward(100); M1B_Forward(100); M2A_Forward(100); M2B_Forward(100);
}
</syntaxhighlight>