Hi, all. Some of you may find this quite useful.
I took some time today to figure out how to use temperature monitoring on the B-G431B-ESC1 with simpleFOC, as the board has a thermistor on pin PB14. After looking through some STM32CubeIDE source code, I found the voltage to temperature mapping:
For anyone trying to read the temperature on their own B-G431B-ESC1, just declare PB14 as an input in your setup:
pinMode(A_TEMPERATURE, INPUT);
(A_TEMPERATURE
is already mapped to PB14 in platformio) Then, to read the temperature, do this:
temp = map(analogRead(A_TEMPERATURE),0,1024,-49,125);
The pin can do 12 bits resolution, but analogRead seems to work with 10 bits or the pin was programmed with a 10-bit resolution somewhere. Idk. This still works great and map()
doesnāt work on decimal numbers, anyways, so itās whatever.
However, disappointingly, this doesnāt work when integrated in a SimpleFOC application. I think the ADC on pin PB14 is shared with another pin and that other pin gets prioritized over PB14 or itās declared before PB14. Am I right? I just get 0V, -49C with the exact same readTemp()
function.
The reason I had to develop this is because my board gets āoh my god hotā even at low speeds. The project Iām doing hasā¦
motor.torque_controller = TorqueControlType::voltage; //torque measured in [V], lol.
motor.controller = MotionControlType::velocity; //velocity measured in [rad/s]
motor.foc_modulation = FOCModulationType::SpaceVectorPWM; //15% more power eventually
Iām running 24V so the required current draw is half that of 12V and the motor has no load and is going at maybe 40% of its max rpm.
My motor.current_limit
is set to 10A, but I expect to be getting nowhere near that with a sensored setup. Did I screw up by not setting driver.voltage_limit
? It seems redundant to me when Iām already setting motor.current_limit
.
Iāll be measuring the driverās current draw and the motorās current draw. Curious what Iāll see. Got a clamp meter coming in, but for now Iāll try with a multimeter and some really āsusā wiring on one of the phases. Edit: using a power meter, I see that Iām drawing 3.6W from my outlet when no motor sketch is uploaded, then a peak of 8W when sensor alignment runs, and then 5.5W afterwards. The chip is toasty warm, regardless. Not hot, no, butā¦well, I suppose SimpleFOC demands a fair bit of computing power at any pointā¦nah Iām still not convinced. Might try with a second board soon.
Iāve read @Valentineās thread post here about what to do with motors getting hot or starting to shake, etc., but thatās for an open-loop setup and without current sensing, I think. I know I have motor.torque_controller = TorqueControlType::voltage
, but I really donāt want to go about tuning two sets of PID values for current sensing if I donāt have to.
Iām assuming that the declaration for low-side current sensing in the B-G431B-ESC1 I have is correct, since I got it from the boardās hardware-specific example on the simpleFOC github repo:
LowsideCurrentSense currentSense(0.003, -64.0/7.0, A_OP1_OUT, A_OP2_OUT, A_OP3_OUT);
Iāll want to eventually run this motor at higher power (~400W), so Iāve ordered some little heatsinks, fans, and thermal paste, but thatās for when the motor is actually doing big work. At less than 50W output, I expect the driver to run cool. Meanwhile, after sensor alignment, Iām seeing a reading of 45°C on the NTC?? Iāll be confirming this with an infrared gun next week.
Hereās the closed loop sketch Iāve been running: link.
Hereās the temperature reading sketch Iāve been running: link.
Edit:
Ok. Did some tests.
Target (rad/s) | Power meter reading (W) | Multimeter reading on one phase (A) |
---|---|---|
0 | 5.5 | 0 |
5 | 5.6-5.7 | 0.4 (0Hz) |
10 | 6.1 | 0.68 (0Hz) |
20 | 7.9 | 1.28 (23Hz) |
30 | 10.4 | 1.88 (34Hz) |
40 | 13.5 | 2.42 (46Hz) |
50 | ⦠| ⦠|
Hmm I think I can hear/see cogging at 5 rad/s. Motor definitely not completely quiet at 10 rad/s. Sounds likeā¦a muffled, spinning ratchet with very many tiny teeth⦠I guess youād call this cogging? Already uncomfortable to touch the MCU at T40, didnāt go to T50. Max is 3000rpm, so that would be T314. Wow. And this is with no load!
I wonāt have any huge changes in load in my application, but there will be a mixer spinning through bread dough. It will have to put up quite the fight. Lots of work to be doneā¦
I donāt see anything in the Overview of the ESC mentioning back-drive protection. Thatās what youād call it, yes, when thereās bemf sending (large) current from the motor to the driver due to applied load?
Wondering what to do about the temp and cogging. I think I have to try TorqueControlType::foc_current
. I have no other ideas at the moment.
Edit:
As a side note, when command line (motor.monitor) is telling me 0.7A, the multimeter connected to one phase going into the motor tells me 1.0A (on AC mode). ⦠1/sqrt(2) = 0.7?? Seems this 1/sqrt(2) relationship holds for current at any target velocity. Iāll have a look at what that relationship is, exactly, a little later. And Iāll see how different the results are with foc_current
(without and with 2xPID tuning).
Oh, and I get very different sounds from the motor depending on the speed. At T15, I hear a pretty audible sound once per rotation. At T10, I hear only a faint, constant ratchet. At T20, I hear an audible, maybe 4x per revolution ratchet. Similar at T25. Less so at T30. Definitely there at T50. Musical mysteryā¦or misery.
Have a great weekend, everyone.