Electronic – BLDC motor waveforms

atmegabrushless-dc-motordriverpwmwaveform

I'm trying to drive a brushless motor (BLDC) with an ATMEGA328p
I use Timer0/1/2 to generate 3 different PWMs @ 62Khz.
First I tried (only absolute values)

$$A = \sin(T)$$

$$B = \sin\left(T + \frac{2\pi}{3}\right)$$

$$C = \sin\left(T + \frac{4\pi}{3}\right)$$

But the angular speed was "pulsing" so I tried to generate 3 triangular signals
$$\text{space by} \frac{2\pi}{3} \text{ also,}$$
but it's still "pulsing".

Any idea how can I achieve it?

I'd like to be able to control position/speed, but for the moment I'm just trying to make it rotate constantly.

Code : http://pastebin.com/yAfqzVSu

Video : https://youtu.be/ksYnc2J_IFU

BLDC has 12 poles, the PWM has a 62Khz frequency, but the values are updated @ ~20hz

Best Answer

BLDC motors are normally driven in a '6 step' square wave sequence. This must be applied in synchronization with the rotor position, or it won't spin.

If you use Hall sensors to control switching then the motor should automatically run at synchronous speed (if the Hall sensors are correctly oriented) but a sensorless motor has be to run 'open loop' until it it picks up enough speed to detect back-emf from the unpowered winding. It will only stay in lock if the speed is increased very slowly, and even then it may jerk back and forth a few times until the rotor aligns with the rotating magnetic field.

At low speed the back-emf is very low and only the resistance and inductance of the windings limits current draw. Start up should be accompanied by a low PWM ratio, to keep the phase current down.

PWM is usually only applied to the low-side (or sometimes high-side) switches, while the other side is switched fully on and off in 6 step sequence. The diagram below shows typical timing of the drive waveforms sent to the switching devices (eg. MOSFETs).

enter image description here

When the motor is synchronized the voltage waveform across each phase should be a trapezoid shape, as the voltage slopes up and down between activation of each switch. Therefore you don't need to modulate the PWM in a sine wave. In the scope trace below you can see how the 6 steps combine to produce a trapezoid waveform across the phase terminals which is close to a sine wave, even though each individual motor terminal can only go up, down, or open circuit.

enter image description here

I tried running a brushless CDROM motor with open loop sine wave PWM at very low frequency and PWM ratio. It worked, but was not smooth. Magnetic attraction between the stator and rotor caused a large amount of cogging, which the sine wave drive was too weak to overcome. At higher rpm the movement became smoother due to rotor inertia, but if the speed was ramped up too fast or if any load was applied it would loose sync and stop.