Rotor Testbench

Hardware: components, pins and circuits. All values come from benchcode/pins.h.

COMPONENTS

ComponentNotes
Raspberry PiThe server. Talks to the Nano by USB (/dev/ttyUSB0)
Arduino NanoATmega328P, old bootloader (cpu=atmega328old). Powered by the USB
ESCDriven by the servo signal on D9. Its BEC (5 V) is used to detect the battery
Brushless motor—
LiPo battery, 3SPowers the ESC. Balance lead used to measure the voltage
PotentiometerThrottle in POT mode
Push buttonUnlock (hold 2 s) / lock (one tap)
3 LEDsRed, green, yellow; each with a 330 Ω resistor to GND
BuzzerBeeps (driven with tone())

PINS

PinName in pins.hConnected toMode
D2PIN_REDRed LED (bench state)output
D3PIN_GREENGreen LED (bench state)output
D4PIN_YELLOWYellow LED (battery)output
D6PIN_BAT_DETECTESC BEC (battery plugged in)input (external 100 kΩ pull-down)
D7PIN_BUZZERBuzzeroutput
D8PIN_BUTTONPush button to GNDinput pull-up
D9PIN_ESCESC signalservo PWM (Timer1)
A0PIN_BATTERYBattery voltage divideranalog
A6PIN_POTPotentiometer wiperanalog (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.

StateBatteryPer cellMeaning
NONE< 6.0 V—no balance lead
LOW< 10.2 V3.4 Vthe motor cannot turn; 2 s below this while UNLOCKED locks the bench
WEAK< 10.8 V3.6 Vfinish 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 seeMeaning
Red, green, yellow rotating (100 ms each)ESC arming: wait
Red onLOCKED
Red blinking (500 ms)UNLOCKING: hold the button
Red blinking fast (200 ms)UNLOCKING, button being held
Green onUNLOCKED: the motor can turn
Yellow offNo battery
Yellow onBattery good
Yellow blinking slowly (500 ms)Battery weak or low

Beeps

BeepMeaning
2000 Hz shortUNLOCK accepted: hold the button
2000 Hz longUnlocked
1000 Hz shortLocked (button tap or battery unplugged)
1000 Hz longLocked: battery low
3000 Hz longLocked: server lost (heartbeat)