I’m using SimpleFOC V2.3.4, PlatformIO and ESP32S3 package version 3.0.4. I have two issues:
Issue 1: I’m getting an error in current_sense.init(). See below:
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
[ 1117][E][esp32-hal-adc.c:172] __analogChannelConfig(): Pin is not configured as analog channel
[ 1126][E][esp32-hal-adc.c:172] __analogChannelConfig(): Pin is not configured as analog channel
MOT: Align sensor.
MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 4.19
MOT: Align current sense.
CS: Switch A-B
CS: Inv B
MOT: Success: 4
MOT: Ready.
Looking into esp32_mcu.cpp, I noticed function _configureADCInline is setting pinMode(pin, ANALOG). Is there a mode called ANALOG? or, is it INPUT? Not sure if this is the cause of the error.
Issue 2: My ADC pins are A0 and A1. Not sure why align current sense is switching A,B and inv B. It works for Success 1. For Success 4, the BLDC motor only works in one-direction, but not both. What’s causing the inconsistencies?
Did you end up finding out what was going on with this? I am experiencing the same thing currently. I don’t recall having this issue before.
I can’t say for absolutely sure as it was a few weeks ago when I did a basic functionality test (same hardware and same pins being used), but am 99% it worked fine, otherwise, I would not have moved forward with implementation.
Looks like we missed to answer this question at the time…
This is normal. Analog input and digital input use different peripherals of the MCU, and this configures the pin to use the ADC for analog input.
That’s a good question. If you are sometimes getting success 1 and sometimes success 4 (without changing the wiring in-between) then there is something wrong. It should always be the same.
At a guess, maybe the currents are too low (less than the noise) so then you sometimes get the right result and sometimes (when the noise is “bad”) the wrong result.
You could try (carefully!!) to increase the alignment voltage a little bit to see if more current helps to give a clearer, more reliable signal.
I tried increasing my alignment voltage from 2V to 3V (6V BLDC motor), now I’m getting Success 2 consistently with message “CS: Switch B-(C)NC”. The comment in the code says phase B is not measured so put the _NC to phase B. However in my main program, I declared
InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A0, A1, NOT_SET), which PinC is not used. The logic is if (_isset(pinB) && !_isset(pinC) then swap PhaseB with PhaseC current. Why would the logic swap phases if PinC is not set?
Foc_current still works. Now getPhaseCurrents shows PhaseB is zero due to the swap.