当前位置: 首页 > news >正文

重庆网站建设公司 十年网站接广告

重庆网站建设公司 十年,网站接广告,建筑工程网上教育平台,中国建筑集团有限公司公章图片轮趣科技 42步进电机arduino:WHEELTEC_MS42DDC 接线方式: WHEELTEC_MS42DDC有两个接口, 一端接口连接配套的DC电源,另外一端只需要用三根线,一根负极连接ardino 的GND,然后把该端口的tx和rx连接到arduino的rx和tx,下…

轮趣科技

42步进电机+arduino:WHEELTEC_MS42DDC

接线方式:

请添加图片描述WHEELTEC_MS42DDC有两个接口,在这里插入图片描述
一端接口连接配套的DC电源,另外一端只需要用三根线,一根负极连接ardino 的GND,然后把该端口的tx和rx连接到arduino的rx和tx,下面代码中用的serial2对应arduino mega中的16和17;千万别接错正负极。

代码如下

#include <Arduino.h>// 定义串口通信的波特率,根据 MS42DC 电机的 USB 串口控制协议,波特率为 115200
const long baudRate = 115200;// 帧头,为固定值 0x7B
const byte START_BYTE = 0x7B;
// 控制 ID,现在为 0x02
const byte CONTROL_ID = 0x01;void setup() {// 初始化调试串口Serial.begin(115200);while (!Serial) delay(1);// 初始化与电机通信的串口Serial2.begin(baudRate);Serial.println("Serial communication initialized");
}// 发送控制信息到电机的函数
void sendMotorCommand(byte controlMode, byte direction, byte microstepping, int value1, int value2) {byte command[11];// 帧头command[0] = START_BYTE;// 控制 IDcommand[1] = CONTROL_ID;// 控制模式command[2] = controlMode;// 转向command[3] = direction;// 细分值command[4] = microstepping;// 数据字节 1command[5] = highByte(value1);// 数据字节 2command[6] = lowByte(value1);// 数据字节 3command[7] = highByte(value2);// 数据字节 4command[8] = lowByte(value2);// 计算 BCC 校验位,为前面九个字节的异或和byte bcc = command[0] ^ command[1] ^ command[2] ^ command[3] ^ command[4] ^ command[5] ^ command[6] ^ command[7] ^ command[8];command[9] = bcc;// 帧尾command[10] = 0x7D;Serial2.write(command, 11);Serial.print("Sent command to motor: ");for (int i = 0; i < 11; i++) {Serial.print(command[i], HEX);Serial.print(" ");}Serial.println();
}void loop() {// // 速度控制模式示例// sendMotorCommand(0x01, 1, 0x20, 0, 0x0064); // 顺时针,32 细分,速度为 10 Rad/s// delay(1000);// // 位置控制模式示例// sendMotorCommand(0x02, 0, 0x20, 0x2710, 0x0064); // 逆时针,32 细分,位置为 1000 度,速度为 10 Rad/s// delay(1000);// // 力矩控制模式示例// sendMotorCommand(0x03, 1, 0x20, 0x03E8, 0x0064); // 顺时针,32 细分,电流为 1000 mA,速度为 10 Rad/s// delay(1000);// 单圈绝对角度控制模式示例sendMotorCommand(0x04, 0, 0x20, 0x04B0, 0x0064); // 逆时针,32 细分,目标角度为 100 度,速度为 10 Rad/sdelay(1000);sendMotorCommand(0x04, 0, 0x20, 0x03E8, 0x0064); // 逆时针,32 细分,目标角度为 100 度,速度为 10 Rad/sdelay(1000);sendMotorCommand(0x04, 0, 0x20, 0x0320, 0x0064); // 逆时针,32 细分,目标角度为 100 度,速度为 10 Rad/sdelay(1000);sendMotorCommand(0x04, 0, 0x20, 0x0258, 0x0064); // 逆时针,32 细分,目标角度为 100 度,速度为 10 Rad/sdelay(1000);// 接收电机的状态反馈(如果有)if (Serial2.available() > 0) {byte buffer[32];int bytesRead = Serial2.readBytes(buffer, Serial2.available());Serial.print("Received ");Serial.print(bytesRead);Serial.println(" bytes from motor:");for (int i = 0; i < bytesRead; i++) {Serial.print(buffer[i], HEX);Serial.print(" ");}Serial.println();}
}
http://www.hkea.cn/news/357927/

相关文章:

  • 新建网站推广给企业百度问一问在线咨询客服
  • 曹鹏wordpress建站seo视频广东疫情防控措施
  • 网站开发的岗位排名优化工具
  • 岳阳做网站怎么做推广让别人主动加我
  • 不断改进网站建设公司百度官网优化
  • 万户网站宁波网站制作优化服务
  • 潍坊快速网站排名网站是怎么做出来的
  • 聚美优品的pc网站建设注册网址
  • 陕西省住房与城乡建设厅网站免费b站推广软件
  • 淮南市住房与城乡建设部网站网店买卖有哪些平台
  • 网页qq表情佛山百度快速排名优化
  • 网站建设方案论文1500社会新闻最新消息
  • 网站组建 需求分析市场监督管理局职责
  • 云课堂哪个网站做的好厦门关键词优化seo
  • 中企动力沈阳分公司seo免费诊断电话
  • 网站vps被黑湖人最新排名最新排名
  • 如何夸奖客户网站做的好seo课程心得体会
  • 有哪些做电子商务的网站时空seo助手
  • 临沂百度网站电脑培训机构哪个好
  • 无锡专业做网站的公司怎样把自己的产品放到网上销售
  • 大学网站建设管理办法推广技巧
  • 长春做网站公司seo关键词排名优化软件怎么选
  • 网站开发未按合同约定工期完工seo关键词排名怎么提升
  • 创可贴app海报制作网站百度seo优化方法
  • 龙岗品牌网站建设2024年新闻摘抄
  • 南阳住房和城乡建设厅网站招聘网站排名
  • 如何做网站活动封面建站的公司
  • 温州网站建设培训营销推广方案包括哪些内容
  • 厦门 建网站商业软文案例
  • wordpress读者墙站长之家seo工具包