Skip to content

Commit

Permalink
review all code
Browse files Browse the repository at this point in the history
  • Loading branch information
ken committed Nov 19, 2021
1 parent 17a1926 commit 4a9912a
Show file tree
Hide file tree
Showing 61 changed files with 1,051 additions and 942 deletions.
80 changes: 67 additions & 13 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# MotorDriverBoard
[English](README.md) 中文版

MotorDriverBoard是由 [深圳市易创空间科技有限公司](www.emakefun.com),专门针对Arduino Uno(兼容Mega2560)机器人,电机驱动,多路舵机控制而研发的一款多功能电机驱动扩展板。本驱动板采用I2C方式控制[PCA9685](./doc/pca9685.pdf)(16路PWM输出芯片)。所以本驱动板电机或者舵机不存在和arduino口的对应关系,是通过I2C扩展PWM控制,详情请见[驱动板原理图](./doc/MotorDriverBoard_V5.1.pdf)
MotorDriverBoard是由 [深圳市易创空间科技有限公司](www.emakefun.com),专门针对Arduino Uno(兼容Mega2560)机器人,电机驱动,多路舵机控制而研发的一款多功能电机驱动扩展板。本驱动板采用I2C方式控制[PCA9685](./doc/pca9685.pdf)(16路PWM输出芯片)。所以本驱动板电机或者舵机和arduino主板IO口不存在对应关系,是通过I2C扩展PWM控制,详情请见[驱动板原理图](./doc/MotorDriverBoard_V5.1.pdf)

MotorDrvierBoard for Arduino UNO(Arduino Mega2560)
MotorDriverBoard for Arduino Uno(Arduino Mega2560)

![MotorDriverBoard_0](./doc/picture/ZH/MotorDriverBoard_show0.jpg)

### 快速链接

[arduino ide库文件下载]()

[mixly库下载]()

[mblock5库下载]()

[mind+库下载]()

[MaigcBlock下载]()

## 特点

- 支持4路直流电机,最大驱动电流3A
- 支持驱动8路舵机,带自恢复保险丝,防止舵机堵转
- 支持驱动2路4线步进电机
Expand All @@ -29,7 +42,7 @@ MotorDrvierBoard for Arduino UNO(Arduino Mega2560)
### 供电说明
- 通过Uno的DC(6~12)头单一电源供电,舵机供电

**PS2控制6V以上的电机时,为了确保PS2不断连,建议使用航模电池或者大电流21700锂电池,两节18650供电有压力**
**PS2控制9V以上的电机时,为了确保PS2不断连,建议使用航模电池或者大电流21700锂电池,两节18650供电有压力**

![MotorDriverBoard_dc_power_supply](./doc/picture/ZH/dc_power_supply.png)

Expand All @@ -51,10 +64,14 @@ MotorDrvierBoard for Arduino UNO(Arduino Mega2560)

## 驱动库使用

[下载arduino库]()放置Arduino IDE安装目录下的libraries目录下如下图

![examples](./doc./picture./ZH./examples.png)



## 基础示例程序
[**gpiotest**](examples/gpiotest/gpiotest.ino) 控制PCA9685输出口当作普通IO口输出高低电平
[**gpio_test**](./arduino_lib/examples/base/gpio_test/gpio_test.ino) 控制PCA9685输出口当作普通IO口输出高低电平

```c++
gpio.begin(1000); /*初始化io口的输出频率为1KHz*/
Expand All @@ -64,7 +81,7 @@ gpio.setPin(S1, LOW); /*引脚S1(S1~S8)输出低电平*/



[**pwmtest**](examples/pwmtest/pwmtest.ino) 这个示例程序为控制PCA9685输出口输出PWM波形
[**pwm_test**](./arduino_lib/examples/base/pwm_test/pwm_test.ino) 这个示例程序为控制PCA9685输出口输出PWM波形

```c++
pwm.begin(1500); /*初始化io口的输出频率为1500Hz*/
Expand All @@ -78,20 +95,51 @@ DCMotor_1->run(FORWARD);
/*控制电机运行状态(FORWARD(前)、BACKWARD(后)、BRAKE(停止))*/
```
**[ps2_test](./arduino_lib/examples/base/ps2_test/ps2_test.ino)**PS2手柄测试程序
PS2安装如下:
## 电机测试示例
[**dc**](./arduino_lib/examples/motor_test/dc/dc.ino)四路直流电机测试程序
```c++
Emakefun_MotorDriver mMotor = Emakefun_MotorDriver(0x60);
Emakefun_DCMotor *DCMotor_1 = mMotor.getMotor(M1);
void setup()
{
Serial.begin(9600);
mMotor.begin(50);
}
void loop()
{
// 前进
DCMotor_1->setSpeed(200); //速度0~255
DCMotor_1->run(FORWARD); // 总共FORWARD前进,BACKWARD后退,BRAKE刹车 RELEASE释放四个状态
}
```

**接线图**![MotorDriverBoard_dc](./doc/picture/ZH/dc.png)

[**servo**](examples/servo/servo.ino)八路舵机测试程序


[**servo**](./arduino_lib/examples/motor_test/servo/servo.ino)八路舵机测试程序

```c++
mMotorDriver.begin(50); /*初始化io口的输出频率为50Hz*/
mServo1->writeServo(0); /*设置舵机角度 0~180*/
mServo1->writeServo(S1); /*设置舵机角度 0~180*/
```
**接线图**![MotorDriverBoard_servo](./doc/picture/ZH/servo.png)
**接线图**![MotorDriverBoard_servo](./doc/picture/ZH/servo.png)

[**stepper**](examples/stepper/stepper.ino) 步进电机测试程序
[**stepper**](./arduino_lib/examples/motor_test/stepper/stepper.ino) 步进电机测试程序
```c++
Emakefun_StepperMotor *StepperMotor_1 = mMotorDriver.getStepper(1, 200);
Expand All @@ -109,7 +157,7 @@ StepperMotor_1->step(200, FORWARD, DOUBLE);

**接线图**![MotorDriverBoard_stepper](./doc/picture/ZH/stepper.png)

[**encoder**](examples/encoder/encoder.ino)4路直流电机测试程序
[**encoder**](./arduino_lib/examples/motor_test/encoder/encoder.ino)4路直流电机测试程序

```c++
mMotorDriver.begin(); /*初始化io口的输出频率默认为最大*/
Expand Down Expand Up @@ -150,15 +198,21 @@ MsTimer2::start(); /*启动定时器2*/
**接线图**
编码电机我们使用的是6pin的GH1.25转PH2.0线材接线如下:
## 综合应用
[PS2控制四驱小车](examples/ps2ControlCar/ps2ControlCar.ino)
[PS2控制四驱小车](./examples/ps2ControlCar/ps2ControlCar.ino)
[PS2控制四驱麦克纳姆轮小车](examples/ps2ControlMecanumWheel/ps2ControlMecanumWheel.ino)
[PS2控制四驱小车加机械臂](examples/ps2ControlCarAndRoboticArm/ps2ControlCarAndRoboticArm.ino)
[蓝牙(WIFI)控制四驱小车](examples/ble/ble.ino)
[蓝牙(WIFI)控制四驱小车](./arduino_lib/examples/ble/ble.ino)
蓝牙或者wifi模块请使用数据透传模块,连接到arduino的硬件串口引脚上(0-RXD,1-TXD)
## 图像化编程块说明
Expand Down
File renamed without changes.
Loading

0 comments on commit 4a9912a

Please sign in to comment.