The alignment lasts approx 700mS. I do not know what is the Iq to Vout ratio of the DAC. But I measured a peak of 0.5V (2.15V - 1.65V).
I have configured it for 1A.
I have two issues with this picture: (For the next photos, it would be nice to include the timebase and all vertical settings. Guessing 100ms timebase here, right?)
- is that really Iq? It doesn't look like it should. I would have expected a constant 1A value for that 700ms (or a linear ramp)
- the encoder seems to misbehave beginning with horizontal division 9. There seems to be some high frequency 'overlay', if we can assume that the motor is slowly accelerating.
Iq voltage conversion should be 0V <--> -max measurable current, 3.3V <--> +max measurable current. STMCWB calculates max readable current of +-3.268A (power stage, current sensing). So +1A would be 1.65V + 1.65V*(1.0A / 3.268A) = 2.15V. It seems like the current controller is reaching that level for a short time, when looking closely at the beginning (~ div 1).
It looks to me that the current PI control loop is oscillating. I suggest working on the motor current before looking at encoder feedback. You can use/repeat the alignment procedure to investigate that.
Also put the rotor angle on the screen (measured electrical angle). Turn the motor manually a few turns, is the display consistent (the displayed angle value must be the same every time the shaft repeats a certain orientation)? I suspect that there is still a mismatch between encoder angle measurement and actual angle.
I took a picture of the oscilloscope.
I had to put the controller at zero speed to be able to rotate the rotor manually.
The DAC outputs (in this version) only come into operation after make "start motor.
looks okay. But the objective here is: does the encoder count correctly? If you paint a reference mark on the shaft, and turn it a random number of complete revolutions (fast or slow), and then carefully align to the painted reference mark again, then the shown voltage (or value, if you do it directly in STMCWB) for "measured electrical angle" *must* be identical all the time. Have you checked that? *And* you must see exactly *one* triangle sweep per mechanical revolution. It is not allowed to "lose" one single tick count now and then, because that will put everything out of sync over time.
From the first scope picture, I am concerned that the encoder output may be corrupted. (Magnetic interference? wrong field strength of permanent magnet?)