How to handle multiple Totembus modules with a X4?

Dear forum members,

Does any of you know how I can connect eg. 2 distance sensors to a system based on a X4 card, while still having the possibility to have a totembus connector availalble to set up a daisy chain for other modules eg a X3?
Gladly hear your experience in this area,

Best regards, Frits

1 Like

You can connect modules in any combination. They can be all daisy chained and recognized in the same network.

With “X3” you are referring to Mini Control Board X3 or old ones with sandwich function boards?

Mini Control Board X3 is only Bluetooth capable and doesn’t have TotemBUS connectors.
The old X3 boards (shipped with Truck and Robotic arm) are deprecated and won’t work with X4. We are switching to new hardware and software, so it’s being replaced.

1 Like

Arnas,
Thank you very much for your response!
Actually, the first picture says it all for me, since it’s clear for me now that the distance sensors can be daisy chained; this didn’t show so much from the YouTube clips about the distance sensor and eg. as headlights on the Jeep video. Your info about the X3 is more than welcome. My doubts are gone now. Thank you so much.
Best regards,
Frits

1 Like

Happy to help.

In terms of features and documentation, this is an early product, so it will only get better overtime. All the questions are welcome.

Continuing the discussion from How to handle multiple Totembus modules with a X4?:

Hi, I have a follow-up question concerning multiple distance sensors connected to one x4 board. In the programming examples, there is no hint how to distinguish one distance sensor from the other. When connecting standard tof-sensors to an I2C Bus, they have an XSHUT pin to assign them different Bus addresses. The object contructor then uses the bus address to be assigned to a specific sensor. In your examples, the constructor Module11 does not take any parameters to distinguish between sensors. What does the trick with your sensors?

Modules on TotemBUS has 2 identifiers: module number (which is 11 for distance sensor) and module serial (15 bit unique identifier). You can communicate with modules only by using number (where all modules on TotemBUS responds) or number and serial (where only specific module responds).

This way all modules respond to commands:

Module11 sensor; // Control all modules with number 11
void setup() {
  sensor.rgb.on(); // Will turn LED on for all connected modules with number 11
}

Module11 object actually has a constructor to accept serial number Module11(uint16_t serial = 0), so you can can declare object referencing specific module.

This will control modules individually:

Module11 sensor1(9724); // Init module 11 with serial 9724
Module11 sensor2(9740); // Init module 11 with serial 9740
void setup() {
  sensor1.rgb.color(255, 0, 0); // Set red color for number 11 serial 9724
  sensor2.rgb.color(0, 255, 0); // Set green color for number 11 serial 9740
  sensor1.distance.getMM(); // Get distance of module with serial 9724
  sensor2.distance.getMM(); // Get distance of module with serial 9740
}

Arduino example of controlling multiple sensors (can also find in Arduino IDE Examples -> TotemBUS -> SameModules): TotemArduinoBoards/SameModules.ino at master · totemmaker/TotemArduinoBoards · GitHub
Also this is mentioned in documentation: https://docs.totemmaker.net/modules/programming/#accessing-specific-module

Now tricky part to acquire this serial. You need to use X4.module functionality ping modules and “discover” them. Run the code and connect module to TotemBUS. It will print its serial.

// Function called when ping response from module is received
void moduleDiscovered() {
  int number = X4.module.getLastNumber();
  int serial = X4.module.getLastSerial();
  Serial.printf("Found. number: %d, serial: %d\n", number, serial);
}
void setup() {
  Serial.begin(115200);
  // Register module ping response event function
  X4.module.addEvent(moduleDiscovered);
}
void loop() {
  Serial.println("Scan...");
  X4.module.ping(); // Ping all modules
  delay(500);
}

Note: connect only one module at the time. This “ping” method doesn’t work reliably at the moment.

Example code: TotemArduinoBoards/ListConnectedModules.ino at master · totemmaker/TotemArduinoBoards · GitHub
Documentation: https://docs.totemmaker.net/roboboard-x4/module/