查看(SKU:DFR0398)Romeo BLE Quad的源代码
←
(SKU:DFR0398)Romeo BLE Quad
跳转至:
导航
、
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
[[文件:DFR0398.jpg|thumb|300px|right|Romeo BLE Quad]] ==简介== Romeo BLE Quad 是基于Bluno M3的二次设计版本,继承Bluno系列的全部特性,支持蓝牙无线编程,无线通信和手机无线控制功能。同时Romeo BLE Quad还增加了四路电机驱动,配合板载的编码器接口,可直接实现机器人PID闭环反馈控制。并且主控器还外扩了Gravity 3Pin管脚接口,可直插Gravity系列传感器模块,方便实用,体积小巧。<br> Romeo BLE Quad相比其他的Romeo机器人主控拥有更加强大的处理性能,这全都得益于它与众不同的处理核心。32位主控器相比传统的Arduino UNO 8位单片机,在性能上拥有显著的优势,但它的开发环境较为复杂,开发难度也相对较高。而Romeo BLE Quad不同于以往其他的32位主控,在保留了其强大性能的同时,也兼容了Arduino的简单方便的使用方法。极大的降低了它的使用难度。<br> Romeo BLE Quad外扩10个数字管脚和5个模拟管脚,管脚与电机驱动相互独立,无冲突。支持舵机外部供电,保证系统能够稳定运行。主控器板载电源管理系统,支持USB和外接电源自动切换,可直连USB供电或7-10v的宽电压供电,并支持传统STM32 SWD编程调试。<br> :{|style="background-color:#F2DEDE; color:#B84442; padding:10px;" |-style="vertical-align:top;" |[[File:warning_yellow.png|center]] | 注意:Romeo BLE Quad I/O口工作电压为3.3V,使用前请先阅读[http://wiki.dfrobot.com.cn/index.php?title=(SKU:DFR0398)Romeo_BLE_Quad#.E5.BC.95.E8.84.9A.E8.AF.B4.E6.98.8E 引脚说明],切勿直接外接5V设备,以免损坏芯片管脚。 |} <br> ==产品参数== *微控制器: STM32 F103RET6 *时钟速度: 72MHz *蓝牙芯片: TI CC2540 (蓝牙4.0) *通信距离: 30 m *直流电机:4路 *工作电压: 3.3V *输入电压: 5V(USB)/7~10V *支持USB与外接供电自动切换 *数字IO口: 10 *模拟输入: 5 *I2C/IIC: 默认为SDA (30)和SCL(29),软件I2C可以指定任意两个数字口作为I2C的SDA和SCL *SRAM: 64K *Flash: 512K **默认用户代码空间:492K **默认用户数据空间:20K *串口2个:Serial1、Serial3 **Serial1 0 (Rx1) 和 1 (Tx1) **Serial3 30(Rx3) 和 29(Tx3) *尺寸: 67 x 42 (mm) *重量: 54g <br> {|style="background-color:#FCF8E3;color:#8A6D3B;" |style="padding: 10px;"| 注意:Romeo BLE Quad的串口是从Serial1开始的,Serial1负责USB通信和蓝牙通信,使用串口监视器或者蓝牙通信时,需要把代码中的'''Serial'''改为'''Serial1''' |} <br> 电机驱动芯片HR8833参数 *双通道H桥电流控制电机驱动器 *驱动两路直流电机 *1500mA驱动输出(单路) *宽电压供电2.7V-10.8V ==引脚说明== [[image:1.Romeo BLE Quad-drive顶层引脚图.png|800px|border|顶层引脚图]] <br> :{| style="width:450px; height:250px;text-align:center" |+数字IO口使用表 |-style="background-color:#63B7CE;text-align:center" | '''电机'''||'''电机控制IO口1'''||'''电机控制IO口2'''||'''编码器接口A'''||'''编码器接口B''' |- |-style="text-align:center;" | M1 || 8 || 23 || 12 || 11 |- |- style="background-color:#B7DDE8;text-align:center; " | M2 || 7 || 9 || 2 || 3 |- |-style="text-align:center;" | M3 || 24 || 14 || 5 || 26 |- |- style="background-color:#B7DDE8;text-align:center;" | M4 || 4 || 25 || 35 || 36 |- |} :{|style="background-color:#FCF8E3;color:#8A6D3B;" |style="padding: 10px;"| 注:Romeo BLE Quad 采用了两块HR8833电机驱动,驱动方式与常规的L298稍有不同,具体逻辑可见[[(SKU:DRI0040)Motor driver-HR8833 双路直流电机驱动模块]]<br> Romeo BLE Quad PID调速时将使用快速衰减模式(已封装在库中,仅需了解):<br> 正转:电机控制器脚1为低,电机控制脚2为PWM输出 <br> 反转:电机控制器脚2为低,电机控制脚1为PWM输出 <br> |} :{|style="background-color:#F2DEDE; color:#B84442; padding:10px;" |-style="vertical-align:top;" |[[File:warning_yellow.png|center]] | 特别注意:Romeo BLE Quad I/O口工作电压为3.3V,使用前请先阅读引脚说明,切勿直接外接5V设备,以免损坏芯片管脚。 *3.3V only:D20, D27, D28 *5V兼容:D0, D1, D29, D30, D31, D32, D33 *模拟管脚A0~A4都配有5V分压电阻,所以当外部输入为0~5V时,输出0~1023模拟量 |} ==使用教程== ===Arduino 环境搭建=== 在正式使用Romeo BLE Quad前,我们需要安装它的编译环境,由于Romeo BLE Quad是Bluno M3的二次开发版,我们可以把他看做为“Bluno M3 + Bluno M3扩展板 + 2 x HR8833电机驱动”的集成板,管脚映射和定义上与Bluno M3保持了一致,请参考Bluno M3编译环境篇:<br> <u><big><big>[[Bluno M3 V2.2 安装开发环境]]</big></big></u>\快速入门 ===电机PID调速=== 本教程将使用[http://www.dfrobot.com.cn/goods-1272.html JS02 L型带编码器电机]为例,设置速度时应考虑几个重要参数: *采样周期setSampleTime(本例为100(ms),即0.1s) *采样周期内正交编码器所计的个数motorSpeed(设定:200) *电机编码器极数(本例为16) *电机减速比(本例为120) {|style="background-color:#FCF8E3;color:#8A6D3B;" |style="padding: 10px;"| 例如:当电机编码器为16极时,编码器转一圈增量为16*2=32。假设编码器得到200个脉冲数时,则编码器速度为200÷0.1(s)÷32 = 62.5 r/s = 62.5*60 r/min =3750r/min,则电机速度为3750/120=31.25r/min。 |} *本例程把大部分功能都已经封装在库内了,有时需要修改打印内容,可以在Motor.cpp第241行中修改。如下图所示 [[image:MotorCPP.png|400px|border]] <br> {|style="width:100%;background-color:#F9E3B8;" | ===准备=== |} *'''硬件''' **Romeo BLE Quad x1 **[http://wiki.dfrobot.com.cn/index.php?title=(SKU:FIT0458)Micro_DC_Motor_with_Encoder-SJ02_微型直流带编码器L型减速电机 微型直流带编码器L型减速电机] x4 **杜邦线 若干 *'''软件''' **参考[[(SKU:DFR0329)Bluno M3控制器 兼容Arduino]]\快速入门 <br> {|style="width:100%;background-color:#F9E3B8;" | ===接线图=== |} [[image:1.Romeo BLE Quad-drive连线图.png|800px|certer|连线图]] {|style="background-color:#FCF8E3;color:#8A6D3B;" |style="padding: 10px;"| 注:本图只以M4为例子,其他M1、M2、M3的连接方式和M4是相同的 |} <br> {|style="width:100%;background-color:#F9E3B8;" | ===样例代码=== |} 点击下载库文件[https://github.com/lfwag/RomeoBLEQuadDrive.git 例程和Motor.h库文件]和[https://github.com/lfwag/PID_V1.git PID_V1.h库文件] :{|style="width:100%;" |style="padding: 10px;"| <pre style="color:blue;"> /*! * @file RemeoBLEQuadDrive.ino * @brief RemeoBLEQuadDrive.ino PID control system of DC motor * * RemeoBLEQuadDrive.ino Use PID control 4 way DC motor direction and speed * * @author linfeng(490289303@qq.com) * @version V1.0 * @date 2016-4-14 */ #include "PID_v1.h" #include "Motor.h" Motor motor[4]; int motorSpeed[4] = {-200,200,400,-400};/*Set 4 speed motor*/ /* Speed=motorSpeed/(32*(setSampleTime/1000))(r/s) */ const int motorDirPin[4][2] = { //Forward, Backward /*Motor-driven IO ports*/ {8,23}, {7,9}, {24,14}, {4,25} }; //const double motorPidParam[3]={0.6,1,0.03};/*DC MOTOR,Yellow??180degree*/ //const double motorPidParam[3]={1.5,1,0.05};/*DC MOTOR,Yellow??90 degree*/ const double motorPidParam[3]={1.2,0.8,0.05};/*Encoder V1.0,160rd/min ;19500/min; 32:1,Kr=3.5*/ void setup( void ) { Serial1.begin(115200); for(int i=0;i<4;i++){ motor[i].setPid(motorPidParam[0],motorPidParam[1],motorPidParam[2]);/*Tuning PID parameters*/ motor[i].setPin(motorDirPin[i][0],motorDirPin[i][1]);/*Configure IO ports*/ motor[i].setSampleTime(100);/*Sets the sampling period*/ motor[i].setChannel(i);/*Sets the motor channel */ motor[i].ready();/*Motor enable*/ motor[i].setSpeed(motorSpeed[i]);/*Set motor speed*/ } } void loop( void ) { for(int i = 0; i < 4; i++){ motor[i].calibrate();/*motor PID calibrate*/ } } /****************************************************************************** Copyright (C) <2016> <linfeng> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Contact: 490289303@qq.com ******************************************************************************/ </pre> |} <br> {|style="width:100%;background-color:#F9E3B8;" | ===结果=== |} <br> 电机按照设置的速度和方向运行。 <br><br> ==疑难解答== {|style="background-color:#78CDF8;color:#000000;" |style="padding: 10px;"| 更多问题及有趣的应用,可以 [http://www.dfrobot.com.cn/community/forum.php '''访问论坛'''] 进行查阅或发帖! |} <br> ==更多== *[http://www.dfrobot.com.cn/images/upload/File/DFR0398/20161101162846c2u66v.pdf 原理图] *[http://wiki.dfrobot.com.cn/index.php?title=(SKU:DFR0329)Bluno_M3%E6%8E%A7%E5%88%B6%E5%99%A8_%E5%85%BC%E5%AE%B9Arduino Bluno M3产品维库] *[[Bluno M3 V2.2 安装开发环境]] (注意:Romeo BLE Quad 基于Bluno M3 V2.2硬件版本设计) *[http://wiki.dfrobot.com.cn/index.php?title=(SKU:DRI0040)Motor_driver-HR8833_%E5%8F%8C%E8%B7%AF%E7%9B%B4%E6%B5%81%E7%94%B5%E6%9C%BA%E9%A9%B1%E5%8A%A8%E6%A8%A1%E5%9D%97 HR8833 产品维库] <br> [[image:shopping_car.png|link=http://www.dfrobot.com.cn/index.php?route=common/home]] [http://www.dfrobot.com.cn/goods-1358.html DFRobot商城购买链接]
返回
(SKU:DFR0398)Romeo BLE Quad
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面