Adc
Current
A warning on missing codes in cheap MCU ADCs, and a tip on compensating
Over the last few weeks I’ve been grading my servo board’s measurement chain against a multimeter, one channel at a time. Every current, voltage and temperature the servo reads goes through the CH32V006’s ADC (analog-to-digital converter), so before trusting any of it I wanted to know what the converter itself does. The datasheet’s ADC table lists clock rates, sample times and supply ranges, and says nothing at all about linearity or offset. So I measured it. Most of it is fine. A few things surprised me though, and one of them is a calibration bit the manual calls reserved that makes every reading worse. This post collects the quirks I would want to know about if I was starting a project today. I measured all of this on a CH32V006, but most of it isn’t a WCH thing. The sawtooth, the reference that needs a long sample time, and the codes that go missing when the clock runs too fast all come from how a SAR (successive-approximation) converter works, and you’ll find the same kinds of errors on most microcontrollers. Only the hidden calibration bit is specific to this chip. If you’re new here, OpenServoCore is my effort to turn cheap MG90S-class servos into networked smart actuators with sensor feedback, cascade control, and its own single-wire bus protocol. The measurements below live in the stage 1 notebooks of the notebooks repo, and most of them ran on one rev 2A dev board, board D, which carries a CH32V006 (WCH’s sub-20-cent RISC-V microcontroller).