Final Project

slides

I have two final project ideas. My initial idea was to design a modular light controller, which I described in Week 01b. Over the weeks, and after discussions with my local instructor Ferdi, I developed the idea of creating a "smart" filament holder for the Prusa XL. This holder would measure the weight of the spools and indicate how much filament remains. This feature is particularly useful because loading and unloading filament on the Prusa XL can be cumbersome—especially when printing with five different materials, as it requires unloading, weighing, and reloading five spools. Integrating this with a filament drying box would be a great addition. For this aspect, I found some inspiration on YouTube with the Sicco Box, which is also available on Printables. Another idea that came to mind was to develop a test stand for the Aero Hand by Chestnut Robotics. I had previously built an Aero Hand for a research department at my university, where it was intended to serve as a demonstrator and test platform for evaluating newly developed pressure sensors and, in a later stage, potentially touch sensors. A more human-like hand geometry is important for this type of gripper, as the sensors are intended to be integrated into wearable sensor gloves or prostheses at a later stage. The development of such devices was therefore primarily a question of available funding. A more human-like hand geometry is important for this type of gripper, as the sensors are intended to be integrated into wearable sensor gloves or prostheses at a later stage. The development of such devices was therefore primarily a question of available funding. Unfortunately, not all components arrived in time for the event, so we were unable to present the fully assembled Aero Hand. Nevertheless, we still wanted to pursue the original idea and continue with its development. As the sensors evolved from week to week, the project became increasingly complex. What initially started as a relatively simple concept of attaching PDMS-based sensor substrates directly to the hand has since developed into a more refined approach. We have now reached a stage where castable silicone cover provide a suitable solution, as they allow the sensors to be integrated relatively easily into the surface of the cover. The current plan is to attach the sensors to the outer surfaces of the moulds before casting the silicone cover. However, this implementation will be carried out in a subsequent development iteration after I have completed my final project.

However, this was only the beginning of my difficulties in defining a suitable project. I spent so much time evaluating different ideas and possible approaches that I eventually decided to proceed with one of the less complex concepts, which was probably not the most ambitious option: developing a test stand for the Aero Hand.

What should it do in each spiral?

  1. Provide a more stable mounting solution to hold the hand in a fixed position while remaining portable. It should also offer basic inputs and outputs to monitor its operation and control it. A standalone approach would be preferable for the initial development stage.
  2. Provide easy access to individual motor control, allowing each motor to be controlled independently.
  3. Implement predefined gestures and continuous movements for testing and measurement purposes.
  4. Manufacture the sensors and cast the silicone covers.
  5. Integrate sensor data acquisition, evaluation and output.
  6. Implement a feedback mechanism in which the servos react to the sensor data, while simultaneously providing the sensor readings and corresponding servo positions as output.
  7. Develop a custom bus servo driver board and integrate at least the driver board and microcontroller into the hand. If sufficient space is available, integrate the hardware developed in the fifth spiral into the hand.
  8. In the future, I would also like to experiment with alternative actuation concepts and motors, such as brushless motors with cycloidal drives in a closed-loop configuration.

With each successive spiral, the project will become increasingly integrated and refined, ultimately resulting in a standalone version of the hand that no longer requires the current test stand. This represents the intended direction of development for the concept. From spiral 7 onwards, however, the focus will shift towards a substantially different project.

System Integration

The thoughts about the system integration are documented in week 15.

Mechanics

Bom

ID Component Quantity price/# price
M01 Housing 1
M02 Baseplate 1
M03 Spacer 2
M04 DIN EN ISO 10642 M3x6 7
M05 DIN EN ISO 4762 M3x6 2
M06 DIN EN ISO 4762 M2x3 4

The DIN EN ISO 4762 M3x6 screws can easily be replaced by any other M3x6 screw that has no countersunk or hexagonal screw head. The screw head must fit within the corresponding PCB footprint without contacting the GND copper area or any signal traces.

Housing

The housing serves several functions:
1. Provides a stable and robust stand that protects the Aero Hand from tipping over.
2. Positions the display and rotary encoder securely and presents them in an accessible arrangement.
3. Adds a visually appealing enclosure to the system.

The housing was manufactured using FFF on a Prusa CORE One with Prusament PETG Signal White filament.

For the first version of the housing, I prioritized material efficiency, although I expected that this might compromise the print quality. The result did not meet my expectations. I also discovered a design issue: the rotary encoder is installed by turning it into the housing, with its nut sitting flush against the surface. I had not allowed enough clearance for the pin header to rotate with the encoder during installation. Removing the header assembly and resoldering it would have resolved the clearance issue, but I wanted to avoid reworking the electronics. Since the housing's appearance also needed improvement, I redesigned it and moved the encoder farther back to provide sufficient clearance for installation.

housing 00

housing 01

The second print turned out well and resolved all of the identified issues.

housing 04

After removing the support material, I cleaned the areas where it had contacted the print and installed three threaded inserts for attaching the baseplate. Ideally, the inserts would be positioned on the opposite side so that tightening the screws presses them into the 3D-printed part rather than loading them against a surface. However, this is not critical in this application.

housing 02

Baseplate and Spacer

The baseplate was laser-cut from a 3 mm sheet of PMMA. I later drilled the countersunk holes using a drill press and cut the threads by hand with a tap. I considered CNC milling the baseplate to include another manufacturing process, but this would have taken longer and produced a much rougher edge. The spacers were manufactured using FFF on a Prusa CORE One with Prusament PETG Signal White filament.

Electronics

Bom

The prices exclude shipping and include German VAT, given in €. They are calculated for single components only, without bulk discounts, so they represent an estimated worst-case cost. To simplify reproduction, I will minimize the number of suppliers, even if this results in higher individual component prices.

ID Designator Component Quantity price/# price link
E01 J1 Molex 0022057035 1 0,21 € 0,21 € https://www.digikey.de/de/products/detail/molex/0022057035/403342
E02 J2 to J8 Molex 0022035035 7 0,20 € 1,40 € https://www.digikey.de/de/products/detail/molex/0022035035/403302
E03 J9 PinHeader_01x06_P2.54mm_vertical_SMD 1 0,28 € 0,28 € https://www.digikey.de/en/products/detail/metz-connect-usa-inc/PM20206VBNN/7794801
E04 J10, J11 PinSocket_01x07_P2.54mm_vertical_SMD 2 1,07 € 2,14 € https://www.digikey.de/en/products/detail/amphenol-cs-fci/91601-307LF/1535077
E05 J12 PinSocket_01x05_P2.54mm_vertical_SMD 1 0,47 € 0,47 € https://www.digikey.de/en/products/detail/gct/BG125-05-A-1-1-0440-N-D/13901355
E06 J13 PinHeader_01x03_P2.54mm_vertical_THT 1 0,09 € 0,09 € https://www.digikey.de/en/products/detail/sullins-connector-solutions/PRPC003SAAN-RC/2775251
E07 U1 Seedstudio Bus Driver Board 1 7,30 € 7,30 € https://openelab.de/products/seeed-studio-bus-servo
E08 PinHeader_01x07_P2.54mm_vertical_THT 2 0,10 € 0,20 € https://www.digikey.de/en/products/detail/adam-tech/PH1-07-UA/9830505
E09 Xiao ESP32 S3 1 6,65 € 6,65 € https://www.digikey.de/de/products/detail/seeed-technology-co-ltd/113991114/19285530
E10 FR1 35 µm 1/25 100,95 € 4,04 € https://www.digikey.de/de/products/detail/bantam-tools/MT1005/8567213
E11 KY-040 rotary encoder 1 2,15 € 2,15 € https://www.reichelt.de/de/de/shop/produkt/entwicklerboards_-_drehwinkel-encoder_ky-040-282545
E12 JOY-IT 2,42" OLED Display 1 18,90 € 18,90 € https://www.reichelt.de/de/de/shop/produkt/entwicklerboards_-_display_oled_2_42_128x64_pixel-335005
E13 Feetech HLS3606M 7 38,59 € 270,13 € https://de.aliexpress.com/item/1005010298067392.html
E14 Servo cable (2. included with servo) 1 0,00 € 0,00 €
E15 Jumper wire 8/20 1,73 € 0,70 € https://www.digikey.de/en/products/detail/adafruit-industries-llc/1950/6827084
E16 Cable 0,75 mm² red ~ 0,1 m 1
E17 Cable 0,75 mm² black ~ 0,1 m 1
E18 3 mm Heatshrink ~ 5 mm 4
E19 5 mm Heatshrink ~ 8 mm 2
E20 0,75 mm² wire-end ferrules 2
E21 barrel connector 1 2,80 € 2,80 € https://www.ebay.de/itm/333914873060
E22 barrel plug 1 1,60 € 1,60 € https://www.reichelt.de/de/de/shop/produkt/hohlstecker_knickschutz_aussen_3_5_mm_innen_1_3_mm-8645
E23 Dupont Connector 01x05 2
E24 Dupont Connector 01x06 1

The servo motors are part of the Aero Hand BOM. Because they play a major role in this project, they are included in the bill of materials here.
Pin sockets and pin headers can be obtained at a lower cost by purchasing them in larger strips and cutting or breaking them into the required lengths.

Servo Board

The servo board functions as an adapter that replaces the small Y-connector boards supplied with the hand. It connects all bus servos in a compact arrangement, allowing them to be controlled through a shared communication line rather than separate signal wires. One advantage of this bus topology is that fewer signal wires are required, although this is limited to a specific number of servos. The servo cables, which are already routed inside the hand near the wrist, hold the board in place. At present, I have not routed these cables further into the back of the hand because they secure the adapter board without causing it to move or the cables to become pinched.

servo_board_01-02

Main board

The main board currently connects the bus servo driver board and the XIAO ESP32-S3, mounted on top, with the user interface components, including the display and rotary encoder.

main_board_01-02

PCB Production

I use our F1 Ultra UV laser to manufacture the boards because it is easier and more convenient for single-sided PCBs and can produce finer details. The higher production resolution makes it easier to route the PCB while keeping the design compact. However, several design considerations should be kept in mind. Based on experience from the past month, I increased the clearance between copper regions and all elements except the board outline from 0,254 mm to 0,5 mm to simplify cleaning. If this conflicts with other design constraints, I would reduce the clearance again to 0,254 mm. For soldering on FR1, I also prefer to increase the copper area spoke width and spoke spacing from 0,254 mm to 0,5 mm. When using the laser and FR1, my typical minimum trace width is 0,5 mm, even though narrower traces of 0,254 mm are possible, as demonstrated in previous PCB designs. I plan to verify the absolute minimum manufacturing parameters using Niels' PCB manufacturing test.

The laser fabrication process is as follows:
1. Export the Gerber files.
2. Convert them using the Gerber2Png tool from FabLab Kerala.
3. Import the generated files into xTool Studio.
4. Trace the imported shapes in xTool Studio.
5. Assign the engraving and cutting operations to separate layers and align the layers over one another.
6. Apply the following settings. It is important to enable angle rotation for multiple engraving passes.
7. Place the FR1 material in the laser, set the focus, and position the design at a suitable location on the material.
8. Start the laser.

After laser processing, I clean the boards with steel wool and isopropanol.

pcb production 04-05

The final step is soldering the components onto the PCB.

servo_board_03-05

The SPI header is not currently required, and its future use has not yet been determined. Therefore, I have omitted it from this version of the design.

main_board_03-05

Wires

I fabricated the power cables for the servo motors. Inside the enclosure, I soldered 0.75 mm² wires to the barrel jack and insulated the connections to prevent accidental short circuits. I fitted wire-end ferrules to the other ends for connection to the PCB or bus servo driver board. I prepared an external barrel plug in a similar way, but without wire-end ferrules. This plug is a temporary connection for a bench power supply. One conductor is considerably shorter than the other to reduce the risk of a short circuit if exposed clips are used.

The rotary encoder is connected using two 1×5-pin Dupont connectors, while the display uses one 1×6-pin Dupont connector. At the display end, the wires are soldered directly to the board.

wire

Software

First Tests

For the initial functional test, I attempted to use only the components I already had available. However, this turned out to be easier said than done. I first had to determine how to communicate with the servos and which communication protocol and operating mode they required. The available documentation for the motors was reasonably comprehensive, but not entirely clear or complete. Consequently, it took me some time and quite a few exchanges with Gemini to work through and test almost all possible configurations.

Before reaching this point, I had been a little too optimistic about the complexity of using bus servos. I already knew that they were considerably more powerful and somewhat more complex than typical 9 g hobby servos, but I had underestimated the additional hardware requirements for communicating with them. I knew which IC was used in the original Aero Hand control board, but since it was not readily available, I decided to experiment with a simpler approach first to see how far I could get without dedicated interface hardware. Spoiler: not very far. My initial idea was to use a 1 kΩ resistor between the TX pin of the XIAO ESP32-C3 and the servo's data line, while connecting the RX pin of the XIAO directly to the same data line. The assumption was that the XIAO could transmit signals to the servo while the resistor would sufficiently limit and dampen the signal reaching the TX pin from the servo during transmission. This would hopefully result in a rudimentary, although potentially unreliable, half-duplex communication circuit. Unfortunately, this approach did not work. Since I also did not have a suitable half-duplex transceiver IC available, I ordered the aforementioned Seeed Studio Bus Servo Driver Board instead. However, even with this board, communication initially failed.

At this point, I tried to establish communication using the recommended library from Seeed Studio in combination with their bus servo driver board. The SCServo library did not produce any meaningful results. I suspected that I was using the wrong communication protocol, especially since the motor datasheets did not explicitly specify which protocol was required. Therefore, I started by attempting to ping the servo using all protocols supported by the library, but none of these attempts returned a positive response. I also tried cycling through different baud rates without success. Eventually, I used Gemini to develop a custom communication protocol implementation based on the servo motor's datasheet ("generate a testcode to rotate a Feetech HLS3606M servo left wait rotate right wait and repeat while using a Xiao ESP32S3 and a Seedstudio Bus Servo Driver Board based on the datasheet from the servo"), which turned out to be the right approach. Using this, I was finally able to move a servo. I was quite happy about this result, as it meant that I had finally established communication and made some actual progress.

show code
#include <Arduino.h>

#define TX_PIN D6
#define RX_PIN D7

HardwareSerial ServoSerial(1);

// --------------------------------------------------
// Feetech Protocol
// --------------------------------------------------

void sendPacket(
    uint8_t id,
    uint8_t instruction,
    uint8_t* params,
    uint8_t param_len)
{
    uint8_t length = param_len + 2;

    uint8_t checksum =
        id + length + instruction;

    ServoSerial.write(0xFF);
    ServoSerial.write(0xFF);

    ServoSerial.write(id);
    ServoSerial.write(length);
    ServoSerial.write(instruction);

    for(int i = 0; i < param_len; i++)
    {
        ServoSerial.write(params[i]);
        checksum += params[i];
    }

    checksum = ~checksum;

    ServoSerial.write(checksum);
}

// --------------------------------------------------
// Torque Enable
// --------------------------------------------------

void enableTorque(uint8_t id)
{
    uint8_t params[2];

    // Register 40 = Torque Enable
    params[0] = 40;
    params[1] = 1;

    sendPacket(
        id,
        0x03,
        params,
        2
    );
}

// --------------------------------------------------
// Move Servo
// --------------------------------------------------

void writePos(uint8_t id, uint16_t pos){
    uint8_t params[3];

    // Goal Position Register
    params[0] = 42;

    params[1] = pos & 0xFF;
    params[2] = (pos >> 8) & 0xFF;

    sendPacket(
        id,
        0x03,
        params,
        3
    );
}

void setup(){
    Serial.begin(115200);
    ServoSerial.begin(1000000,SERIAL_8N1,RX_PIN,TX_PIN);
}

void loop(){
    Serial.println("Left");
    writePos(1, 3500);
    delay(1000);

    Serial.println("Right");
    writePos(1, 4600);
    delay(1000);

}

Fortunately, the implementation worked. However, a more systematic approach would have been to start with a simple ping test to verify communication with the servo before implementing the protocol.

The next step was to control multiple servos simultaneously. To achieve this, I extended the loop to perform the same operation for servo ID 2 immediately after servo ID 1. This initially worked when I connected a second servo, but not as expected. Both motors responded to the commands but always executed the same movements simultaneously. I eventually identified the cause: both servos were configured with the same default ID (1).

Setup Servo ID

I therefore had to assign a unique ID to each servo. To achieve this, I asked Gemini to: "generate a code that change the default servo id 1 to 2 from a Feetech HLS3606M servo motor while using a Xiao ESP32S3 and a Seedstudio Bus Servo Driver Board". I used the generated code shown below to change the servo ID:

show code
#include <Arduino.h>

#define TX_PIN D6
#define RX_PIN D7

HardwareSerial ServoSerial(1);

#define OLD_ID 1
#define NEW_ID 2

void sendPacket(
    uint8_t id,
    uint8_t instruction,
    uint8_t* params,
    uint8_t param_len)
{
    uint8_t length = param_len + 2;

    uint8_t checksum =
        id + length + instruction;

    ServoSerial.write(0xFF);
    ServoSerial.write(0xFF);

    ServoSerial.write(id);
    ServoSerial.write(length);
    ServoSerial.write(instruction);

    for(int i = 0; i < param_len; i++)
    {
        ServoSerial.write(params[i]);
        checksum += params[i];
    }

    checksum = ~checksum;

    ServoSerial.write(checksum);
}

void writeByte(
    uint8_t id,
    uint8_t reg,
    uint8_t value)
{
    uint8_t params[3];

    params[0] = reg;
    params[1] = value;

    sendPacket(
        id,
        0x03,
        params,
        2
    );
}

void setup()
{
    Serial.begin(115200);

    delay(2000);

    Serial.println("SET SERVO ID");

    ServoSerial.begin(
        1000000,
        SERIAL_8N1,
        RX_PIN,
        TX_PIN
    );

    delay(1000);

    Serial.println("EEPROM Unlock");

    writeByte(OLD_ID, 55, 0);

    delay(100);

    Serial.println("Setze neue ID");

    writeByte(OLD_ID, 5, NEW_ID);

    delay(100);

    Serial.println("EEPROM Lock");

    writeByte(NEW_ID, 55, 1);

    Serial.println("Fertig");
}

void loop()
{
}

The code establishes communication with the servo and enables write access to its internal EEPROM by modifying the corresponding control register. It then changes the servo ID from 1 to 2 by writing the new value to the respective ID register. Finally, it disables write access to the EEPROM again, returning it to read-only mode.

First real Test

After that I assembled the hole Aero Hand and before moving any servo I wanted to read out the momentary position then manualy tension all wires by putting the servo in loop mode and write in relation to the momentary position a new position in the serial monitor, what also allows me to test the right assemble of the hand. For that I asked Gemini: "generate a code for a Feetech HLS3606M servo motor while using a Xiao ESP32S3 and a Seedstudio Bus Servo Driver Board that only read out the momentary position from 7 servos with the ID 1 to 7"

show code
#include <Arduino.h>

#define TX_PIN D6
#define RX_PIN D7

#define SERVO_BAUD 1000000

#define FIRST_SERVO_ID 1
#define LAST_SERVO_ID  7

HardwareSerial ServoSerial(1);

// HLSCL register
#define REG_PRESENT_POSITION_L 56

// Feetech instruction
#define INST_READ 0x02


// ============================================================
// send a Read-Data-Package
// ============================================================

void sendReadPacket(uint8_t id, uint8_t address, uint8_t length)
{
    // READ DATA:
    //
    // FF FF ID LENGTH 02 ADDRESS READ_LENGTH CHECKSUM
    //
    // LENGTH = 4
    //          instruction + address + read length + checksum

    uint8_t packetLength = 4;

    uint8_t checksum =
        id +
        packetLength +
        INST_READ +
        address +
        length;

    checksum = ~checksum;

    ServoSerial.write(0xFF);
    ServoSerial.write(0xFF);
    ServoSerial.write(id);
    ServoSerial.write(packetLength);
    ServoSerial.write(INST_READ);
    ServoSerial.write(address);
    ServoSerial.write(length);
    ServoSerial.write(checksum);

    ServoSerial.flush();
}


// ============================================================
// read n bytes with timeout
// ============================================================

bool readBytes(
    uint8_t *buffer,
    uint8_t length,
    uint32_t timeoutMs = 100)
{
    uint32_t start = millis();

    uint8_t index = 0;

    while (index < length)
    {
        if (ServoSerial.available())
        {
            buffer[index++] = ServoSerial.read();
        }
        else
        {
            if (millis() - start >= timeoutMs)
            {
                return false;
            }

            delay(1);
        }
    }

    return true;
}


// ============================================================
// read out position
// ============================================================

int readPosition(uint8_t id)
{
    // remove all data from the input buffer
    while (ServoSerial.available())
    {
        ServoSerial.read();
    }

    // Position:
    // Register 56 = Low Byte
    // Register 57 = High Byte

    sendReadPacket(
        id,
        REG_PRESENT_POSITION_L,
        2
    );

    // Answer:
    //
    // FF FF ID LENGTH ERROR POS_L POS_H CHECKSUM
    //
    // = 8 Bytes

    uint8_t response[8];

    if (!readBytes(response, 8))
    {
        return -1;
    }


    // --------------------------------------------------------
    // header check
    // --------------------------------------------------------

    if (response[0] != 0xFF ||
        response[1] != 0xFF)
    {
        return -2;
    }


    // --------------------------------------------------------
    // ID check
    // --------------------------------------------------------

    if (response[2] != id)
    {
        return -3;
    }


    // --------------------------------------------------------
    // Error byte
    // --------------------------------------------------------

    if (response[4] != 0)
    {
        Serial.print("Servo ");
        Serial.print(id);
        Serial.print(" meldet Fehler 0x");
        Serial.println(response[4], HEX);

        return -4;
    }


    // --------------------------------------------------------
    // Read out position
    // --------------------------------------------------------

    uint16_t rawPosition =
        (uint16_t)response[5] |
        ((uint16_t)response[6] << 8);

    int position;

    if (rawPosition & 0x8000)
    {
        position = -(rawPosition & 0x7FFF);
    }
    else
    {
        position = rawPosition;
    }

    return position;
}


// ============================================================
// SETUP
// ============================================================

void setup()
{
    Serial.begin(115200);

    delay(2000);

    Serial.println();
    Serial.println("======================================");
    Serial.println("HLS3606M POSITION SCANNER");
    Serial.println("======================================");

    Serial.println("UART: 1000000 Baud");
    Serial.println("IDs: 1 - 7");
    Serial.println();

    ServoSerial.begin(
        SERVO_BAUD,
        SERIAL_8N1,
        RX_PIN,
        TX_PIN
    );

    delay(500);
}


// ============================================================
// LOOP
// ============================================================

void loop()
{
    Serial.println("--------------------------------------");

    for (uint8_t id = FIRST_SERVO_ID;
         id <= LAST_SERVO_ID;
         id++)
    {
        int position = readPosition(id);

        Serial.print("Servo ID ");
        Serial.print(id);
        Serial.print(": ");

        if (position >= 0)
        {
            Serial.print(position);

            float degrees =
                position * 360.0f / 4096.0f;

            Serial.print("  (");
            Serial.print(degrees, 2);
            Serial.println(" deg)");
        }
        else
        {
            Serial.print("keine Antwort");

            if (position == -2)
                Serial.print(" [Header]");
            else if (position == -3)
                Serial.print(" [falsche ID]");
            else if (position == -4)
                Serial.print(" [Servo-Fehler]");
            else
                Serial.print(" [Timeout]");

            Serial.println();
        }

        // break between servos
        delay(20);
    }

    Serial.println();

    // read out every 500 ms
    delay(500);
}

This approach worked as intended, but did not provide any particularly useful functionality. It was merely a preliminary test to verify that the servo communication and position reading worked correctly without unintentionally damaging the hand during testing. So next I asked for: "generate a test code that let me change the position from a servo by using a rotary encoder as input and the serial monitor as output. Initially show me the momentary position from the servo and update it with each change. Use the HLSCL library for that" I also wanted to integrate the library used by the original Aero Hand firmware. I had not used it before because, despite knowing that it existed, I was unable to locate and install it on my computer. I am still not sure what caused the issue, but after updating the Arduino IDE, I tried installing the library again, and it worked without any problems.

show code
#include <Arduino.h>
#include <Wire.h>
#include <U8x8lib.h>
#include <HLSCL.h>

// =====================================================
// PIN CONFIGURATION
// =====================================================

// Rotary encoder
#define ENCODER_CLK D0
#define ENCODER_DT  D1
#define ENCODER_SW  D2

// I2C OLED
#define OLED_SDA D4
#define OLED_SCL D5

// Servo bus
#define SERVO_TX D6
#define SERVO_RX D7

// =====================================================
// SERVO CONFIGURATION
// =====================================================

#define SERVO_COUNT 7

const uint8_t servoIDs[SERVO_COUNT] = {
  1, 2, 3, 4, 5, 6, 7
};

const uint32_t SERVO_BAUD = 1000000;

const int SERVO_SPEED = 32766;
const int SERVO_ACCEL = 50;
const int SERVO_TORQUE = 700;

// Position change per encoder detent
const int32_t POSITION_STEP = 100;

// Read interval
const unsigned long READ_INTERVAL = 250;

// =====================================================
// OBJECTS
// =====================================================

HLSCL hlscl;

// SSD1306, 128x64, hardware I2C
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(U8X8_PIN_NONE);

// =====================================================
// SERVO DATA
// =====================================================

int32_t currentPosition[SERVO_COUNT] = {0};
int32_t targetPosition = 0;

bool positionValid[SERVO_COUNT] = {false};

uint8_t selectedServo = 0;

// =====================================================
// ENCODER DATA
// =====================================================

int lastEncoderState = 0;
int encoderCounter = 0;

const int8_t encoderTable[16] = {
   0, -1,  1,  0,
   1,  0,  0, -1,
  -1,  0,  0,  1,
   0,  1, -1,  0
};

bool lastButtonState = HIGH;
unsigned long lastButtonTime = 0;

const unsigned long BUTTON_DEBOUNCE = 200;

// =====================================================
// TIMING
// =====================================================

unsigned long lastReadTime = 0;

// =====================================================
// OLED DISPLAY
// =====================================================

void drawHeader() {
  u8x8.drawString(0, 0, "SERVO POSITIONS");
}

void drawServoLine(uint8_t index) {

  char line[17];

  char indicator = (index == selectedServo) ? '>' : ' ';

  if (positionValid[index]) {

    snprintf(
      line,
      sizeof(line),
      "%cS%u: %7ld",
      indicator,
      servoIDs[index],
      (long)currentPosition[index]
    );

  } else {

    snprintf(
      line,
      sizeof(line),
      "%cS%u: -------",
      indicator,
      servoIDs[index]
    );
  }

  // Fill remaining characters with spaces
  uint8_t length = strlen(line);

  while (length < 16) {
    line[length++] = ' ';
  }

  line[16] = '\0';

  // OLED rows 1-7 are used for the seven servos
  u8x8.drawString(0, index + 1, line);
}

void drawAllServos() {

  for (uint8_t i = 0; i < SERVO_COUNT; i++) {
    drawServoLine(i);
  }
}

// =====================================================
// SERIAL OUTPUT
// =====================================================

void printSelectedPosition() {

  Serial.print("Servo ");
  Serial.print(servoIDs[selectedServo]);
  Serial.print(" | ");

  if (positionValid[selectedServo]) {

    Serial.print("Position: ");
    Serial.println(currentPosition[selectedServo]);

  } else {

    Serial.println("Position unavailable");
  }
}

// =====================================================
// READ SERVO POSITION
// =====================================================

bool readServoPosition(uint8_t index) {

  int16_t position = hlscl.ReadPos(servoIDs[index]);

  // Read error
  if (position == -1) {
    return false;
  }

  bool changed =
    !positionValid[index] ||
    currentPosition[index] != position;

  currentPosition[index] = position;
  positionValid[index] = true;

  return changed;
}

// =====================================================
// READ ALL SERVOS
// =====================================================

void updateServoPositions() {

  bool displayChanged = false;

  for (uint8_t i = 0; i < SERVO_COUNT; i++) {

    if (readServoPosition(i)) {

      displayChanged = true;

      // Serial output only for selected servo
      if (i == selectedServo) {
        printSelectedPosition();
      }
    }
  }

  // Only redraw the display if a position changed
  if (displayChanged) {
    drawAllServos();
  }
}

// =====================================================
// SELECT NEXT SERVO
// =====================================================

void selectNextServo() {

  uint8_t previousServo = selectedServo;

  selectedServo++;

  if (selectedServo >= SERVO_COUNT) {
    selectedServo = 0;
  }

  Serial.println();
  Serial.print("Selected Servo: ");
  Serial.println(servoIDs[selectedServo]);

  // Initialize target from valid current position
  if (positionValid[selectedServo]) {
    targetPosition = currentPosition[selectedServo];
  }

  // Only redraw the two rows whose indicators changed
  drawServoLine(previousServo);
  drawServoLine(selectedServo);

  printSelectedPosition();
}

// =====================================================
// ENCODER BUTTON
// =====================================================

void handleButton() {

  bool buttonState = digitalRead(ENCODER_SW);

  if (
    buttonState == LOW &&
    lastButtonState == HIGH &&
    millis() - lastButtonTime > BUTTON_DEBOUNCE
  ) {

    lastButtonTime = millis();
    selectNextServo();
  }

  lastButtonState = buttonState;
}

// =====================================================
// ENCODER ROTATION
// =====================================================

void handleEncoder() {

  int currentState =
    (digitalRead(ENCODER_CLK) << 1) |
     digitalRead(ENCODER_DT);

  int encoderIndex = (lastEncoderState << 2) | currentState;

  encoderCounter += encoderTable[encoderIndex];

  lastEncoderState = currentState;

  // One complete quadrature cycle = one detent
  if (encoderCounter >= 4) {

    encoderCounter = 0;
    changeSelectedServoPosition(POSITION_STEP);

  } else if (encoderCounter <= -4) {

    encoderCounter = 0;
    changeSelectedServoPosition(-POSITION_STEP);
  }
}

// =====================================================
// CHANGE SELECTED SERVO POSITION
// =====================================================

void changeSelectedServoPosition(int32_t change) {

  // Prevent movement if initial position is unknown
  if (!positionValid[selectedServo]) {

    Serial.println("Cannot move servo: position unknown.");
    return;
  }

  targetPosition += change;

  // Protect signed 16-bit range
  if (targetPosition > 32767) {
    targetPosition = 32767;
  }

  if (targetPosition < -32768) {
    targetPosition = -32768;
  }

  hlscl.WritePosEx(
    servoIDs[selectedServo],
    (int16_t)targetPosition,
    SERVO_SPEED,
    SERVO_ACCEL,
    SERVO_TORQUE
  );

  Serial.print("Servo ");
  Serial.print(servoIDs[selectedServo]);
  Serial.print(" | Target: ");
  Serial.println(targetPosition);
}

// =====================================================
// SETUP
// =====================================================

void setup() {

  Serial.begin(115200);

  // Encoder
  pinMode(ENCODER_CLK, INPUT_PULLUP);
  pinMode(ENCODER_DT, INPUT_PULLUP);
  pinMode(ENCODER_SW, INPUT_PULLUP);

  lastEncoderState =
    (digitalRead(ENCODER_CLK) << 1) |
     digitalRead(ENCODER_DT);

  // I2C OLED
  Wire.begin(OLED_SDA, OLED_SCL);

  u8x8.begin();
  u8x8.setPowerSave(0);
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.clearDisplay();

  drawHeader();

  // Servo UART
  Serial2.begin(
    SERVO_BAUD,
    SERIAL_8N1,
    SERVO_RX,
    SERVO_TX
  );

  hlscl.pSerial = &Serial2;

  delay(500);

  Serial.println();
  Serial.println("HLS3606M Servo Controller");
  Serial.println("------------------------");

  // Initial position read
  updateServoPositions();

  if (positionValid[selectedServo]) {
    targetPosition = currentPosition[selectedServo];
  }

  drawAllServos();
  printSelectedPosition();
}

// =====================================================
// MAIN LOOP
// =====================================================

void loop() {

  handleEncoder();
  handleButton();

  // Periodically read all seven servos
  if (millis() - lastReadTime >= READ_INTERVAL) {

    lastReadTime = millis();

    updateServoPositions();
  }
}


    Serial.println("send command.");

    // wait a moment for servos to react
    delay(100);

    // ------------------------------------------------------
    // read out actual position
    // ------------------------------------------------------

    int actualPosition = hlscl.ReadPos(SERVO_ID);

    if (actualPosition >= 0)
    {
      Serial.print("Position: ");
      Serial.println(actualPosition);

      float degrees =
        actualPosition * 360.0f / 4096.0f;

      Serial.print("approx.: ");
      Serial.print(degrees, 2);
      Serial.println(" degree");
    }
    else
    {
      Serial.print("Error: ");
      Serial.println(actualPosition);
    }

    Serial.println();
  }
}

"Final Code"

Using the previous code as a basis, I gave Gemini the following prompts to produce the final implementation:
1. Modify the code so that it can be used with a Joy-IT 2.42-inch OLED display in I2C mode.
2. Modify the code so that rotating the rotary encoder navigates between menu entries and pressing a button selects the servo whose position should be changed. A second button press returns to the menu. The code should provide 7 servos, one submenu with 4 predefined poses, and 2 selectable animations. A menu entry for returning to the servo menu is required. If the menu does not fit on the display, it should be scrollable.
3. The display should refresh only when the rotary encoder is rotated or a button is pressed.
4. Use hardware interrupts to read the rotary encoder and remove the clearDisplay option unless the menu changes.
5. Modify the code so that navigation can jump directly from the first menu entry to the last, without scrolling through all intermediate entries.
6. Modify the code so that menu navigation wraps around instead of jumping. The menu should operate as an infinite loop.
7. Create individual min and max boundary variables for all 7 servos.
8. Add a configuration entry to both menus, allowing the min and max boundaries of all 7 servos to be configured. Is it possible to store these values in the EEPROM so they remain available after the device is switched off and on again?
9. The configuration menu should contain only the three entries "Min", "Max", and "Back", without duplicate entries. The selection indicator should always appear on the left side, before the text. It should not be placed on the right side behind "Min" or "Max".
10. Implement dynamic encoder control: when the encoder is rotated slowly, the position_step variable should increase or decrease by 10; during fast rotation, it should change by 100.
11. While configuring the min and max boundaries in the configuration menu, the current position should remain visible and the servo should be controlled directly.
12. The current position should be displayed above the min value.
13. Add an option to adjust the display brightness from 0 to 100% in the configuration menu.
14. Remove the 0 to 100% mapping and use the full range from 0 to 255, while displaying the current value.

Thoughts on the prompts:
1. A physical OLED display was required instead of a serial monitor.
2. Initially, menu entries could only be cycled by pressing a button, which was unintuitive and inconvenient.
3. The display flickered.
4. The rotary encoder readings were unreliable, and the display continued to flicker while the encoder was being rotated.
5. Navigation only moved from the beginning to the end and then required scrolling through all intermediate entries again. This was inconvenient.
6. Wraparound navigation was too abrupt and appeared hectic.
7. Safety measures are required to prevent the hand from damaging itself. This occurred during a presentation with my professor.
8. Servo boundaries are not useful if they cannot be adjusted while the device is running or if they require a code modification. The most recently configured values must remain available at all times.
9. In the configuration menu, "Min" and "Max" appeared twice, and the selection indicator moved between the left and right sides of the display.
10. An increment of 10 was unnecessarily slow, while 100 was too imprecise. Therefore, both speeds should be supported dynamically.
11. Configuring boundaries without providing immediate visual feedback is error-prone. Direct servo control should probably be toggled on and off, although it can remain active as long as the servo stays within its boundaries and cannot move into an unexpected range.
12. The current position was displayed at the bottom of the menu. Positioning it at the top improves readability.
13. The display was very bright, but adjustability is useful when it is exposed to sunlight or another strong light source.
14. There is no reason to restrict the possible brightness settings.

show code
#include <Arduino.h>                                            // include basic arduino framework library
#include <Wire.h>                                               // include library for I2C communication
#include <U8x8lib.h>                                            // include library for the JoyIt 2.42" OLED Display
#include <HLSCL.h>                                              // include library to control the bus servos
#include <Preferences.h>                                        // include library to access the flash memory from the ESP32 S3

// define pins to there corrosponding hardware connection
#define ENCODER_CLK D0                                          // rotary encoder "clock" pin -> pin A
#define ENCODER_DT  D1                                          // rotary encoder data pin -> pin B
#define ENCODER_SW  D2                                          // rotary encoder button pin -> don't press while booting up the system, otherwise the ESP32 S3 could start in another bootmode
#define OLED_SDA    D4                                          // I2C data pin for the display and other devices
#define OLED_SCL    D5                                          // I2C clock pin for the display and other devices
#define OLED_RES    D3                                          // reset pin for the display
#define SERVO_TX    D6                                          // transmitter pin to communicate with the bus servo driver board and then with the bus servos
#define SERVO_RX    D7                                          // receiver pin to communicate with the bus servo driver board and then with the bus servos

// bus servo motor parameter configuration and boundaries
#define SERVO_COUNT 7                                           // define how many servos are connected
const uint8_t servoIDs[SERVO_COUNT] = { 1, 2, 3, 4, 5, 6, 7 };  // set all servo id's to communicate with the right servo motor (servos programmed on this id before)
const uint32_t SERVO_BAUD = 1000000;                            // baud rate to communicate to the servos
const int SERVO_SPEED = 32766;                                  // movement speed from the servos
const int SERVO_ACCEL = 50;                                     // acceleration from the servos
const int SERVO_TORQUE = 700;                                   // maximum torque drom the servos

// initialia boundaries, getting overridden from the flash memory after reboot
int32_t servoMin[SERVO_COUNT] = {    0,    0,    0,    0,    0,    0,    0 };
int32_t servoMax[SERVO_COUNT] = { 3000, 3000, 3000, 3000, 3000, 3000, 3000 };

int displayBrightness = 100;                                    // set initial display brightness

enum MenuState {                                                // setup menu and status structure
  STATE_MAIN_MENU,                                              // main menu: live control of the servos, configuration menu, poses and automatic movements menu
  STATE_SERVO_ACTIVE,                                           // live control of the servos
  STATE_POSE_MENU,                                              // poses and automatic movement menu: poses and automatic movements, configuration menu, back
  STATE_CONFIG_SERVO_LIST,                                      // configuration menu list: servos 1-7, display brightness, back
  STATE_CONFIG_PARAM,                                           // configuration servo parameter: set min and max boundaries for the selected servo 
  STATE_CONFIG_EDIT_VAL,                                        // live changing of the min or max boundaries from the selected servo
  STATE_CONFIG_BRIGHTNESS                                       // live changing of the display brightness
};

MenuState currentMenuState = STATE_MAIN_MENU;                   // initial start menu -> main menu
MenuState lastMenuState = STATE_MAIN_MENU;                      // initial last menu state -> main menu because there was no other menu before

const uint8_t TOTAL_MAIN_ITEMS        = SERVO_COUNT + 2;        // number of menu items at the main menu: 7 servos + 1 poses and automatic movement + 1 configuration = 9 items
const uint8_t TOTAL_POSE_ITEMS_FIXED  = 8;                      // number of menu items at the poses and automatic movement menu: 4 poses + 2 animations + 1 configuration + 1 back = 8 items
const uint8_t TOTAL_CONFIG_SERVO_ITEMS = SERVO_COUNT + 2;       // number of menu items at the configuration menu: 7 servos + 1 display brightness + 1 back = 9 items
const uint8_t TOTAL_CONFIG_PARAM_ITEMS = 3;                     // number of menu items at each servo boundarie configuration menu: min-limit + max-limit + back = 3 items

uint8_t selectedIndex = 0;                                      // momentary position in a menu
uint8_t scrollOffset = 0;                                       // set anker point for the menu that it not get cut up or go over the display boundarie
const uint8_t DISPLAY_ROWS = 6;                                 // set how many rows are visible on the display

uint8_t configServoIndex = 0;                                   // select which servo are beeing configurated
bool configuringMin = true;                                     // selection boolean, which boundarie is manipulated true = min, false = max

// OBJECTS
HLSCL hlscl;                                                    // instantiate an object for the servo parameter and the servo class
U8X8_SSD1309_128X64_NONAME2_HW_I2C u8x8(OLED_RES);              // instantiate an object for the OLED display
Preferences preferences;                                        // instantiate an object to read and write variables in to the flash memory

// data and flash memory functions
int32_t currentPosition[SERVO_COUNT] = {0};                     // read current position from the selected servo
bool positionValid[SERVO_COUNT] = {false};                      // control bool variable for the position reading of each servo
unsigned long lastReadTime = 0;                                 // counter for the servo position read out interval
const unsigned long READ_INTERVAL = 250;                        // set an intervall in ms where the servo position is checked

volatile int encoderCounter = 0;                                                        // interrupt varabial to save the rotary encoder position
volatile int lastEncoderState = 0;                                                      // save the last know position from the rotary encoder to compare it
const int8_t encoderTable[16] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 }; // Lookup table for rotary encoder behaviour

bool lastButtonState = HIGH;                                    // variable to save the last know status from the rotyr encoder button
unsigned long lastButtonTime = 0;                               // variable to save the time the button was pressed
const unsigned long BUTTON_DEBOUNCE = 200;                      // set a debounce time in ms where another button press are ignored to make sure that only actual button presses are detected and the bouncing of the     signal while pressing the button is reduced

void loadSettingsFromFlash() {                                  // function to load parameters from the flash memory
  preferences.begin("aerohand", true);                          // access flash memory in read only mode
  for (int i = 0; i < SERVO_COUNT; i++) {                       // cycle through all servos and read out the saved min and max boundarie
    char keyMin[10], keyMax[10];                                // buffer servo id and min/max boundarie name for the flash memory access
    snprintf(keyMin, sizeof(keyMin), "s%d_min", i);             // build key name to read out the min boundarie for each servo from the flash memory
    snprintf(keyMax, sizeof(keyMax), "s%d_max", i);             // build key name to read out the max boundarie for each servo from the flash memory

    servoMin[i] = preferences.getInt(keyMin, servoMin[i]);      // read out min boundarie for each servo
    servoMax[i] = preferences.getInt(keyMax, servoMax[i]);      // read out max boundarie for each servo
  }

  displayBrightness = preferences.getInt("brightness", 100);    // set default display brightness for the first initialisation to 100 % -> 255
  preferences.end();

  u8x8.setContrast(map(displayBrightness, 0, 100, 0, 255));     // set display brightness while mapping a 0 to 100 % integers to the actuall 256 value range for tghis parameter
}

void saveLimitsToFlash() {                                      // function to save parameters to the falsh memory
  preferences.begin("aerohand", false);                         // access flash memory in read-write mode
  for (int i = 0; i < SERVO_COUNT; i++) {                       // cycle through all servos and save the min and max boundarie in the flash memory
    char keyMin[10], keyMax[10];                                // buffer servo id and min/max boundarie name for the flash memory access
    snprintf(keyMin, sizeof(keyMin), "s%d_min", i);             // build key name to write the min boundarie for each servo from the flash memory
    snprintf(keyMax, sizeof(keyMax), "s%d_max", i);             // build key name to write out the max boundarie for each servo from the flash memory

    preferences.putInt(keyMin, servoMin[i]);                    // read out min boundarie for each servo
    preferences.putInt(keyMax, servoMax[i]);                    // read out max boundarie for each servo
  }
  preferences.end();
}

void saveBrightnessToFlash() {                                  // function to save the display brightness value to the falsh memory
  preferences.begin("aerohand", false);                         // access flash memory in read-write mode
  preferences.putInt("brightness", displayBrightness);          // save momentary display brightness value in the flash memory
  preferences.end();                                            // end falsh memory access
}

void IRAM_ATTR encoderISR() {                                                   // interrupt service routine (ISR) for the rotary encoder
  int currentState = (digitalRead(ENCODER_CLK) << 1) | digitalRead(ENCODER_DT); //read momentary rotary enccoder position
  int encoderIndex = (lastEncoderState << 2) | currentState;                    // calculate direction and status from the rotary encoder
  encoderCounter += encoderTable[encoderIndex];                                 // compared encoder index to the Lookup-table
  lastEncoderState = currentState;                                              // override lastEncoderState with the new value
}

void drawMenu() {                                                                                                                       // function to build the menues and visualize them on the display
  if (currentMenuState != lastMenuState) {                                                                                              // checked if you switching between menues
    u8x8.clearDisplay();                                                                                                                // if it switch the menu the display will be cleared
    lastMenuState = currentMenuState;                                                                                                   // override last know lastMenuState
    scrollOffset = 0;                                                                                                                   // set scrollOffset anker point
  }

  uint8_t totalItems = 0;                                                                                                               // set variable to the item number in a menu 
  if (currentMenuState == STATE_MAIN_MENU || currentMenuState == STATE_SERVO_ACTIVE) totalItems = TOTAL_MAIN_ITEMS;                     // set total Item variabel depending on the define menu size, for the Main menu
  else if (currentMenuState == STATE_POSE_MENU) totalItems = TOTAL_POSE_ITEMS_FIXED;                                                    // set total Item variabel depending on the define menu size, for the Pose menu
  else if (currentMenuState == STATE_CONFIG_SERVO_LIST) totalItems = TOTAL_CONFIG_SERVO_ITEMS;                                          // set total Item variabel depending on the define menu size, for the     Configuration menu
  else if (currentMenuState == STATE_CONFIG_PARAM || currentMenuState == STATE_CONFIG_EDIT_VAL) totalItems = TOTAL_CONFIG_PARAM_ITEMS;  // set total Item variabel depending on the define menu size, for the Boundaries    menu

  if (currentMenuState == STATE_MAIN_MENU || currentMenuState == STATE_SERVO_ACTIVE) {                                                  // check which menu is selected, starting with the main menu
    u8x8.drawString(0, 0, "=== AERO HAND ===");                                                                                         // write a titel on the display

    for (uint8_t i = 0; i < DISPLAY_ROWS; i++) {                                                                                        // cylce throug the different display rows to write each menu item
      uint8_t itemIndex = (scrollOffset + i) % totalItems;                                                                              // calculate which menu item is in this position at the display
      char line[17];                                                                                                                    // buffer for menu points
      char indicator = (itemIndex == selectedIndex) ? '>' : ' ';                                                                        // put a ">" indicator in front of the selected menu item, otherwise it shows a     space 

      if (itemIndex < SERVO_COUNT) {                                                                                                    // checked the selected servo
        if (currentMenuState == STATE_SERVO_ACTIVE && itemIndex == selectedIndex) {                                                     // if the servo is selected 
          snprintf(line, sizeof(line), "[%cS%u: %7ld]", indicator, servoIDs[itemIndex], (long)currentPosition[itemIndex]);              // it will get highlighted with "[ ]" and the momentary position are read out
        } else {
          if (positionValid[itemIndex]) {                                                                                               // if the servo is not selected, check if there is already a actual position    reading
            snprintf(line, sizeof(line), "%cS%u: %7ld", indicator, servoIDs[itemIndex], (long)currentPosition[itemIndex]);              // if there is already a positioning reading write it
          } else {
            snprintf(line, sizeof(line), "%cS%u: -------", indicator, servoIDs[itemIndex]);                                             // otherwise displayed as blank (-------)
          }
        }
      } else if (itemIndex == SERVO_COUNT) {                                                                                            // after the servo list is the "Pose and Animation" menu
        snprintf(line, sizeof(line), "%c> Pose & Anima", indicator);                                                                    // write it on the display with the corrosponding selction indicator
      } else {                                                                                                                          // after the "Pose & Animation" menu is the "Configuration" menu
        snprintf(line, sizeof(line), "%c> Configuration", indicator);                                                                   // write it on the display with the corrosponding selction indicator
      }

      uint8_t len = strlen(line);                                                                                                       // measure character in line to overwritte them to counter ghosttext
      while (len < 16) line[len++] = ' ';                                                                                               // every symbol slot following the newly written string, is fillt up with a space
      line[16] = '\0';                                                                                                                  // end string object
      u8x8.drawString(0, i + 1, line);                                                                                                  // show the new string at the correct position on the display
    }
  } 
  else if (currentMenuState == STATE_POSE_MENU) {                                                                                       // check if the pose & animation menu is selected
    u8x8.drawString(0, 0, "=== POSEN / ANIMS ===");                                                                                     // write the menu titel on the display

    const char* poseNames[TOTAL_POSE_ITEMS_FIXED] = {                                                                                   // setup menu items for the pose & animation menu
      "1. Fist",
      "2. Open Hand",
      "3. Peace",
      "4. Pinch",
      "Anim: Wave",
      "Anim: Grab",
      "> Configuration",
      "< Back to Main"
    };

    for (uint8_t i = 0; i < DISPLAY_ROWS; i++) {                                                                                        // cycle through menu rows
      uint8_t itemIndex = (scrollOffset + i) % totalItems;                                                                              // calculate which menu item is selected
      char line[17];                                                                                                                    // buffer for menu points
      char indicator = (itemIndex == selectedIndex) ? '>' : ' ';                                                                        // put a ">" indicator in front of the selected menu item, otherwise it shows a     space 

      snprintf(line, sizeof(line), "%c %s", indicator, poseNames[itemIndex]);                                                           // show menu items at the corosponding position on the display

      uint8_t len = strlen(line);                                                                                                       // measure character in line to overwritte them to counter ghosttext
      while (len < 16) line[len++] = ' ';                                                                                               // every symbol slot following the newly written string, is fillt up with a space
      line[16] = '\0';                                                                                                                  // end string object
      u8x8.drawString(0, i + 1, line);                                                                                                  // show the new string at the correct position on the display
    }
  }
  else if (currentMenuState == STATE_CONFIG_SERVO_LIST) {                                                                               // check if the configuration menu is selected
    u8x8.drawString(0, 0, "=== CONFIG MENU ===");                                                                                       // write the menu titel on the display

    for (uint8_t i = 0; i < DISPLAY_ROWS; i++) {                                                                                        // cycle through menu rows
      uint8_t itemIndex = (scrollOffset + i) % totalItems;                                                                              // calculate which menu item is selected
      char line[17];                                                                                                                    // buffer for menu points
      char indicator = (itemIndex == selectedIndex) ? '>' : ' ';                                                                        // put a ">" indicator in front of the selected menu item, otherwise it shows a     space 

      if (itemIndex < SERVO_COUNT) {                                                                                                    // checked if the menu item is a servo
        snprintf(line, sizeof(line), "%cS%u Limits", indicator, servoIDs[itemIndex]);                                                   // wrote on the display the selction indicator at the correct position and Servo    id with the string Limits
      } else if (itemIndex == SERVO_COUNT) {                                                                                            // checked if the menu item is directly after a servo
        snprintf(line, sizeof(line), "%cBrightness", indicator);                                                                        // wrote on the display the selction indicator at the correct position and    Brightness
      } else {                                                                                                                          // otherwise the menu item is back
        snprintf(line, sizeof(line), "%c< Back", indicator);                                                                            // wrote on the display the selction indicator at the correct position and Back
      }

      uint8_t len = strlen(line);                                                                                                       // measure character in line to overwritte them to counter ghosttext
      while (len < 16) line[len++] = ' ';                                                                                               // every symbol slot following the newly written string, is fillt up with a space
      line[16] = '\0';                                                                                                                  // end string object
      u8x8.drawString(0, i + 1, line);                                                                                                  // show the new string at the correct position on the display
    }
  }
  else if (currentMenuState == STATE_CONFIG_PARAM || currentMenuState == STATE_CONFIG_EDIT_VAL) {                                       // checked if the servo limit configuration menu is selected and if a menu point    is selected (button press) or not
    char header[17];                                                                                                                    // max symbol counter for the display width (16+1)
    snprintf(header, sizeof(header), "=== SET S%u ===", servoIDs[configServoIndex]);                                                    // write header with corosponding servo id included
    u8x8.drawString(0, 0, header);                                                                                                      // set position on the display to 0,0 and write the header

    for (uint8_t i = 0; i < DISPLAY_ROWS; i++) {
      char line[17];                                                                                                                    // buffer for menu points

      if (i == 0) {                                                                                                                     // select the first menu row after the header
        snprintf(line, sizeof(line), "Is:  %5ld", (long)currentPosition[configServoIndex]);                                             // write the current servo position always right alligned after the string "Is: "
      } 
      else if (i == 1) {                                                                                                                // select the second menu row after the header
        char indicator = (selectedIndex == 0) ? '>' : ' ';                                                                              // write the selection indicator if the row is selected (selectedIndex and i are    different because the first row after the header can't be selected)
        if (currentMenuState == STATE_CONFIG_EDIT_VAL && configuringMin)                                                                // checked if the button is pressed and we are in editing mode and if the control     variable which boundarie is edit is true -> edit min boundarie
          snprintf(line, sizeof(line), "[%cMin: %5ld]", indicator, (long)servoMin[configServoIndex]);                                   // write the selction indicator some [] for highlighting that we are in editing     mode and the boundarie value
        else                                                                                                                            // otherwise
          snprintf(line, sizeof(line), "%cMin: %5ld", indicator, (long)servoMin[configServoIndex]);                                     // write the selction indicator and the set it boundarie value -> editing mode off
      } 
      else if (i == 2) {                                                                                                                // select the third menu row after the header
        char indicator = (selectedIndex == 1) ? '>' : ' ';                                                                              // write the selection indicator if the row is selected (selectedIndex and i are    different because the first row after the header can't be selected)
        if (currentMenuState == STATE_CONFIG_EDIT_VAL && !configuringMin)                                                               // checked if the button is pressed and we are in editing mode and if the control     variable which boundarie is edit is false -> edit max boundarie
          snprintf(line, sizeof(line), "[%cMax: %5ld]", indicator, (long)servoMax[configServoIndex]);                                   // write the selction indicator some [] for highlighting that we are in editing     mode and the boundarie value
        else                                                                                                                            // otherwise
          snprintf(line, sizeof(line), "%cMax: %5ld", indicator, (long)servoMax[configServoIndex]);                                     // write the selction indicator and the set it boundarie value -> editing mode off
      } 
      else if (i == 3) {                                                                                                                // select the fourth menu row after the header
        char indicator = (selectedIndex == 2) ? '>' : ' ';                                                                              // write the selection indicator if the row is selected (selectedIndex and i are    different because the first row after the header can't be selected)
        snprintf(line, sizeof(line), "%c< Back", indicator);                                                                            // write "< Back" at the selected menu row with the selection indicator
      } 
      else {                                                                                                                            // select all other lines from the fifth menu row on after the header
        snprintf(line, sizeof(line), "                ");                                                                               // write an empty row on the display
      }

      uint8_t len = strlen(line);                                                                                                       // measure character in line to overwritte them to counter ghosttext
      while (len < 16) line[len++] = ' ';                                                                                               // every symbol slot following the newly written string, is fillt up with a space
      line[16] = '\0';                                                                                                                  // end string object
      u8x8.drawString(0, i + 1, line);                                                                                                  // show the new string at the correct position on the display
    }
  }
  else if (currentMenuState == STATE_CONFIG_BRIGHTNESS) {                                                                               // checked if the display brightness configuration menu is selected
    u8x8.drawString(0, 0, "=== DISPLAY ===");                                                                                           // write the menu titel on the display

    for (uint8_t i = 0; i < DISPLAY_ROWS; i++) {                                                                                        // cycle through menu rows
      char line[17];                                                                                                                    // buffer for menu points
      if (i == 0) {                                                                                                                     // select the first menu row after the header
        snprintf(line, sizeof(line), "[>Bright: %3d%%]", displayBrightness);                                                            // write ">Bright:" and the momentary display brightness on the display
      } else if (i == 1) {                                                                                                              // select the second menu row after the header
        snprintf(line, sizeof(line), " < Back");                                                                                        // write "< Back" at the selected menu row
      } else {                                                                                                                          // select all other lines from the fifth menu row on after the header
        snprintf(line, sizeof(line), "                ");                                                                               // write an empty row on the display
      }

      uint8_t len = strlen(line);                                                                                                       // measure character in line to overwritte them to counter ghosttext
      while (len < 16) line[len++] = ' ';                                                                                               // every symbol slot following the newly written string, is fillt up with a space
      line[16] = '\0';                                                                                                                  // end string object
      u8x8.drawString(0, i + 1, line);                                                                                                  // show the new string at the correct position on the display
    }
  }
}

void readServoPositions() {                                     // read momentary position of each servo
  for (uint8_t i = 0; i < SERVO_COUNT; i++) {                   // cycle trough the servo id's
    int16_t pos = hlscl.ReadPos(servoIDs[i]);                   // read the position and save it
    if (pos != -1) {                                            // detect error/not responsive servo
      currentPosition[i] = pos;                                 // wrote it at the corrosponding array field
      positionValid[i] = true;                                  // allow that "-------" is shown as the momentary position
    }
  }
}

int16_t constrainPosition(uint8_t servoIdx, int32_t pos) {          // fuction to make sure the set it boundaries are not breached
  if (pos > servoMax[servoIdx]) return (int16_t)servoMax[servoIdx]; // checked if target position is higher that the set it max boundarie, if so the target position will be switcht to the max boundarie
  if (pos < servoMin[servoIdx]) return (int16_t)servoMin[servoIdx]; // checked if target position is lower that the set it min boundarie, if so the target position will be switcht to the min boundarie
  return (int16_t)pos;                                              // if the target position between the min and max boundarie just return the target position
}

void moveServoDelta(int32_t change) {                                                         // rotate servo if the rotary encoder value change
  if (selectedIndex >= SERVO_COUNT) return;                                                   // make sure a servo is selected otherwise jump out
  uint8_t sIdx = selectedIndex;                                                               // save selected servo id lokaly

  if (!positionValid[sIdx]) return;                                                           // make sure there is a valid position read out, if not the servo is not allowed to get moving commands

  int32_t target = currentPosition[sIdx] + change;                                            // calculate new servo position based on the old one and how much the rotary encoder is rotated
  target = constrainPosition(sIdx, target);                                                   // make sure the tagret position is allowed by jumping into the corosponding fuction

  hlscl.WritePosEx(servoIDs[sIdx], (int16_t)target, SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);  // send the new calculated position to the servo with the pre definied parameters
  currentPosition[sIdx] = target;                                                             // save the new calculated position in to the lokal buffer, so the display can directly show the new position without     reading it again
}

void executePoseOrAnimation(uint8_t poseIndex) {                                          // function to control hand movement with predefined poses and animations
  int32_t targetPos[SERVO_COUNT] = {0};                                                   // local array to save target positions

  switch (poseIndex) {                                                                    // define the poses and animations in a switch case, for the poses an array would also be possible but then there would be two    different structures 
    case 0:                                                                               // fist
      for(int i = 0; i < SERVO_COUNT; i++) targetPos[i] = servoMax[i];                    // close all fingers
      break;
    case 1:                                                                               // open Hand
      for(int i = 0; i < SERVO_COUNT; i++) targetPos[i] = servoMin[i];                    // open all fingers
      break;
    case 2:                                                                               // peace
      targetPos[3] = servoMin[3];                                                         // open the index finger
      targetPos[4] = servoMin[4];                                                         // open the middle finger
      for(int i = 0; i < SERVO_COUNT; i++){                                               // cycle through all fingers
        if (i != 3 && i != 4){                                                            // checked that every finger is cycled through except the index and middle finger
          targetPos[i] = servoMax[i];                                                     // close all selected fingers
        }  
      }
      break;
    case 3:                                                                               // pinch
      targetPos[0] = servoMin[0];                                                         // close the thumb abductor partially
      targetPos[1] = servoMin[1];                                                         // close the thumb flex partially
      targetPos[2] = servoMin[2];                                                         // close the thumb tendon partially
      targetPos[3] = servoMin[3];                                                         // close the index finger partially
      for(int i = 4; i < SERVO_COUNT; i++){                                               // cycle through the middle, ring and pinky finger
        targetPos[i] = servoMax[i];                                                       // open all selected fingers
      }
      break;
    case 4:                                                                               // wave
      for(int a = 0; a < 3; a++) {                                                        // repeat the movement 3 times
        for(int i = 0; i < SERVO_COUNT; i++) {                                            // cycle through all fingers
          int16_t p4_1 = constrainPosition(i, servoMin[i]);                               // set animation first position (all fingers open)
          hlscl.WritePosEx(servoIDs[i], p4_1, SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);    // send the new calculated position to the servo with the pre definied parameters
          delay(1000);                                                                    // gave the servos some time to move and stay in there positions
        }
        for(int i = 0; i < SERVO_COUNT; i++) {                                            // cycle through all fingers
          int16_t p4_2  = constrainPosition(i, servoMax[i]);                              // set animation first position (all fingers open)
          hlscl.WritePosEx(servoIDs[i], p4_2, SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);    // send the new calculated position to the servo with the pre definied parameters
          delay(1000);                                                                    // gave the servos some time to move and stay in there positions 
        }
      }
      return;
    case 5:                                                                               // grab
      for(int i = 0; i < SERVO_COUNT; i++) {                                              // cycle through all fingers
        int16_t p5_1 = constrainPosition(i, servoMin[i]);                                 // set animation first position (all fingers open)
        hlscl.WritePosEx(servoIDs[i], p5_1, SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);      // send the new calculated position to the servo with the pre definied parameters
        delay(1000);                                                                      // gave the servos some time to move and stay in there positions
      }
      for(int i = 0; i < SERVO_COUNT; i++) {                                              // cycle through all fingers
        int16_t p5_2  = constrainPosition(i, servoMax[i]);                                // set animation first position (all fingers open)
        hlscl.WritePosEx(servoIDs[i], p5_2, SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);      // send the new calculated position to the servo with the pre definied parameters
        delay(1000);                                                                      // gave the servos some time to move and stay in there positions 
      }
      return;
  }

  if (poseIndex <= 3) {                                                                   // check if it is a pose and not an animation (animations locked the menu and will be executet in there switch case application)
    for (int i = 0; i < SERVO_COUNT; i++) {                                               // cycle through all servos
      int16_t safeTarget = constrainPosition(i, targetPos[i]);                            // varify that all given positions are within the set it boundaries and copy the calculated target positions in to a new array    that contains only verified position values 
      hlscl.WritePosEx(servoIDs[i], safeTarget, SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);  // send the new calculated position to the servo with the pre definied parameters
    }
  }
}

void onEncoderTurn(int direction, int32_t stepSize) {                                                                                   // function to interpret rotational input logik from the rotary encoder
  uint8_t totalItems = 0;                                                                                                               // set variable to the item number in a menu 
  if (currentMenuState == STATE_MAIN_MENU || currentMenuState == STATE_SERVO_ACTIVE) totalItems = TOTAL_MAIN_ITEMS;                     // set total Item variabel depending on the define menu size, for the Main menu
  else if (currentMenuState == STATE_POSE_MENU) totalItems = TOTAL_POSE_ITEMS_FIXED;                                                    // set total Item variabel depending on the define menu size, for the Pose menu
  else if (currentMenuState == STATE_CONFIG_SERVO_LIST) totalItems = TOTAL_CONFIG_SERVO_ITEMS;                                          // set total Item variabel depending on the define menu size, for the     Configuration menu
  else if (currentMenuState == STATE_CONFIG_PARAM || currentMenuState == STATE_CONFIG_EDIT_VAL) totalItems = TOTAL_CONFIG_PARAM_ITEMS;  // set total Item variabel depending on the define menu size, for the Boundaries    menu
  else if (currentMenuState == STATE_CONFIG_BRIGHTNESS) totalItems = 2;                                                                 // set total Item variabel depending on the define menu size, for the Brightness    Configuration menu

  if (currentMenuState == STATE_SERVO_ACTIVE) {                                                                                         // check that a specific servo is selected
    moveServoDelta(direction * stepSize);                                                                                               // change into "live" mode where every rotational input from the rotary encoder is    translatet in to a servo movement
  } 
  else if (currentMenuState == STATE_CONFIG_EDIT_VAL) {                                                                                 // check if the Boundaries menu is active
    if (configuringMin) {                                                                                                               // check the selection variable -> if its true the min boundarie will be modify
      servoMin[configServoIndex] += (direction * stepSize);                                                                             // rotational input change the min boundarie of the selected servo
      if (servoMin[configServoIndex] < -32768) servoMin[configServoIndex] = -32768;                                                     // check that the datatype boundaries are not breached
      hlscl.WritePosEx(servoIDs[configServoIndex], (int16_t)servoMin[configServoIndex], SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);        // servo move to the new set it min boundarie
    } else {                                                                                                                            // check the selection variable -> if its false the max boundarie will be modify
      servoMax[configServoIndex] += (direction * stepSize);                                                                             // rotational input change the max boundarie of the selected servo
      if (servoMax[configServoIndex] > 32767) servoMax[configServoIndex] = 32767;                                                       // check that the datatype boundaries are not breached
      hlscl.WritePosEx(servoIDs[configServoIndex], (int16_t)servoMax[configServoIndex], SERVO_SPEED, SERVO_ACCEL, SERVO_TORQUE);        // servo move to the new set it max boundarie
    }
    saveLimitsToFlash();                                                                                                                // save the new set it limits to the flash memory
  }
  else if (currentMenuState == STATE_CONFIG_BRIGHTNESS) {                                                                               // ckeck if the brightness configuaration menu is active
    displayBrightness += direction * (stepSize > 10 ? 5 : 1);                                                                           // rotational input change the display brightness with a higher step resolution so    the brightness could be fine-tune
    if (displayBrightness > 100) displayBrightness = 100;                                                                               // if the read out value would be over 100 % it will be set it to 100 %
    if (displayBrightness < 0) displayBrightness = 0;                                                                                   // if the read out value would be over 0 % it will be set it to 0 %

    u8x8.setContrast(map(displayBrightness, 0, 100, 0, 255));                                                                           // map the rotational input from 0 % to 100 % to the actual value range from 0 to     255 and change it directly to this setting
    saveBrightnessToFlash();                                                                                                            // save the new set it brightness value to the flash memory
  }
  else {
    selectedIndex = (selectedIndex + direction + totalItems) % totalItems;                                                              // if nothing is selected the rotational input let us cycle through the menu items    in an infinte loop and make sure that the selection indicator and the "selected" menu item is always on the display

    bool visible = false;                                                                                                               // control variable to check if a menu item is shown on the display or not
    for (uint8_t i = 0; i < DISPLAY_ROWS; i++) {                                                                                        // cycle through the menu items
      if ((scrollOffset + i) % totalItems == selectedIndex) {                                                                           // check which menu item is visible in which display row
        visible = true;                                                                                                                 // if a menu item is shown on the display control varaible is true
        break;                                                                                                                          // terminate for loop
      }
    }
    if (!visible) {                                                                                                                     // check if the menu item is not shown on the display
      if (direction > 0) {                                                                                                              // check if the coursor would move on the bottom side out of the display
        scrollOffset = (selectedIndex - DISPLAY_ROWS + 1 + totalItems) % totalItems;                                                    // bring the coursor from a theoretical menu point outside the visible display    area to the lowest row from the display and scroll the menu "up" by setting up the offset parameter accordingly
      } else {                                                                                                                          // otherwise the coursor would move on the top side out of the display
        scrollOffset = selectedIndex;                                                                                                   // bring the coursor from a theoretical menu point outside the visible display    area to the highest row from the display and scroll the menu "down" by setting up the offset parameter accordingly
      }
    }
  }
  drawMenu();                                                                                                                           // write menu on the display
}

void handleEncoderRotation() {                      // function to interpret rotational input signals from the rotary encoder and resolve the signals
  int step = 0;                                     // lokal buffer

  noInterrupts();                                   // lock interrrupts and make sure that there are no signal collision (value will not be read it, while code is accessing the value)
  if (encoderCounter >= 4) {                        // check if the enncoder is rotated two the right and land on or in between two snap-in points
    step = 1;                                       // lokal buffer know that the rotational input was a rotation to the right
    encoderCounter -= 4;                            // save the encoder steps in between two snap-in points
  } else if (encoderCounter <= -4) {                // check if the enncoder is rotated two the left and land on or in between two snap-in points
    step = -1;                                      // lokal buffer know that the rotational input was a rotation to the left
    encoderCounter += 4;                            // save the encoder steps in between two snap-in points
  }
  interrupts();                                     // allow intterrupts again

  if (step != 0) {                                  // check if the encoder was rotated
    unsigned long now = millis();                   // save the momentary runtime from the esp32
    static unsigned long lastTurnTime = 0;          // save the last know turntime
    unsigned long dt = now - lastTurnTime;          // calculate how much time has passed since the last rotational input
    lastTurnTime = now;                             // set last know turntime to the momentary runtime

    int32_t dynamicStep = (dt < 80) ? 100 : 10;     // if the rotary encoder is rotated slowly (<80 ms) it will change the selected value by 10 and if it is rotated fast (>80 ms) it will change the selected value by 100
    onEncoderTurn(step, dynamicStep);               // interpret clean rotational input
  }
}

void handleButtonPress() {                                                                            // function to interpret button signals from the rotary encoder switch in all possible menues
  bool buttonState = digitalRead(ENCODER_SW);                                                         // control variable to check if the switch was pressed or not

  if (buttonState == LOW && lastButtonState == HIGH && millis() - lastButtonTime > BUTTON_DEBOUNCE) { // detect signal edges, debounce the signal by comparing the time between the last know valid input and the active    input to a set it parameter
    lastButtonTime = millis();                                                                        // save the runtime from the esp32 from the last valid button input

    if (currentMenuState == STATE_MAIN_MENU) {                                                        // check if the coursor is in the Main menu
      if (selectedIndex < SERVO_COUNT) {                                                              // check if a servo is selected
        currentMenuState = STATE_SERVO_ACTIVE;                                                        // change in to the live servo control mode
      } else if (selectedIndex == SERVO_COUNT) {                                                      // check if the pose & animation menu is selected
        currentMenuState = STATE_POSE_MENU;                                                           // switch to the Pose & Animation menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      } else {                                                                                        // otherwise the Configuration menu is selected
        currentMenuState = STATE_CONFIG_SERVO_LIST;                                                   // switch to the Configuration menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      }
    } 
    else if (currentMenuState == STATE_SERVO_ACTIVE) {                                                // check if a servo is in the live control mode
      currentMenuState = STATE_MAIN_MENU;                                                             // end the servo live control mode
    } 
    else if (currentMenuState == STATE_POSE_MENU) {                                                   // check if the coursor is in the Pose & Animation menu
      if (selectedIndex < 6) {                                                                        // check if a pose or animation is selected
        executePoseOrAnimation(selectedIndex);                                                        // pose or animation is executed
      } else if (selectedIndex == 6) {                                                                // check if the congiguration menu is selected
        currentMenuState = STATE_CONFIG_SERVO_LIST;                                                   // switch to the Configuration menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      } else {                                                                                        // otherwise back is selected
        currentMenuState = STATE_MAIN_MENU;                                                           // switch to the Main menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      }
    }
    else if (currentMenuState == STATE_CONFIG_SERVO_LIST) {                                           // check if the coursor is in the Configuration menu
      if (selectedIndex < SERVO_COUNT) {                                                              // check if a servo is selected
        configServoIndex = selectedIndex;                                                             // save the id from the selected servo
        currentMenuState = STATE_CONFIG_PARAM;                                                        // switch to the Boundaries menu for the selected servo
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      } else if (selectedIndex == SERVO_COUNT) {                                                      // check if the coursor is in the Brightness configuration menu
        currentMenuState = STATE_CONFIG_BRIGHTNESS;                                                   // switch to the Brightness configuration menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      } else {                                                                                        // otherwise back is selected
        currentMenuState = STATE_MAIN_MENU;                                                           // switch to the main menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      }
    }
    else if (currentMenuState == STATE_CONFIG_PARAM) {                                                // check if the coursor is in a Boundarie menu
      if (selectedIndex == 0) {                                                                       // check if the min boundarie is selected
        configuringMin = true;                                                                        // set the control variable to modify the min boundarie
        currentMenuState = STATE_CONFIG_EDIT_VAL;                                                     // acticate modifikation from the min boundarie
      } else if (selectedIndex == 1) {                                                                // check if the max boundarie is selected
        configuringMin = false;                                                                       // set the control variable to modify the max boundarie
        currentMenuState = STATE_CONFIG_EDIT_VAL;                                                     // acticate modifikation from the max boundarie
      } else {                                                                                        // otherwise back is selected
        currentMenuState = STATE_CONFIG_SERVO_LIST;                                                   // switch to the Configuration menu
        selectedIndex = 0;                                                                            // reset coursor position
        scrollOffset = 0;                                                                             // reset scroll controll variable
      }
    }
    else if (currentMenuState == STATE_CONFIG_EDIT_VAL) {                                             // check if a boundarie modification is activated
      currentMenuState = STATE_CONFIG_PARAM;                                                          // deactivate boundarie modification
      selectedIndex = (configuringMin ? 0 : 1);                                                       // set the selection indicator on the right spot depending on which boundarie was edit
      scrollOffset = 0;                                                                               // reset scroll controll variable
    }
    else if (currentMenuState == STATE_CONFIG_BRIGHTNESS) {                                           // check if the coursor is in a Brightness configuration menu
      currentMenuState = STATE_CONFIG_SERVO_LIST;                                                     // switch to the Configuration menu
      selectedIndex = SERVO_COUNT;                                                                    // place the selction indicator on the last know position in the Configuartion menu -> at the menu item for the     Brightness configuration menu
      scrollOffset = 0;                                                                               // reset scroll controll variable
    }

    drawMenu();                                                                                       // write menu on the display
  }
  lastButtonState = buttonState;                                                                      // override lastButtonState with the new one
}

void setup() {                                                                  // function only executed onex at the microcontroller start
  Serial.begin(115200);                                                         //start serial communication for debugging purposes with a baudrate of 115200

  loadSettingsFromFlash();                                                      //load saved settings from the falsh memory

  pinMode(ENCODER_CLK, INPUT_PULLUP);                                           // set rotary encoder clock pin as a input with internal pullup
  pinMode(ENCODER_DT, INPUT_PULLUP);                                            // set rotary encoder data pin as a input with internal pullup
  pinMode(ENCODER_SW, INPUT_PULLUP);                                            // set rotary encoder switch pin as a input with internal pullup

  lastEncoderState = (digitalRead(ENCODER_CLK) << 1) | digitalRead(ENCODER_DT); // initiate the control variable lastEncoderState with the initial encoder position

  attachInterrupt(digitalPinToInterrupt(ENCODER_CLK), encoderISR, CHANGE);      // initiate interupt routine for the rotary encoder clock pin
  attachInterrupt(digitalPinToInterrupt(ENCODER_DT), encoderISR, CHANGE);       // initiate interupt routine for the rotary encoder data pin

  Wire.begin(OLED_SDA, OLED_SCL);                                               // initiate I2C communication for the display
  u8x8.begin();                                                                 // initiate communication between the esp32 and the display (theoreticaly doesn't matter which communication protocoll is used)
  u8x8.setPowerSave(0);                                                         // wake up display (display typicaly boot up in to sleep mode)
  u8x8.setFont(u8x8_font_chroma48medium8_r);                                    // set up a good readable font to show text on the display
  u8x8.clearDisplay();                                                          // clear the display to make sure no unwanted leds are on

  Serial2.begin(SERVO_BAUD, SERIAL_8N1, SERVO_RX, SERVO_TX);                    // start second serial communication to the servos with the defined parameters 
  hlscl.pSerial = &Serial2;                                                     // set the communication pointer in the library to the hardware interface
  delay(500);                                                                   // give the serial communication some time to set up correctly

  readServoPositions();                                                         // read momentary servo position for all servos
  drawMenu();                                                                   // write initial menu on the display
}

void loop() {                                                   // function executed as long as the micocontroller is running
  handleEncoderRotation();                                      // jump into the function to handle a rotational input from the rotary encoder 
  handleButtonPress();                                          // jump into the function to handle a button press input from the rotary encoder 

  if (millis() - lastReadTime >= READ_INTERVAL) {               // check the counter for the last read out and compared to the defined read-out interval
    lastReadTime = millis();                                    // reset counter
    readServoPositions();                                       // read out momentary servo positions
  }
}

Design Files

CAD

Click here to see the first idea

The weight measurement should be implemented using individual load cells for each spool holder. My first approach was to use the same or similar load cells that are already integrated into the hotends, but I couldn't find any specific information about them. The typical Δm will be 1 kg, with a range from 220 g to 1220 g, which corresponds to the weight of a 1 kg Prusament spool. Adafruit recommends using load cells rated for double the maximum expected weight for optimal measurement precision. With this in mind, the Adafruit 5 kg load cells could be a good choice, as they would also support 2 kg spools, which we occasionally use with our Prusa MK4S (formerly MK3.9). For optimal precision, a high-quality ADC such as the HX711 is essential. In week 09 I tested the usage of an HX711 in combination with an ESP32C3.
Beside the HX711 I looked for integrated ADC on the available microcontroller from the FabInventory and the Xiao ESP32C6.

Microcontroller ADC Resolution
Attiny 1624 12 bit (17 bit with oversampling)
Attiny 3226 12 bit (17 bit with oversampling)
Attiny 412 10 bit
ATSAMD11C14A 12 bit (12, 13, 14, 15, 16 bit with oversampling)
ATSAMD21E18A 12 bit (12, 13, 14, 15, 16 bit with oversampling)
AVR128DB32 12 bit
SAMD21 12 bit
Xiao ESP32C3 12 bit
Xiao ESP32C6 12 bit
Xiao ESP32S3 12 bit
Xiao RP2040 12 bit
Raspberry Pi Pico 12 bit

Other useful information from inside the box are temperature and humidity. For that I also did some experiments in week 09 with the conclusion that the BME688 will over achieve the job, it is still easy to use and implement why I'll want to integrated it in to the project even if the price is still high, specially for the module if its not bought separately.

The project will include multiple sensors and actors so I need a display and some way to navigate to a menu. Beside the load cells and a environment sensor I want to use a rotary encoder as a human input, which I experiment in week 9. To get an visual output I plan to use a display. For that I reason I experiment with a small and a bigger OLED display in week 10.

To realize the active drying feature I came up with two ideas.
1. Fan heaters which can be found as open, relatively small modules.
2. Dehumidifier membranes like these ones, which I found in a youtube video, while researching for already designed solutions for similar problems.

The first option have the problem that they have a high power consumption and that you don't want to use them unsupervised because they could easily start a fire. Cause of the heating elements in an closed and small room. The second option can fast be expensive but they don't use active heating, so there are less potential fire hazards. In the Sicco box which was an inspiration a fan heater from a Sunlu S4 is used.

It would be nice to have some kind of modularity so I can start with one spool holder in the box with a load cell, a display and a rotary encoder. The next iteration will conclude multiple spool holders and in the last iteration some kind of active drying solution can be added. I don't want to replace always the pcb and make some new wiring, so I plan to use multiple microcontroller. One microcontroller on each spool holder, so they will be modular, one main microcontroller where the display and rotary encoder is connected and optional one for the active drying solution, otherwise that could probably done by the main microcontroller. For that reason I tried out some simple networking in week 11.

System Integration

The thoughts about the system integration are documented in week 15.

Electronics

BOM

The prices will be calculated without shipping, with german taxes in €. For easier reproduction I'll try to minimize quantity of different shops even if it cost more.

ID Designator Component Quantity price/# price link Comment
01 U1, U2 Xiao ESP32-C3 2 4,39 $ 8,78 $ Digikey
02 U3 NCV1117ST50T3G 1 0,51 $ 0,51 $ Digikey
03 D1, D2, D3, D4, D5 Neopixel 5 3,96 $ 3,96 $ Digikey pack of 10
04 C1, C2 C3216X7R1H105K160AB 2 0,24 $ 0,48 $ Digikey temperature stability and rated voltage not necessary
05 R1, R2, R3 RC1206FR-0710KL 3 0,10 $ 0,30 $ Digikey
06 R4 RC1206FR-0710KL 1 0,09 $ 0,09 $ Digikey
07 J1, J2, J3, J4 TSM-107-01-L-SV 4 1,12 $ 4,48 $ Digikey Cutable sockets could be cheaper
08 J5 M20-9990246 1 0,10 $ 0,10 $ Digikey Cutable header could be cheaper
09 J6 PH1-01-UA 1 0,10 $ 0,10 $ Digikey Cutable header could be cheaper
10 J7 61300311121 1 0,12 $ 0,12 $ Digikey Cutable header could be cheaper
11 J8 SSM-114-L-SV-LC 1 3,40 $ 3,40 $ Digikey Cutable sockets could be cheaper
12 U4, U5, U6, U7, U8 HX711 5 4,79 $ 23,95 $ Digikey Cheaper on Amazon also available as a Kit with a load cell
13 S1 BME688 1 17,54 $ 17,54 $ Digikey
14 DS1 OLED 1 18,90 € 18,90 € Reichelt
15 SW1 Rotary Encoder 1 1,51 $ 1,51 $ Digikey
16 S2, S3, S4, S5, S6 Load Cell 5 kg 5 3,47 $ 17,35 $ Digikey different load cells also possible, cheaper on Amazon
17 DM1 Dehumidifier Membrane 1 82,58 € 82,58 € Micro Dehumidifier Alternative: M-1J1R
18
19
20
21
22
23
24
25

Mainboard

2 sided pcb

schematic

The first big challenge is to mill a 2 sided board. In preparation for this I build a vacuum clamp with bowel pins in week 07.
I did in the first try following steps:
1. drill 4 holes for positioning
2. mill the top side
3. flip the board along the x axis
4. mill the bottom side
5. mill vias, holes and the outline

Before I can drill the four holes in the double sided pcb stock in the same distance to each other then the dowel pins on the vacuum clamp, in my case 117 mm in x and 91,6 mm in y. I need to generate g-code for that. The first attempted was to use mods but with that I couldn't generate g-code for 2 mm holes with a 2 mm end mill. It was only possible with a 1,6 mm endmill. Ferdi could generate g-code for a 1,9 mm endmill for a 2 mm hole but with only 96 dpi instead of 999 dpi. We couldn't reproduce this, so I just let Fusion 360 generate the g-code for the 4 holes using the "Drill" tool with a 2 mm drill.

To prepare the png files for milling I have to make sure that I could use the same 0 point without any offset between the layers after flipping. Normally I exported the top layer and the outlines/holes as a pdf load them in Inkscape, make some small adjustments and then exported it as png to uploaded it into mods. For this pcb I decided to try gerber2png. For that I exported a gerber file from easyeda with following setting:

✅ Top Layer
✅ Bottom Layer
✅ Board Outline Layer
✅ Mechanical Layer
✅ Export Object

easyeda 01

I then ended up with following seven files:

easyeda 02

Which I drag and drop into Gerber2Png except the "How-to-order-PCB" file.

gerber2png 01

This generates the following different png files:

gerber2png 02

To only need two g-codes I opened the outline file and the hole file in gimp and lay them over each other to make one png file out of them. I will not drill completely through my stock material why I also flipped a copy of the drilling file to also drill the holes from the bottom side.

gerber2png 03

To make sure that I don't have any offsets while flipping the stock I loaded all files in to Inkscape and put them on a canvas with the size that matches the hole distance for the bowel pins. So as long as the coordinates from the front left dowel pin are correct I can easily flip the board and don't need to correct the origin.

gerber2png 04

Before I started the actual milling I tried the g-code in midair to make sure that the endmill not collide with the dowel pins, which are slightly raised.

While doing the test I came up with the idea to remove the critical pin on the front left, which is also the 0 point for the g-code. Later Ferdi told me, that I can adjust the jog height in mods. I then raise the jog height to 5 mm to make sure that it is definitely higher than the dowel pin.

But I was still a little bit scared and after I already broke one of the good endmills from Ferdi accidentally in a dump situation.

While milling the bottom I recognized that the png files gerber2png generates flips the board over the short side, while in my case I need it to flip the board along the long side, which result in a not usable pcb. But that gave me the chance to fix some small errors that I found. For example one trace thats handle the serial communication has a 90° angle on a via and I didn't put my name or "Fab Academy 25" on the board.

The results was still impressive and the difference between cheap and expensive endmills are definitely visible. Over the last weeks I used the cheap ones and for the final project I came in the pleasures situation to use the good ones. Thank you Ferdi for let me borrowing your endmills.

mill 03-04

To ensure that the coordinates from the origin are correct I put the wrong milled pcb back in the machine and milled the bottom side with the correct flipped file. Which wasn't a success because I used the wrong png file. The result itself looks promising and for the holes and outline I used the correct file which results in a good enough result. The y coordinate could be slightly of by a few μm which is good enough. All in all it took me 4 tries until everything works. The third try looks promising but I forgot to check the mill bit positions, so the mill used the wrong endmill for milling the holes, which results in bigger holes and without any pads.

PCB test

After soldering the pcb I began testing the different components. Firstly the Neopixels for that I used following test code:

#include <Adafruit_NeoPixel.h>                                               // library for NeoPixels

#define PIN_NEO_PIXEL D3                                                     // Xiao pin that connects to NeoPixel
#define NUM_PIXELS 5                                                         // The number of LEDs

Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800); // set the NeoPixel initialization

void setup() {
  NeoPixel.begin();                                                          // initialize the NeoPixel strip object
}

void loop() {
  for (int i = 0; i < 256; i++) {                                            // color cycling
    byte r = (i < 85) ? i * 3 : (i < 170) ? 255 - (i - 85) * 3 : 0;
    byte g = (i < 85) ? 255 - i * 3 : (i < 170) ? 0 : (i - 170) * 3;
    byte b = (i < 85) ? 0 : (i < 170) ? (i - 85) * 3 : 255 - (i - 170) * 3;

    for (int j = 0; j < 5; j++) {
      NeoPixel.setPixelColor(j, r, g, b);                                    // set color
    }

    NeoPixel.setBrightness(100);                                             // reduce brightness to 100 from 255, only for filming otherwise not need it
    NeoPixel.show();                                                         // output the color
    delay(10);                                                               // short delay for the color change
  }
}

Secondly I integrated the rotary encoder into the test.

#include <Adafruit_NeoPixel.h>    // library for NeoPixels
#include <Encoder.h>              // library for rotary encoder

#define PIN_NEO_PIXEL D3          // Xiao pin that connects to NeoPixel
#define NUM_PIXELS 5              // number of LEDs
#define dt D7                     // Xiao pin that connects to rotary encoder dt
#define clk D9                    // Xiao pin that connects to rotary encoder clk
#define sw D8                     // Xiao pin that connects to rotary encoder sw

Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800); // set the NeoPixel initialization
Encoder brightness(dt,clk);                                                  // initiate object rotary encoder with the name brightness

int encoder_value = 0;            // value of rotary encoder
int brightness_value = 255;       // brightness value for the NeoPixel
int brightness_value_old = 255;   // previous brightness value for the NeoPixel
bool sw_control = false;

void setup() {
  Serial.begin(115200);            // initial serial communication with a baud rate of 115200
  NeoPixel.begin();                // initialize the NeoPixel strip object
  pinMode(sw, INPUT);              // set pin for rotary encoder button as an input
}

void IRAM_ATTR fallout()
{
  if (sw_control == false){
    brightness_value = brightness_value_old;
    sw_control = true;
  }
  else if (sw_control == true){
    brightness_value_old = brightness_value;
    brightness_value = 0;
    sw_control = false;
  }
}

void loop() {
  for (int i = 0; i < 256; i++) {                                             // go through all possible values to control a Neopixel
    byte r = (i < 85) ? i * 3 : (i < 170) ? 255 - (i - 85) * 3 : 0;           // set first set of number ranges for a color cycle 
    byte g = (i < 85) ? 255 - i * 3 : (i < 170) ? 0 : (i - 170) * 3;          // set second set of number ranges for a color cycle 
    byte b = (i < 85) ? 0 : (i < 170) ? (i - 85) * 3 : 255 - (i - 170) * 3;   // set third set of number ranges for a color cycle 

    if (encoder_value != brightness.read()){
      encoder_value = brightness.read();
      brightness_value = encoder_value;
    }
    Serial.println(brightness_value);

    for (int j = 0; j < 5; j++) {
      NeoPixel.setPixelColor(j, r, g, b);             // set color
    }
    NeoPixel.setBrightness(brightness_value);
    NeoPixel.show();                                   // output the color
    attachInterrupt(sw, fallout, HIGH);
    delay(10);                                         // short delay for the color change
  } 
}

Thirdly I integrated the OLED display to make sure that everything works together.

#include <Adafruit_NeoPixel.h>                                               // library for NeoPixels
#include <Encoder.h>                                                         // library for rotary encoder
#include <Wire.h>                                                            // include wire library need it for the Adafruit_GFX library
#include <Adafruit_GFX.h>                                                    // include Adafruit_GFX library need it for the Adafruit_SSD1306 library
#include <Adafruit_SSD1306.h>                                                // include Adafruit_SSD1306 library tp control the OLED display

#define PIN_NEO_PIXEL D3                                                     // Xiao pin that connects to NeoPixel
#define NUM_PIXELS 5                                                         // number of LEDs
#define dt D7                                                                // Xiao pin that connects to rotary encoder dt
#define clk D9                                                               // Xiao pin that connects to rotary encoder clk
#define sw D8                                                                // Xiao pin that connects to rotary encoder sw
#define SCREEN_WIDTH 128                                                     // set OLED display width
#define SCREEN_HEIGHT 64                                                     // set OLED display height
#define OLED_RESET -1                                                        // set the reset pin

Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800); // set the NeoPixel initialization
Encoder brightness(dt,clk);                                                  // initiate object rotary encoder with the name brightness

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);    // initialize an Adafruit_SSD1306 object called display with the parameters from above

int encoder_value = 0;                                                       // value of rotary encoder
int brightness_value = 255;                                                  // brightness value for the NeoPixel
int brightness_value_old = 255;                                              // previous brightness value for the NeoPixel
bool sw_control = false;

void setup() {
  Serial.begin(115200);                                                      // initial serial communication with a baud rate of 115200
  NeoPixel.begin();                                                          // initialize the NeoPixel strip object
  pinMode(sw, INPUT);                                                        // set pin for rotary encoder button as an input

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {                          // checked if a display is available  
    Serial.println(F("SSD1306 allocation failed"));                          // if no display is available send an error message to the serial monitor  
    for(;;);
  }

  display.clearDisplay();                                                    // clear the display --> set every pixel to black  
}

void displayMessage(int message) {                                           // function to visualize a message on the display
  display.clearDisplay();                      
  display.setTextSize(1);                                                    // set text size
  display.setTextColor(SSD1306_WHITE);                                       // set the text color
  display.setCursor(0,0);                                                    // set the position where the text is shown on the display
  display.println("Encoder Value:");                                         // send the input from the function to the display
  display.setCursor(0,10);                                                   // set the position where the text is shown on the display
  display.println(message);                                                  // send the input from the function to the display
  display.display();                                                         // show data on the display with the parameters from above
}

void IRAM_ATTR fallout()
{
  if (sw_control == false){
    brightness_value = brightness_value_old;
    sw_control = true;
  }
  else if (sw_control == true){
    brightness_value_old = brightness_value;
    brightness_value = 0;
    sw_control = false;
  }
}

void loop() {
  for (int i = 0; i < 256; i++) {                                             // go through all possible values to control a Neopixel
    byte r = (i < 85) ? i * 3 : (i < 170) ? 255 - (i - 85) * 3 : 0;           // set first set of number ranges for a color cycle 
    byte g = (i < 85) ? 255 - i * 3 : (i < 170) ? 0 : (i - 170) * 3;          // set second set of number ranges for a color cycle 
    byte b = (i < 85) ? 0 : (i < 170) ? (i - 85) * 3 : 255 - (i - 170) * 3;   // set third set of number ranges for a color cycle 

    if (encoder_value != brightness.read()){
      encoder_value = brightness.read();
      brightness_value = encoder_value;
    }
    displayMessage(encoder_value);                                            // display the encoder value on the display

    for (int j = 0; j < 5; j++) {
      NeoPixel.setPixelColor(j, r, g, b);                                     // set color
    }
    NeoPixel.setBrightness(brightness_value);
    NeoPixel.show();                                                          // output the color
    attachInterrupt(sw, fallout, HIGH);
    delay(10);                                                                // short delay for the color change
  } 
}

And it didn't worked because I mixed up SDA and CLK on the display. So I have to mill and solder a new pcb but now I know how it works, so it should work alot faster. After I fix this I used the test code again and it works.

Before fixing the mixed up sda and clk pins I tried out the last functionality, if the serial communication between the xiao's works or if there is also a problem. I asked CHatGPT for some basic code to test the communication between the two boards with following prompt:

"Write a code which coud be compiled in the arduino ide for two xiao esp 32c3 which allows them to communicated over a serial communication on pin pin d0 and d1. The result should be visible in a serial monitor."

Which result after some small modification in the following code for the transmitter:

void setup() {
  Serial.begin(115200);        // Debug monitor
  Serial1.begin(9600, SERIAL_8N1, 2, 3);  // TX only on GPIO3 (D1)
  // Note: RX pin is set to -1 because we're only transmitting here
  Serial.println("Sender ready.");
}

void loop() {
  String message = "Hello";
  Serial1.println(message);    // Send to receiver
  Serial.println("Sent: " + message);
  delay(1000);
}

And for the receiver:

void setup() {
  Serial.begin(115200);         // Debug monitor
  Serial1.begin(9600, SERIAL_8N1, 2, 3);  // RX only on GPIO1 (D0)
  // Note: TX pin is set to -1 because we're only receiving
  Serial.println("Receiver ready.");
}

void loop() {
    String received = Serial1.readStringUntil('\n');
    Serial.println("Received: " + received);
}

final project test 04

Distributionboard

Out of time concerns I desided to use cables to connect the HX711 modules with the mainboard. To collect all the neccessary connections to the mainboard I designed a small distribution pcb which then connect all signals bundled to the mainboard. For that reason the board is located on the inside of the Eurobox close to the mainboard. To make the schemativ a little bit easier to read I used different small connectors, at the pcb they are put together as one connector for less cable chaos.

distributionboard 01

Adapterboards

The Adapterboards are nothing more than 90° bracket to connect the HX711 module to the cable that runs to the Distributionboard. To make the cable ruting alittle bit cleaner there are different types of Adapterboards.

Mechanics

BOM

The prices will be calculated without shipping, with german taxes in €. For easier reproduction I'll try to minimize quantity of different shops even if it cost more.

ID Component Quantity price/# price link Comment
01 Bearing 608 20 0,98 $ 15,38 $ Digikey bulk discount
02 Eurobox ED64/42 1 31,71 € 31,71 € Auer Packaging
03 DIN EN ISO 4017 - M3x12 20 0,073 € 1,46 € Amazon
04 DIN EN ISO 4032 - M3 20 0,0449 € 0,898 € Amazon
05 DIN EN ISO 10642 - M4x12 10 0,1398 € 1,398 € Amazon
06 Ruthex M3 thread insert 8 0,0899 € 0,7192 € Ruthex
07 DIN EN ISO 7380-1 - M3x6 8 0,0721 € 0,5768 € Amazon
08 Spool holder side 10 3D-printed
09 Spool holder baseplate 5 laser cut
10 Screw cover 20 3D-printed
11 Load cell spacer small 5 3D-printed
12 Load cell spacer big 5 3D-printed
13 Load cell spacer big cover 5 3D-printed
14 Baseplate 1 laser cut
15 Silica box 2
16 Mainboard back cover 1 3D-printed
17 Mainboard front cover 1 3D-printed
18 Mainboard holder 2 3D-printed

The main enclosure for the project will be a Eurobox, because our shelf system is configured to fit Euroboxes and it makes it easy and cheap to reassemble. To fit different sizes of filament spools inside without going to big I decided to use a Box with the size 60 x 40 x 43,5 mm. To make sure that my design will fit with the existing components I reverse engineer a few by myself like the load cell or the filament spools. Others like the Eurobox I search for 3D models online.

Spool holder

Spool holder side

The spool holder side is printed which results in a okayisch surface quality. For the first iteration it is ok but needs to be improved for the finished product. The bearings will be snap fit in to position and only needs slightly pressure to slide in the correct position. The first printed version already works good but need some bigger distance to ensure that the outer ring of the bearing are not rubbing against the spool holder side, which result in unnecessary friction which could compromise the functionality. Better bearings would also a good improvement but for now I'll use the one that are momentary available.

Spool holder baseplate

To ensure that the spool holder sides fits perfectly in to the spool holder baseplate, I make some test with the conclusion that 4,9 mm will works the best because 4,8 mm fits better for just one connection but because I have two I wanted a little bit more of play at the connection, why I choose 4,9 mm.

spool holder baseplate 01

The first plate looks like that.

spool holder baseplate 02

There is still no sliding movement possible because the connection clamps a little bit together between the two connections. It feels more like a good fit, if the parts shouldn't move at all. The biggest challenge is that the parts need some room to slide from right to left but on the other side also make sure that the parts didn't jam.
Out of aesthetics reasons I decided to use counter sink screes to make a clean, even finish without any unnecessary disturbance. To realize the counter sink I use a drill pressed and a countersink drill.

spool holder baseplate 03

For the next iteration I increase the widthenes a little bit, that I could also fit the bigger 2 kg spools from DAS FILAMENT which we also use. It is still enough space in between the plates that they are still not touching eachother to make sure that the measurements are correct.

spool holder baseplate 04

Screw cover

To ensure easy variation of the position from the Spool holder sides but still secure them safely in place. I decided to use some type of thumbscrews which can get fast expensive and four for each spool holder is needed so all in all 20 to make it cheaper but still allows a similar easy handling I chosen to make them on my own. To make it easy and fast to manufacture I used ISO 4017 screws as a base and add some cover around it which is comfortable and easy to turn. For that reason I needed the hexagon head screw to ensure screw propulsion a form fit between the hexagon head and the Screw cover is used. To ensure a good fit I added some dogbones to the hexagon hole because with 3D printing the holes will not have perfect inner corners.

screw cover 01

screw cover 02

Load cell

Load cell spacer small

To connect the load cell with spool holder the load cell spacer small is inserted between the spool holder base plate and the load cell together with two DIN EN ISO 10642 - M4x12 screes to hold everything in place.

load cell spacer small 01

Load cell spacer big

The first idea was to make this part as simple as the load cell spacer small but confronted with the problem that I need to place the HX711 modules somewhere close to the load cell. I decided that it would be best to combine the spool holder spacer big with a small case for the HX711 module. That required some type of locking mechanism for the pcb. To realize this I choose a small lid over the pcb. The pcb itself can be slide inside from the side. I couldn't use any clips because the board didn't have any mounting holes.

load cell spacer big 01

load cell spacer big 02

Load cell spacer big cover

To cover the HX711 module a small cover is need it. The idea to mount this on the load cell spacer big I wanted to use a sliding mechanism. This needed some trails to find the perfect fit. To hold it in place I wanted to add some small holes and pins which snap in place. The corresponding geometries was to small to got a reasonable result. For now I'll not using it and try to print it on the SLA printer or to design the geometry bigger.

load cell spacer big cover 01

Printing it on a SLA printer didn't improve the situation it still similar tide probaply a little bit worst and looks ugly, not that the 3d print with a FFF printer looks nice but defnetli better than the SLA version.

load cell spacer big cover 02

Baseplate

To put the baseplate sandwitch together I used DIN EN ISO 10642 M3x8 screws. Which I screw in from the top. They are secured into cuttet thread in the Baseplate bottom.

Baseplate top

The Baseplate connect everything together mechanical and electrical wise. All five load cells are mounted on to the Baseplate to ensure a secure positioning inside the box. The baseplate itself is out of multiple plates which are sandwitched, which allows me to run cables inside the baseplate. The three layers are screwed together to hold everything in place. To make sure that it will fit inside the box i laser cut a mockup out of cardboard. Which was a good idea, because the 3d model wasn't that accurate and it reveal some problems. Also the walls of the box are condionend to the manufacturing procces. While deep drawing the walls get streched, which results in case of these thin polymere in some tension, which bow the walls inside. Its not a big problem but the baseplate has to push a little bit harder into position because the walls need to be bend straight.

baseplate 01

I tried to fix these problems to has a perfect fit. The second mock up fixed the general dimension issues but still have some minor problems with the radius.

baseplate 02

The third try went well enough, the general dimension are fixed and the radius also looks nice.

baseplate 03

Baseplate spacer

The Baseplate spacer allows to insert cables into the baseplate and also holds the adapterboards and the distributionboard in place.

Baseplate bottom

The bottom part of the baseplate is similar to the Baseplate top, just without the cutouts for the HX711 modules and with some countersunk holes at the bottom, to allow a flush positionig inside the Eurobox.

Silica box

To allow an easy exchange of the silica pearls I deceided to use one box one at the back to contain all of them, so if you wanted to exchange them, you only need to remove the silica box from the Eurobox, dry the pearls and put them back in or use new pearls.

silica box 01

Mainboard housing

Mainboard back cover

The installation of the mainboard should be realized with two clamps that snap into two mounting holes into the pcb.

mainboard back cover 01

The display is directly soldered to the pcb and lack some type of mechanical support because its only connection to the pcb is on the top left corner. To fix this problem I implement two pins with small flanges to support the display into this part. They are going through a 4 mm hole in the pcb where the display can rest on the flange, to secure it in x and y axis a smaller 2,5 mm pin goes from flange to the display pcb.

mainboard back cover 02

The first print looks ugly, has a lot of stringing which came probaply from the age from the filament. It also represent the major design flaws. The pcb stands was to instable because of there heights.

mainboard back cover 03

The second version got some design improvements.

mainboard back cover 04

And also the print looks a lot more promising.

mainboard back cover 05

Last problem that has to be eliminated are that the clips that secure the board in place are to small, to be printed nicely, so I increased them slightly and at some support in the remainig corners because they are the ones that see any force, if the rotary encoder is pushed.

It's probaply not that neccessary because there is still the form fit but it will not make the part less good, if the support is added.

mainboard back cover 07

With these improvements that parts looks a lot better and more stable.

The snap in feature has some small problems in the corners because I printed everything on nominal size. To fix this problem I put a small chamfer on the corners that act like a undercut or recess.

mainboard back cover 10

Mainboard front cover

The cover will snap in place with one positive small radius on the right and left inside. That make sure that the geometry is hidden and nice finish is applied. For a nice surface finish the part will be printed with a SLA printer. On the inside some small channels are added to make sure that on each hole only the corresponding Neopixel is visible and no scattered light interrupt the aesthetics.

mainboard front cover 01

The first iteration of the part came with some mixed up coordinate systems which result in an general offset of the hole pcb inside the front cover.

mainboard front cover 02

This got fixed in the second iteration from this specific part. I also improvent the snap mechanism from a radius on both parts to a radius with a small champher which allows for easier assembly.

mainboard front cover 03

After the mechanical assembly works I go one step back and find out that the display cover is not mounted straight on to the pcb from the oled module and is crucet, which results in alignment issues. To fix this I put a bigger tolerance on to the part, to make sure that even if the display is a little bit croocket it will still fit inside the housing.

mainboard front cover 04

Mainboard holder

The Mainboard holder is responsible to connect the Mainboard back cover to the Eurobox. To make sure the parts together screes are use for the easy application. For that I want to use threaded insert, why I print them out of pla. A thermoplastic in needed to melt the thread inserts in to the part. To make this a little bit more easier I added 0,5 mm chamfer to the holes, so the threaded insert will self center it into the hole. The part also make sure that the User Interface is on an angle for easier usage.

inventor

For the first iteration two of these are used. For later spirals one wider holder with a hidden cable channel would be nice.

3D Models

Eurobox
Bearing 608

Software

Design Files

The final files will be added later.


To create this page, I used Copilot to check my syntax and grammar.

🅭🅯🄎 Aero Hand Test Stand © 2025 by Benedikt Feit is licensed under CC BY-SA 4.0.

Source code hosted at gitlab.fabcloud.org