We try to run a Totem Board X4 v.1.0.
When we run code examples from the git of the Version v.1.0 they mostly run. The only thing we struggle is the servo motors. The odd thing is. If we run it on a v.1.1 Board the code runs perfectly. So we where able to check the motors. So that should not be the problem. Just for information I post here the example code. (I added just the line marked with (*), to enable the motor A, that didn’t help).
#include <Arduino.h>
/*
Board: [X4] RoboBoard X4
Details: Example how to control Servo motor position
PWM (Pulse-width modulation) is used to control servo motor position.
When setting X4.servoA.angle(90) a signal is generated where it goes
LOW after 1500us (microsecond) and goes up after 18.5ms (millisecond).
Using these timings, servo motor knows position it should spin to.
Frequency:
HIGH| <-- 50Hz (20ms) --> |
|_ |
| |______________________________________|
LOW| Period: 500us (angle 0) |
Frequency:
HIGH| <-- 50Hz (20ms) --> |
|___ |
| |____________________________________|
LOW| Period: 1500us (angle 90) |
Frequency:
HIGH| <-- 50Hz (20ms) --> |
|_____ |
| |__________________________________|
LOW| Period: 2500us (angle 180) |
*/
void loopPositionRead() {
// Print current servo motor position
Serial.printf("Pos: %4d%%, Angle: %3d, Pulse: %4dus\n",
X4.servoA.getPos(),
X4.servoA.getAngle(),
X4.servoA.getPulse()
);
delay(100);
}
// Initialize program
void setup() {
// Start Serial Monitor communication at 9600 speed
Serial.begin(9600);
X4.servoA.enable(); // (*)
// Start parallel loop to print current motor position
addLoop(loopPositionRead);
}
// Loop program
void loop() {
// Simple motor spin
X4.servoA.angle(0); // Spin motor to angle 0 (degree)
delay(500);
X4.servoA.angle(90); // Spin motor to angle 90 (degree)
delay(1000);
// Inverted direction motor spin
X4.servoA.setInvert(true); // Enable motor spin to opposite direction
X4.servoA.angle(0);
delay(500);
X4.servoA.angle(90);
delay(500);
X4.servoA.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.
X4.servoA.setSpeed(10); // Set motor spin speed to 10rpm
X4.servoA.angle(0);
delay(2500);
X4.servoA.angle(90);
delay(2500);
X4.servoA.setSpeed(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.
X4.servoA.angle(0, 2000); // Spin to position 0 in 2 seconds
delay(2500);
X4.servoA.angle(90, 1000); // Spin to position 90 in 1 second
delay(1500);
}
The Serial Monitor for the working v.1.1 board outputs lines like that:
If it’s lower than that - click Tools > Burn Bootloader to flash latest version (RGB should light up green). Warning: do not use “Burn Bootloader” feature with RoboBoard X4 v1.1 for now.
This should fix the issue. Also - keep in mind, that v1.0 board has servo ports B and C mixed up.
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);
}
The board (the hardware) I have is 1.0.0. I tried updating to the board version 2.0.14 and use the libraries that are available there, but unfortunately none of the things that were available there didn’t want to compile for the board I have.
I don’t know if there is a miss-communication. We installed the Totem Board 2.0.14 in the ArduinoIDE at the sideboard. I think the same goes for the Totem Library to 1.1.2. Then we tried examples from the webpage (we tried that ca. last week). But no of the examples wanted to compiled.
Our supervisor also tried it I guess and he wrote a email with:
" Our board works with Board support 1.0.0. It does not work with the new
2.0.14-totem.1 version (even an empty sketch compiles and can be uploaded but causes
endless board restart). So if you have the new one installed, uninstall it and
install 1.0.0. (that is the Board support, i.e. check at Board Manager)"
Versions from 1.0.0 to 2.0.14-totem.1 has all the programming functions changed (like X4.servoA.pos(5) → Servo.A.spinPos(5)), so old RoboBoard code has unfortunately be rewritten.
This is done to make functions more explicit, more standard across Totem ecosystem and to compile same code on RoboBoard X3 and X4.
We did not add translation layer (to compile old code), because documentation follows latest version and it would add more confusion.
But code porting is mostly rewriting function calls and shouldn’t cause much issue. Of course it’s not convenient
Then we tried examples from the webpage
We have updated all the code examples, but some old posts or articles may contain 1.0.0 version code… Could you share where such code is located? I can help to rewrite it.
empty sketch compiles and can be uploaded but causes endless board restart
Haven’t heard about this issue before. This may happen if used 2.0.14-totem.1 with old RoboBoard driver version, but should work fine after update.
RoboBoard X4 v1.1 already running latest driver version.
Our supervisor also tried it I guess and he wrote a email with:
“Our board works with Board support 1.0.0. It does not work with the new
2.0.14-totem.1 version”
Sorry to hear that But these issues can be resolved, we just need a feedback.
See support page for ways to contact us: Support - Totem Documentation
That should be good news. I am pretty sure we testet 2.0.14 code ( Servo.A.spinPos(5) ) and it didn’t work. So I think I could not provide you with old post or articles.
I hope that the Driver update fixed everything and we are now able to upgrade to 2.0.14 with no problems. We will try that next. Supervisor also said, that could work.
Thank you so far, I keep you updated if the new Versions + Code now compiles.
UPDATE:
I indeed was able to update to newest firmware and run newest code examples(for the protocols):
#include <Arduino.h>
/*
RoboBoard example to control Servo motor position
PWM (Pulse-width modulation) is used to control servo motor position.
When setting Servo.spinAngle(90) a signal is generated where it goes
LOW after 1500us (microsecond) and goes up after 18.5ms (millisecond).
Using this timing - servo motor knows position it should spin to.
Frequency:
HIGH| <-- 50Hz (20ms) --> |
|_ |
| |______________________________________|
LOW| Period: 500us (angle 0) |
Frequency:
HIGH| <-- 50Hz (20ms) --> |
|___ |
| |____________________________________|
LOW| Period: 1500us (angle 90) |
Frequency:
HIGH| <-- 50Hz (20ms) --> |
|_____ |
| |__________________________________|
LOW| Period: 2500us (angle 180) |
*/
// Initialize program
void setup() {
// Empty
}
// Loop program
void loop() {
// Position control [-100:100]
RGB.color(Color::Green);
Servo.spinPos(-100); // Spin to angle 0
delay(2000);
Servo.spinPos(0); // Spin to angle 90 (center)
delay(1000);
Servo.spinPos(100); // Spin to angle 180
delay(1000);
// Angle control [0:180]
RGB.color(Color::Yellow);
Servo.spinAngle(0); // Spin to angle 0
delay(2000);
Servo.spinAngle(90); // Spin to angle 90 (center)
delay(1000);
Servo.spinAngle(180); // Spin to angle 180
delay(1000);
// Pulse (microseconds) control [500:2500]
RGB.color(Color::Blue);
Servo.spinPulse(500); // Spin to angle 0
delay(2000);
Servo.spinPulse(1500); // Spin to angle 90 (center)
delay(1000);
Servo.spinPulse(2500); // Spin to angle 180
delay(1000);
}
esp32 is official Arduino implementation for ESP32 chip. It contains support for multiple devboards in Tools > Board > esp32. Totem Boards is Arduino implementation for RoboBoard X3 and RoboBoard X4. Located in Tools > Board > Totem Boards.
Version number matches, because Totem Boards is based on esp32 with additional board control functionality (like Servo.A.spinPos(5)). This is to maintain compatibility with general Arduino libraries and to see what “esp32” version “Totem Boards” is running on. In future there will be updates to newer versions.
We also have Totem Library (installed trough Library Managed), but it is not used in RoboBoard programming ( Totem Boards contains everything it is required). The purpose of this library will be more clear in upcoming months.
Also, seems a lot of hassle would be avoided if old RoboBoard code would compile with latest version. Errors and issues are frustrating… Will consider to add translation layer (wrapper) to next release.