SimpleFOC stepstick

I’ll be wearing my dunce cap for a long time after this. It turns out the 150mA threshold was not that the current sensors weren’t outputting anything, but rather that the ADC couldn’t read values smaller than ~50mV because I didn’t run the extremely simple built-in calibration procedure (just set the ADC_CR_ADCAL bit and wait until it clears itself).

I’d heard of it before, but somehow never thought to run it until I was working on Gooser and got nonlinear results from reading the bus voltage divider. I calculated that it had a ~50mV offset, probed the pin to verify, probed the current sensors and saw it there as well, and then thought to calculate what stepstick’s current sense output should be at 150mA, and that was also ~50mV. So I searched “STM32 50mv adc” and got several results saying to run the calibration.

But now that the low range is visible, I can see that the 0 amp reading seems to be influenced by other channels like in post #64. After some sleuthing, it appears the voltage doesn’t have quite enough time to settle when using the shortest sampling time option, so after sampling a channel with high value, sampling a zero shows some remnant voltage. Likewise, high values are dragged down (possibly the source of the apparent phase shift I was seeing in post #65). Increasing sample time from 2.5 to 12.5 cycles eliminates it, but the 6.5 cycle option is probably good enough and doesn’t reduce the maximum PWM duty as much.

HFS mode remains a mystery, giving 50-60% higher reading when the datasheet looks like it should be 95-100% higher, so I’d still like to get a simultaneous current measurement with some other device to verify which mode (if either) gives the true current.