“MotorDriver IIC”的版本间的差异

来自YFRobotwiki
跳转至: 导航搜索
Arduino 扩展库使用方法
第35行: 第35行:
 
 调用库:
 
 调用库:
 
<source lang="c">
 
<source lang="c">
#include <MotorDriver_PCA9685.h>  // 包含头文件
+
#include <MotorDriver.h>  // 包含头文件
 
</source>
 
</source>
  
 
 创建对象:
 
 创建对象:
  
<source lang="c">MotorDriver_PCA9685 motorDirver = MotorDriver_PCA9685();</source>
+
<source lang="c">MotorDriver motorDirver = MotorDriver(YF_IIC_TB);</source>
  
 
'''方法 Methods:'''
 
'''方法 Methods:'''
第77行: 第77行:
  
 
<source lang="c">motorDirver.stopMotor(MAll);  // 电机M1/M2/M3/M4 刹车</source>
 
<source lang="c">motorDirver.stopMotor(MAll);  // 电机M1/M2/M3/M4 刹车</source>
 
 
  
 
=== 参考资料 ===
 
=== 参考资料 ===

2020年10月14日 (三) 16:13的版本

motor driver

购买:https://item.taobao.com/item.htm?id=626324653253

产品简介

IIC-四路电机驱动模块是采用堆叠式设计,可直接插于Arduino UNO主控板或其兼容板上的电机驱动模块。它集成了PCA9685芯片(一个I2C总线控制的16通道PWM控制器)、2片TB6612电机驱动芯片,只占用Arduino IIC端口(A4-SDA/A5-SCL)即可控制4路电机,IIC地址0x40。

IIC-四路电机驱动模块可直接连接M1、M2、M3、M4,4路电机,接口顺序:电机正极、电机负极、编码器负极、编码器正极、A相、B相;兼容本店多款电机:25、37、N20;且扩展5路IIC接口、1路VGTR串行通信接口、 6路3PGVS标准传感器接口、1路串行通信接口,扩展性强。


规格参数

  • 逻辑供电电压:5V DC
  • VIN电机供电电压:2.5V~13.5V DC(推荐6V~12VDC)
  • VS供电电压:跳线帽短接则为5V,不短接可外接4.8V~6V
  • IIC协议控制电机(IIC地址:0x40)
  • 5路IIC扩展口(V/G/D-sda/C-scl)
  • 1路UART串口通信扩展口(V/G/T-txd/R-rxd)
  • 6路GVS I/O扩展口(V由VS供电,通过跳线帽选择如何连接电源)
  • 4路电机接口(电机正极/电机负极/编码器负极/编码器正极/A相/B相)
  • 电源指示灯x1


功能说明

MotorDriver IIC.png


Arduino 扩展库

Arduino library : https://github.com/YFROBOT-TM/Yfrobot-Motor-Driver-Library

Arduino 扩展库使用方法

调用库:

#include <MotorDriver.h>   // 包含头文件

创建对象:

MotorDriver motorDirver = MotorDriver(YF_IIC_TB);

方法 Methods:

初始化

motorDirver.begin();

设置单个电机反向,参数:0-默认,1-反向

motorDirver.setMotorDirReverse(0, 1, 0, 1);// M1/M3 默认方向 M2/M4反向

设置所有电机反向, 0-默认,1-反向

motorDirver.setMotorDirReverse(0); // 所有电机默认方向

驱动单个电机,参数:电机序号 M1,M2,M3,M4;电机速度 -4096~4096

motorDirver.setSingleMotor(M1, 4096);   // M1电机全速正转
motorDirver.setSingleMotor(M1, 0);   // M1电机停止

驱动4路电机,参数:电机速度 -4096~4096

motorDirver.setMotor(0, 4096, 2048,1024);  // 电机M1停止,电机M2 全速正转,电机M3 50%正转,电机M4 25%正转
motorDirver.setMotor(0, 0, 0, 0);  // 电机M1/M2/M3/M4停止
motorDirver.setAllMotor(4096); // 电机M1/M2/M3/M4 全速正转
motorDirver.setAllMotor(0);  // 电机M1/M2/M3/M4停止

电机刹车/急停

motorDirver.stopMotor(M1);  // 电机M1 刹车
motorDirver.stopMotor(MAll);  // 电机M1/M2/M3/M4 刹车

参考资料





返回首页

更多建议和问题欢迎反馈至 YFRobot论坛

购买方式:YFRobot 电子工作室