找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 13290|回复: 3
打印 上一主题 下一主题
收起左侧

用Arduino控制无刷电机电调的最简方法

[复制链接]
跳转到指定楼层
楼主
关于电调的控制信号:电调信号是pwm信号,信号频率为50Hz,一个周期为20ms。对于电调来讲,高电平脉宽为1ms表示停转,高电平脉宽为2ms表示满油门运转;对于舵机来说1.5ms是归中,1ms和2ms分别为左右满舵。(因此下面才直接用Servo库来给实现ESC信号的输出)。

关于Servo.write()Servo.writeMicroseconds()
0.Servo.writeMicroseconds(): Writes a value in microseconds (uS) tothe servo, controlling the shaft accordingly. On a standard servo, this willset the angle of the shaft. On standard servos a parameter value of 1000 isfully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle.
1.servo.write() allows a maximum of 180 servo positions
  servo.writeMicroseconds() allows a maximum of 1000 servo positions
2.The "write" method simply maps the"degrees" to microseconds and calls the "writeMicroseconds"method anyway.
   The "degree" of turn is simply a convenientabstraction, and few bother to calibrate it.
控制程序:

1.  #include<Servo.h> // Using servo library to control ESC
2.  Servo esc; //Creating a servo class with name as esc
3.  int val; //Creating a variable val
4.  void setup()
5.  {
6.  esc.attach(9); //Specify the esc signal pin,Here as D9
7.  esc.writeMicroseconds(1000);// initialize the signal to 1000
8.  Serial.begin(9600);
9.  }
10. void loop()
11. {
12. val=analogRead(A0); // Read input from analog pin a0 and store in val
13. val= map(val, 0,1023,1000,2000); // mapping val to minimum and maximum(Change if needed)
14. Serial.println(val);
15. esc.writeMicroseconds(val);// using val as the signal to esc
16. }
补充:电调1ms停转,2ms满油门运转,是指的单向电调,且是方波脉冲。而一般双向电调,1ms反转最大油门,1.5油门中点,2ms满油门正转。


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶1 踩
回复

使用道具 举报

沙发
ID:514567 发表于 2019-7-28 20:27 | 只看该作者
正好需要,谢谢楼主
回复

使用道具 举报

板凳
ID:79544 发表于 2019-9-3 08:53 | 只看该作者
感谢楼主分享,学习啦!!!!!
回复

使用道具 举报

地板
ID:728839 发表于 2021-1-12 20:09 | 只看该作者
怎么同时控制四个电调呢?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表