Servo getAngle always gives 180

Hi! We (my students and I) are having fun with the gripper bot, in combination with a roboboard X4. We’re trying to get the gripper arm to work. We now can make the arm move (after we turned the connectors the right way up …) But if we try to get the servo angle, we always get 180 degrees. Surely, we are missing something obvious. Help would be much appreciated.

our sketch:

#include <Arduino.h>

void setup() {
  Serial.begin(9600); 
  X4.servoB.setSpeed(30); // 30 RPM
}

void loop() {
  // Angle control [90:180]
  for (int i = 90; i <= 180; i++) {
      X4.servoB.angle(i); // Spin to angle i
      Serial.printf("Pos: %4d%%, Angle: %3d, Pulse: %4dus\n", 
      X4.servoB.getPos(), 
      X4.servoB.getAngle(), 
      X4.servoB.getPulse()
      );
      delay(100);
  }
}

And the serial gave:
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us
Pos: 100%, Angle: 180, Pulse: 6144us

The servo was moving, the serial never changed.

1 Like

Could you run this code to print board versions?

#include <Arduino.h>
void setup() {
  Serial.begin(9600);
}
void loop() {
  Serial.printf("revision: v%s, driver: v%s, software: v%s\n",
    X4.getRevision(),
    X4.getDriverVersion(),
    X4.getSoftwareVersion()
  );
  delay(2000);
}

Thanks for the fast reply. I am now on a short city trip in london, but will run the code on my return and let you know. Regards!

The resulting board version:
revision: v1.1, driver: v1.50, software: v2.00

This (servo.get() function) bug was fixed in driver version 1.52, along with dc.setInvert() feature.

Unfortunately, you have revision 1.1 board manufactured before 2022 March. These boards have a known issue resulting in a complete brick if driver gets updated.
This is currently resolved, but we are still working on a solution to fix already sold units.

In a mean time, if you require these features - please contact our support at info@totemmaker.net. We will send you a replacement.

Coming back to this topic.

With latest Totem Arduino release, this example works as expected:

void setup() {
  Serial.begin(115200); 
  Servo.B.setSpeedRPM(30); // 30 RPM
}

void loop() {
  // Angle control [90:180]
  for (int i = 90; i <= 180; i++) {
      Servo.B.spinAngle(i); // Spin to angle i
      Serial.printf("Pos: %4d%%, Angle: %3d, Pulse: %4dus\n", 
      Servo.B.getPos(), 
      Servo.B.getAngle(), 
      Servo.B.getPulse()
      );
      delay(100);
  }
}
Pos:   94%, Angle: 174, Pulse: 2444us
Pos:   95%, Angle: 175, Pulse: 2455us
Pos:   96%, Angle: 176, Pulse: 2466us
Pos:   97%, Angle: 177, Pulse: 2477us
Pos:   98%, Angle: 178, Pulse: 2488us
Pos:  100%, Angle: 180, Pulse: 2500us
Pos:   80%, Angle: 162, Pulse: 2300us
Pos:   60%, Angle: 144, Pulse: 2100us
Pos:   40%, Angle: 126, Pulse: 1900us
Pos:   20%, Angle: 108, Pulse: 1700us
Pos:    4%, Angle:  93, Pulse: 1544us
Pos:    5%, Angle:  94, Pulse: 1555us
Pos:    6%, Angle:  95, Pulse: 1566us
Pos:    7%, Angle:  96, Pulse: 1577us
Pos:    8%, Angle:  97, Pulse: 1588us
Pos:   10%, Angle:  99, Pulse: 1600us