Wiring the zoom knob, and a long debugging session

The Asteroid Test now has a working zoom knob: a B10K panel pot in the rig that zooms the view 1× / 2× / 4× around the digger.

#potentiometer#debugging#esp32
TABLE OF CONTENTS

Result. The Asteroid Test now has a working zoom knob: a B10K panel pot in the rig that zooms the view 1× / 2× / 4× around the digger. There's also a startup check screen that shows live readings with an OK beside each one, and it waits until I click the stick. Getting there meant finding six separate faults, one at a time.

The bench now. An MB102 power module sits on its own 400-hole breadboard, fed by the adapter. Its 5 V side powers the Nextion, and its 3.3 V side powers the joystick and the knob. Its ground is shared with the ESP32's GND.

Part Goes to
Nextion 5V / GND module 5 V side / ground
Joystick +5V / GND module 3.3 V side / ground (never 5 V)
Joystick VRx / VRy / SW GPIO 34 / 35 / 32
Knob: outer lugs module 3.3 V side and ground
Knob: middle lug (wiper) VP (GPIO 36)
Nextion TX / RX GPIO 27 / 26

The faults, in the order I found them

1. The breadboard was upside down. I'd mounted the 400 board the wrong way round, so its printed red + and blue − rails were swapped relative to the power module. A rail is just a metal strip, and the printing is only a label. What matters is that power and ground land on different strips. On this board, trust the module's own + and − markings.

2. The joystick was on 5 V. At rest it read about 2650 / 2675 instead of the usual ~1880. That number alone gave it away: it was on the 5 V side, which could push close to 5 V into GPIO 34/35 at full tilt (the safe limit is about 3.6 V). Moving it to the 3.3 V side brought it back to 1879 / 1896.

3. A broken jumper on the display's TX. The display drew everything, but never answered, so the sketch logged "never answered" and fell back to slower drawing (about 160 ms per step). Data was getting through in one direction only. A fresh jumper fixed it: the takeover went back to 921,600 baud, and an asteroid drew in about 100 ms.

4. The 3.3 V side was switched off. The knob's supply lug read 0 V. The MB102's jumper on that side was on OFF, not 3V3. Once set, it read 3.33 V.

5. A bad breadboard contact on the knob's signal wire. Even with power and VP right, it read noise until I pulled the jumper out a little. The pin had been sitting beside the hole's spring clips rather than between them. After that, the knob swept smoothly: 2586 → 2508 → 2465 → … → 1303.

6. The knob's ground lug cuts out. The zoom kept jumping to a level, then snapping back to fully zoomed out. When the ground end loses contact, the whole track floats up to 3.3 V, so the wiper reads 4095: "fully zoomed out", wherever the knob is. Next time I'm at the bench: check that solder joint and that wire with the meter while wiggling them.

What I learned

  • Noise means "not connected". An analog pin wired to nothing doesn't read 0. It reads random numbers that jump around, here 0 → 500 → 300 → 0. A wrong-but-connected wire reads a steady wrong value instead. So when readings go wild, look for a wire that isn't really making contact.
  • Snapping to one end means losing one end. A pot whose ground lug drops out reads the top of the range. If the supply lug dropped out, it would read 0.
  • One fault can hide another. Each fix seemed to change nothing until the last of the three knob faults (power, the VP column, the contact) was sorted out.
  • The MB102 can do 5 V and 3.3 V at once: each side has its own jumper. Share its ground with the ESP32, never bridge the two + rails, and don't feed the ESP32's 3V3 pin from it while it's also on USB.
  • Every CP2102 board shows up as usbserial-0001, and opening the serial port restarts this ESP32. Reading the boot output is how to tell which board is plugged in.
  • Power-up order used to matter. The sketch calibrated the stick and looked for the display in its first seconds, so turning the module on after the ESP32 gave a bad centre (the digger drove off on its own) or no display. Now the startup screen waits for my click, and calibrates after it, so order doesn't matter.

Software fixes along the way

  • Knob smoothing: each reading takes 15 samples, keeps the middle 7, and eases toward new values over about 0.1 s. A new zoom level must also hold for 0.3 s before the view switches.
  • Thrown-away samples after switching pins: the ESP32's analog pins share one converter, and the previous pin's voltage lingers for a moment. With the stick pushed hard over, that could drag the knob's reading with it. This was a precaution: the knob kept jumping after it, and the real cause was physical, with stick movements jostling the knob's wires (faults 5 and 6).
  • The knob turns the other way, which is the way I prefer, and clicking the stick no longer starts a new asteroid. I kept hitting it by accident.

Comments (0)

Leave a comment

Loading comments