What is implemented so far is:
- Hall sensor angle measurement with a resolution of 2048 steps per revolution. There is some noise in the range of +-1LSB in the readout. I have not tested the actual angular error which might be caused by nonlinearities of the Hall elements. This is ongoing work. Angular position is measured and calculated with a frequency of max. 2.5 kHz.
The motor position consists of a signed integer variable (32 Bit) which reflects the measured Hall-sensor readout and the number of full motor turns. - SVPWM is fully implemented and allows PWM setting with a resolution of approximately 5000 steps at the maximum possible freuqency of 10 kHz. The SVPWM controls all 6 switche individually and allows to adjust a "guard time" to prevent shoot-through conditions in 10 ns steps. Thus very fast and efficient high-to-low transitions can be realized.
Shoot-through conditions are checked with double the PWM frequency, and are immediately handled by switching off all switches and halting the system. So far they have only occured during intentional experiments. - Self calibration of the Hall-sensor and the brushless motor has been implemented. This means that there is a "learning programm" (for which the motor has to be able to spin freely without load) that determines the motor parameters like number of poles and field-vector to Hall-sensor alignment. Once the learning phase is accomplished, the parameters are stored in the processors flash memory and are always available after power up. The program is designed to also cope with very low-quality and cheap brushless motors which originally have not been designed for positioning purposes but for power drive.
- Vector current setting which controls field strength and angular field orientation is implemented as two PI-type regulators - one for the torque-component of the current and one for the magnetization-component of the current. This involves some mathematical transformations and is a commonly used technique in field-oriented motor control (FOC).
The parameters of the PI regulators can be adjusted on-the-fly. - Positioning of the motor is implemented as a PID-type regulator. Depending on the Motor's load situation, the PID regulator gains can be adjusted and tested. The position regulator currently executes every four current regulator cycles for better stability.
Latest experiments have shown that the unloaded motor (Plante Hobby, J3542-5, ~25 €) completes a 180° set value jump in just about 20 ms (standstill to standstill time with a few percent of overshoot). - The motor currents to achieve this kind of dynamics are quite violent. In the graph below the motor position response can be seen for adjusting the position set value from 90° to -90° starting at 20 ms. 20 ms after the new setting the motor position crosses the target with a light overshoot and levels out quite quickly. Peak values of up to 100 A are present in the deceleration phase. My initial fear that the motor control will only handle up to 25 A have been dispelled the moment I used a more proper power supply :) .
In the lower graph the set-value Ts of the motor current's torque component is shown (red). This level is the result of the PID position regulator and is updated every four cycles. The green curve (Tr) is the output of the motor current regulator and is closely linked to the PWM on/off ratio (it is thus not a current). The blue curve is the actual torque component T which relates to the part of the motor current which is responsible for accelerating and decelerating.
Keep in mind that this is merely an amplitude of this part of the motor current. In fact there is also a small magnetization current present in the motor that does not cause torque. The sum of current magnitudes in the three motor wires will thus be generally higher than the values shown in the graph. Also, the field of the stator has to be kept in sync with the spinning rotor, by carefully balancing the actual currents in the three motor wires over time. This can not be seen in the graphs, but is a product of the two PI current regulators and a set of mathematical transformations. In my next post I will try to link to some literature which I found useful to design my motor control algorithm. - So far I am quite happy with the results. I also have implemented an input for standard remote controls to use the device as a motor regulator. The RC input can be used to set the motor torque, which works perfectly, and also at very very low speeds. There will also be a second mode that positiones the motor according to the RC input which allows to use the BL-Motor as a very sophisticated servo that positiones itself also over a range of multiple turns. Think about reeling in sails on your model sailboat or things like that.