Also, I suggest updating to latest Totem Boards “2.0.14-totem.1”. Version “1.0.0” is 2 years old and you may encounter some more issues down the road.
Same example code for latest version:
#include <Arduino.h>
void loopPositionRead() {
// Print current servo motor position
Serial.printf("Pos: %4d%%, Angle: %3d, Pulse: %4dus\n",
Servo.A.getPos(),
Servo.A.getAngle(),
Servo.A.getPulse()
);
delay(100);
}
// Initialize program
void setup() {
// Start Serial Monitor communication at 9600 speed
Serial.begin(9600);
// Start parallel loop to print current motor position
addLoop(loopPositionRead);
}
// Loop program
void loop() {
// Simple motor spin
Servo.A.spinAngle(0); // Spin motor to angle 0 (degree)
delay(500);
Servo.A.spinAngle(90); // Spin motor to angle 90 (degree)
delay(1000);
// Inverted direction motor spin
Servo.A.setInvert(true); // Enable motor spin to opposite direction
Servo.A.spinAngle(0);
delay(500);
Servo.A.spinAngle(90);
delay(500);
Servo.A.setInvert(false); // Disable direction switching
// Set custom RPM speed for positioning.
// Maximum speed is determined by motor capabilities.
// Typically it's around ~60rpm.
// When speed is set, getPos() function will return exact motor
// position at the moment.
Servo.A.setSpeedRPM(10); // Set motor spin speed to 10rpm
Servo.A.spinAngle(0);
delay(2500);
Servo.A.spinAngle(90);
delay(2500);
Servo.A.setSpeedRPM(0); // Set back to maximum motor speed
// Spin for specified length of time.
// This function will spin motor at speed required to reach
// specified position at given time.
Servo.A.spinAngleDuration(0, 2000); // Spin to position 0 in 2 seconds
delay(2500);
Servo.A.spinAngleDuration(90, 1000); // Spin to position 90 in 1 second
delay(1500);
}
Servo control documentation: Servo. - Totem Documentation
Another servo example: Servo getAngle always gives 180 - #6 by Arnas
Edit: talking about issues… Just spotted that function “getAngle()” may return incorrect value sometimes. Will fix in next release.