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:
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
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.
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
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.
Ok. Did some tests.
|Target (rad/s)||Power meter reading (W)||Multimeter reading on one phase (A)|
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.
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.