Rotor Testbench
Hardware: components, pins and circuits. All values come from benchcode/pins.h.
COMPONENTS
| Component | Notes |
|---|---|
| Raspberry Pi | The server. Talks to the Nano by USB (/dev/ttyUSB0) |
| Arduino Nano | ATmega328P, old bootloader (cpu=atmega328old). Powered by the USB |
| ESC | Driven by the servo signal on D9. Its BEC (5 V) is used to detect the battery |
| Brushless motor | — |
| LiPo battery, 3S | Powers the ESC. Balance lead used to measure the voltage |
| Potentiometer | Throttle in POT mode |
| Push button | Unlock (hold 2 s) / lock (one tap) |
| 3 LEDs | Red, green, yellow; each with a 330 Ω resistor to GND |
| Buzzer | Beeps (driven with tone()) |
PINS
| Pin | Name in pins.h | Connected to | Mode |
|---|---|---|---|
| D2 | PIN_RED | Red LED (bench state) | output |
| D3 | PIN_GREEN | Green LED (bench state) | output |
| D4 | PIN_YELLOW | Yellow LED (battery) | output |
| D6 | PIN_BAT_DETECT | ESC BEC (battery plugged in) | input (external 100 kΩ pull-down) |
| D7 | PIN_BUZZER | Buzzer | output |
| D8 | PIN_BUTTON | Push button to GND | input pull-up |
| D9 | PIN_ESC | ESC signal | servo PWM (Timer1) |
| A0 | PIN_BATTERY | Battery voltage divider | analog |
| A6 | PIN_POT | Potentiometer wiper | analog (input only) |
| GND | — | Common to the ESC, battery divider, LEDs, button, pot | — |
CIRCUITS
ESC signal (D9)
Servo pulses, 50 per second: 1000 µs = 0 % (stopped), 2000 µs = 100 %. The firmware never goes above
MOTOR_MAX_PERCENT = 50 % (1500 µs). The ESC ground must be connected to the Nano GND.
Battery detection (D6)
ESC BEC red wire (5 V) --- 10 kΩ --- D6 --- 100 kΩ --- GND
Battery plugged into the ESC: the BEC gives 5 V and D6 reads HIGH (~4.5 V). Unplugged: the 100 kΩ pulls D6 to LOW. Never connect the BEC to the Nano 5V pin.
The Nano does not see the battery itself: it sees the BEC 5 V that come through the ESC cable. So ESC NONE
means "the ESC is not powered": the battery or the ESC cable was unplugged (tested: both give EVT ESC NONE).
D6 LOW for more than 50 ms (BAT_DISCONNECT_MS) = battery unplugged. After plugging in, the ESC needs
3 s (BAT_ARM_MS) to arm.
Battery voltage (A0)
battery + (balance lead) --- 10 kΩ --- A0 --- 4.7 kΩ --- GND
V(A0) = V(battery) × 4.7 / (10 + 4.7). A full 3S battery (12.6 V) gives 4.03 V on A0.
The highest voltage it can measure is VREF × 14.7 / 4.7 ≈ 14.5 V.
VREF = 4.64 V: the real voltage on the Nano 5V pin (measured with a multimeter; calibrate it for better readings).
Each measurement is the average of 16 readings (BAT_SAMPLES), every 100 ms.
| State | Battery | Per cell | Meaning |
|---|---|---|---|
NONE | < 6.0 V | — | no balance lead |
LOW | < 10.2 V | 3.4 V | the motor cannot turn; 2 s below this while UNLOCKED locks the bench |
WEAK | < 10.8 V | 3.6 V | finish the test and charge (hysteresis 0.2 V) |
GOOD | ≥ 10.8 V | — | — |
Push button (D8)
D8 → button → GND, with the Nano internal pull-up (INPUT_PULLUP): released = HIGH, pressed = LOW.
Debounce 20 ms (DEBOUNCE_MS).
Potentiometer (A6)
Ends to GND and 5V, wiper to A6. With pin 1 to GND and pin 3 to 5V, turning clockwise increases the value (0..1023). A6 is analog input only on the Nano.
LEDs (D2, D3, D4)
Pin → 330 Ω → LED → GND (HIGH = on).
LEDS AND BEEPS
LEDs
| What you see | Meaning |
|---|---|
| Red, green, yellow rotating (100 ms each) | ESC arming: wait |
| Red on | LOCKED |
| Red blinking (500 ms) | UNLOCKING: hold the button |
| Red blinking fast (200 ms) | UNLOCKING, button being held |
| Green on | UNLOCKED: the motor can turn |
| Yellow off | No battery |
| Yellow on | Battery good |
| Yellow blinking slowly (500 ms) | Battery weak or low |
Beeps
| Beep | Meaning |
|---|---|
| 2000 Hz short | UNLOCK accepted: hold the button |
| 2000 Hz long | Unlocked |
| 1000 Hz short | Locked (button tap or battery unplugged) |
| 1000 Hz long | Locked: battery low |
| 3000 Hz long | Locked: server lost (heartbeat) |