Hi everyone, I am a college student and I am using this amazing library to do my assignment of Control theory.

I need to demonstrate how the PID parameters (of closed-loop velocity control) were determined in my paper, so I think I should get the transfer function of my BLDC motor first. I decided to achieve that goal by measuring the frequency response of the motor under closed-loop torque control.

So, to make sure what is the input of the system (which might be voltage or current accroding to this document), I need to know which torque control method was used in velocity control. But the document page of closed-loop velocity control only says The velocity control is created by adding a PID velocity controller to the torque control loop.

Thank you all in advance .

By the way, according to the closed-loop velocity control document, the PID output could be current or voltage, dose it mean the PID output will be target current once the phase resistance is provided? (Since I really donâ€™t know much about FOC and i believe my driver board donâ€™t have current sensor built in )

And here is my code:

BLDCMotor motor = BLDCMotor(7 , 6.12, 295.1642857);

Yes, if you provide the motor phase resistance, the PID operates on â€śestimated currentâ€ťâ€¦

The velocity control loop uses the PID, which outputs a target current or voltage. If the phase resistance is known, then the output is a current, and this is then converted to the target voltage after the PID.

This target voltage (actually 2 voltages, Uq and Ud) are then passed to the FOC control loop. This loop does not use a PID. It takes the target Uq/Ud and the current rotor angle, and converts these (using inverse park/clarke) to the 3 phase voltages for the stator to keep the magnetic fields of rotor and stator orthogonal.

We call this method â€śtorque-voltageâ€ť control because the currents are not measured and therefore we assume current is proportional to voltage. This assumption is ok for small motors / low power systems.

I am sorry I didnâ€™t make my question clear, I am still confusing about what dose the â€śTorque control loopâ€ť stands for in this box diagram, since there are four modes in Torque control loop.

So the torque control loop is what I called the FOC loop in my post above. If you donâ€™t have current sensing, then the current is just assumed to be proportional to voltage, and so the input current is converted to voltage according to V=IR and this is applied to the motor phases using the FOC clarke/parke transformations.
See also here: Torque control | Arduino-FOC

If you have current sensing, then there is another control loop with PIDs to regulate the current. This is what you see if you click on â€śFOC current modeâ€ť in the Torque Control | Arduino-FOC page:

Wouldnâ€™t the best figure to use for calculating current from voltage include the frequency of the signal and the inductance? We would want to use the total impedance of the system divided by voltage, not just the resistance, I think. This wonâ€™t make any difference at smaller speeds where the frequency is low, but it should make a difference at higher speeds.
12 ohm motor with 1.3 mH inductance is at 100 hz(~100 rads per sec for a 7 pole motor ) is 12.11 ohm impedance so not a big difference
14.51 ohms at 1000 hz. more significant difference.

It still doesnâ€™t account for my observations, I noticed during stall the motor current does not actually match ohms law drawn from motor.voltage and the impedance for some reason, I wasnâ€™t clear why, or maybe my power supply current is not accurate or something.

A bigger concern with the assumption that voltage *resistance = torque is that itâ€™s not factoring in back emf. Actual torque control should use the relevant figure coming out from the park transform, which factors in actual current, rotor angle and electrical angle. Shouldnâ€™t it? Or one could use voltage, back emf and ohms law to calculate expected current at near optimal drive angle, and given the way things are happening in simpleFOC specifically, assuming the drive angle is optimal is ok I guess.

If you supply the motor KV value to the constructor, we also take estimated BEMF into account.

If you supply the phase inductance, we also do lag compensation.

Yes, and this is what happens if you have current sensing, but the OP was asking about the situation when you donâ€™t have current sensing, and hence are working with the estimated current or voltageâ€¦

But youâ€™re quite right that ideally the actual current should factor into it. Its just that this complicates things quite a bit, and isnâ€™t really needed in practice for many small motor applicationsâ€¦