我的伺服系统试图超越其极限并且不会停止,直到我拔掉它,并迫使它进入正常位置

问题描述 投票:0回答:1

我刚刚为我的 Arduino 购买了 4 个数字塔式专业 MG996R 高扭矩 180° 伺服系统。 因此,我将它们放入经典扫描测试中,但是过了一段时间。它毫无理由地开始顺时针旋转,直到达到极限,并试图强迫自己超过极限,发出奇怪的嗡嗡声(可能是 PWM)并消耗大量功率。 其中 4 个中的 2 个执行此操作,我尚未测试其他 2 个,是否有任何解释/如何修复它

这是代码:

#include <Servo.h>
int pos = 0;

void setup() {myservo.attach(22);}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) {
    myservo.write(pos);
    delay(15);
  }

  for (pos = 180; pos >= 0; pos -= 1) {
    myservo.write(pos);
    delay(15);
  }

}

我尝试使用一些蓝塔专业版 SG90微伺服,工作得很好。 除了

s
功率、速度或电压之外,这些小型蓝色伺服器和其他更强大的伺服器之间是否存在一些奇怪的变化?

arduino microcontroller servo rc
1个回答
0
投票

再见, 您应该查阅伺服电机数据表(如果有),以检查将轴移动到 0° 或 180° 所需的脉冲宽度值。

Arduino Servo 库默认定义了最小值和最大值,可以使用 Attach 函数等进行设置。 默认值为 544 微秒和 2400 微秒。 Attach(pin,min,max) 函数的最小值和最大值也可用于微调伺服系统的运动。 可以创建交互式功能,以便更轻松地在其极限范围内调整伺服定位。 如果舵机中有机械限制器,您还应该检查它们是否可以修改以及是否设置正确。

您会发现我修改过的代码中使用了最小/最大值(我插入的最大值是任意的)。

#include <Servo.h>
int pos = 0;

Servo myservo; # creating an instance myservo of Servo class

// Consult servo datasheet for the pulse width necessary to move servo's shaft to minimum (0 degrees) and maximum position (n degrees)
// attach function min and maximum values allow to fine tune servo positioning at 0 degrees and n degrees (90, 180, ...)
int servo_min = 544 ; # servo minimum pulse  width in microseconds, default = 544 microseconds
int servo_max = 2300 ; # servo maximum width, default = 2400 microseconds

// void setup() {myservo.attach(22);}
void setup() {myservo.attach(22, servo_min, servo_max);}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) {
    myservo.write(pos);
    delay(15);
  }

  for (pos = 180; pos >= 0; pos -= 1) {
    myservo.write(pos);
    delay(15);
  }

}
© www.soinside.com 2019 - 2024. All rights reserved.