Mittwoch, 9. Oktober 2013

Major software release finished

Long programming nights have passed, but finally my closed loop BLDC motor control software has reached a status worth talking about.

What is implemented so far is:
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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).
  6. 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.
  7. 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.

Dienstag, 14. Mai 2013

Protoype realization and first tests

A first prototype has been assembled and the testing phase has ended successfully.

The tests have been performed with a cheap brushless motor available for model plane pilots in RC-shops. A magnet was attached to the rear part of the motor shaft for position measurment with the Hall-sensor. The test setup looks like this:


Along with testing, basic functionality has been implemented in software. The following features are available and some performance parameters have been determined:
  • Angular resolution of the Hall sensor is 2048 steps per revolution with ± 1 LSB accuracy. This gives an angle readout with accuracy of ± 0.17°. At the moment, the calculation of the angle from the analog voltages of the Hall sensor which are converted with 10 bit ADCs uses up the most CPU power.
  • 10 bit ADCs are used for current measurement on all three phases. Positive and negative currents currents can be measured in the range of ± 45 A at each phase. The resolution is approximately 100 mA.
  • The circuit board has been manufactured from 0.5 mm thick glass-fiber reinforced substrate. The design was thermally optimized and allows laminating the board to solid metal with a thin isolation layer. One protoype has been laminated with a 3 mm thick aluminum sheet. In fact the thermal coupling is so good that soldering without pre-heating of the unit is impossible. The high current paths on the circuit board will be optimized in the next version. So far, however, the board handles a motor current of 30 A. Note that this means average of 60 A that pass through the board (what goes in one phase has to come out at the others). The limiting factor for the maximum current is a parasitic ringing effect. Thermally the board could take motor current well above 30 A.
  • An SVPWM (space vector pulse width modulation) has been implemented to take control of the three-phase motor voltage. The PWM-frequency is 10 kHz. At a motor current of 30 A and a supply voltage of 15 V, a heating of the unit by a few degrees has been observed. This confirmes that the switching of the FETs which are fed by 2 A gate drivers is very efficient. Transition times in the range of 40-60 ns have been measured for the FET pairs.
  • Basic implementation of a closed loop motion control using a simple P-regulator has been completed and the response of the motor motion has been recorded. The recording of current and position and SVPWM control voltage is also carried out in the microcontroller and can be read using the USB port connection. If the regulator is properly tuned the position regulation accuracy is in the range of the accuracy of the Hall sensor.

Sonntag, 24. Februar 2013

Concept and prototype

Since brushless motors have become a new standard in RC planes/copters/boats/cars, their price has dropped, and the user can choose among hundreds of different types optimized for whatever you need the most (speed, torque, power, ...).

In the past, I have equipped three mills with stepper motors, and made my own 3-axis 5A/winding motion control hardware (quite a nice piece, because it fits on a 100 x 80 mm board and requires nothing but a computer with a USB port and a potent power supply). Maybe I'll write a blog about it someday as well...

With the availablitiy of low-cost high-performance brushless motors, I decided to say goodbye to the stepper motor aera, and so I am now working on a closed loop brushless motor control. It should serve as a servo controller for my CNC machines, but with significantly improved dynamics in comparison with stepper motors. On my BF70 mill - for instance - I reach a maximum speed with stepper motors of about 3 mm/s. I intend to boost that to about 70 mm/s with the brushless motor control. Also I decided to make the hardware ready for advanced RC-users.

The (theoretic because yet untetsted) limits and specifications of the controller are:
  • 100 A peak motor current
  • 40 V DC supply (maximum of 100 V if different FETs are used)
  • SVPWM (Space-Vector-Pulse-Width-Modulation) of up to 100 kHz with 16 bits resolution
  • 10-bit current sensing at each driver (also of negative currents that will be conducted by the freewheeling diodes)
  • Hall-type angle sensing with (hopefully) 10 bit resolution (per turn)
  • End-/reference-switch(es) support
  • IIC bus for additional sensing/IO/control
  • SPI as a main control bus
  • USB (virtual COM-port) for secondary control, parameter setting, and debugging (on a separable doughter board)
The V1.0 PCBs are currently in production and have a size of 54 x 43 mm. Use of aluminum backed multi-layer PCB technology, which is necessarry for thermal reasons, is on the roadmap for V2.0.

Here is a snapshot of the layout. I do not plan to give out the layout or the schematics for free, so please do not ask unless you have a business model in mind.



Features I have implemented or plan to implement in software:
  • Motor current regulation
  • Closed-loop motion control - and yes, I mean by that positioning with an accuracy below 1°
  • Regulation algorithms starting with straightforward PID control
  • Self learning of the motor and drive train (number of poles, inductance, current, momentum of inertia, friction, ...)
  • Self configuring of the parameters of the motion controller
  • Motion trajectory generation (ramp-up/-down, ...)
  • RC-type interface (pulse-width) for speed control (drive train)
  • RC-type interface for positioning (using the BLDC-Motor as a servo