I have hall sensor and incremental encoder. I don’t want to use index signal as my system doesn’t allow me to move motor in start to find rotor angle. I know sensor offset and natural direction. All i want to find is index, i do that using hall sensor. Now the problem is i want to find or estimate angle in start position such that foc starts working and i will correct/ fine tune angle in one electrical cycle using hall sensor. I just wanna ask how do i estimate angle on start up using hall sensor, i tried it but motor just moves a bit and stops / locks in certain position.
Both encoders and hall sensors are not absolute from startup.
Encoders can be made absolute by index search.
To use a pre-calibrated value for electrical zero it has to reference an absolute coordinate frame that is the same from one reboot to the next.
For encoders this can be achieved by index search, for hall sensors we currently have no method to make them absolute.
To do what you want you’ll have to run the motor in open loop mode and record the electrical zeros with reference to the encoder or hall sensor value, then you can do the calibration while running the motor open loop, and switch to FOC mode once you have found the zero. But this will only work if the motor is only lightly loaded, and there is no forces to interfere with the open loop commutation.
So, if index search isn’t done and i pass an estimated electrical angle, will the output Ud, Uq, will be some non zero value? or it won’t work at all?
I’m not sure what you mean…
Uq and Ud are the inputs for the FOC, not the outputs.
Uq is the output of the higher level control layers like velocity control…
So you can choose values of Uq and Ud to pass to setPhaseVoltage, but if you don’t have the correct angle, then your Uq will be applied in a random direction - could be close to the 90deg you need, or could be off by 180deg… how to know?
How will you get the “estimate” for the angle? If you can estimate it correctly, then of course it will work well… but if you estimate wrong, the motor could turn in the opposite direction to what you intended…
You could use one hall sensor transition to identify offset angle, but I don’t think that’s currently supported. It could be pretty easy to add, though.
@runger @Copper280z
I figured it out and now i don’t have to go through start up sequence. Motor is foc ready on startup. I did that using hall sensor and estimated electrical angle on startup. In worst case i lose around 14-20% torque because hall sensors have tolerance of ±30degrees but that’s okay, its just for one electrical cycle. If someone want to implement it, i’d be happy to share the source.
Hey, that’s great that you got it working, I think that’s not such an easy problem to solve.
If you feel like sharing some code or a GitHub link here in the forum I’m sure it would be helpful to people searching for this topic in the future…
I surely will.
I was a bit confused when you said FOC works with absolute angle and not electrical angle, Well in my opinion electrical angle is in fact an absolute angle. So it should work and then it did. It was a matter of estimating angle. This is what i like in being part of community, you discuss and debate and find new things.
The electrical angle is repeated for each pole pair, so it’s only absolute if you have a 1 pole pair motor. Otherwise, the electrical angle is repeated a few multiples of the physical angle for one rotation.
That’s relation between electrical and mechanical angle, but electrical angle also have a reference when its reset to zero and its same in one mechanical cycle.
Idk how simple foc does it but my electrical angle repeats its self after " 2PIPOLEPAIR ".
So for a 4pp machine my electrical angle is “0° - 1440°”.
It’s confusing, for sure
To do FOC, you need to know only the absolute electrical angle - if you don’t care about the relationship to the real world or real world rotational speed then in fact the pole pairs do not matter and you could control any BLDC as if it has 1 PP.
But you do need to know the absolute electrical angle with respect to your sensor value - I.e. the location of the electrical zero in sensor coordinates. Otherwise you can’t set the correct current vector.
But SimpleFOC does not work this way. SimpleFOC assumes that you want to do velocity and angle control using real world coordinates in radians and radians/s
So you additionally have to provide the number of pole pairs as a parameter to convert between electrical and rotor coordinates.
On top of this, you can also work in absolute real world coordinates - by having a fixed rotor zero point with respect to the stator. This is automatic for some sensors like magnetic sensors, and can be achieved by search for other sensors like encoders with index pins. And for yet other sensors like Hall Sensors, they are always relative and you can’t make them absolute.
Even so this has its limits, for example we can’t track full rotations while the sensors are off, and we can’t distinguish whether a given startup position was reached by way of clockwise or anti-clockwise rotation…