Electrical – Sinusoidal PWM running BLDC motor in open loop

arduinobrushless-dc-motormotorpid controller

I have started to wokr on the stabilization of a single axes gimbal using an Arduino and a BLDC sensorless motor.

I've read many example about this topic, but I have a question about the usage of the sinusoidal PWM applied to the inverter bridge which drives the BLDC motor.

For instance, consider the generation of the sinusoidal PWM as follows

sineSize = 1024;
sineScale = 32767;

int sinTable[1024];

for (int i = 0; i < sineSize ; i++)
{
    float x = i * (2*pi)/1024;
    sinTable[i] =  round(sin(x) * 32767);
}

I am using a simple (and dummy) P controller which gets the shaft orientation (roll angle) of the motor from an IMU as follows

setpoint = 0; // degrees

float error = setpoint + rollAngle;

Pout = Kp * error;

And I am calculating the values which should be applied to the PWM inputs of my inverter bridge (L6234 from ST) in order to stabilize the motor to the setpoint when the axis moves

// 180  : Maximum value which the IMU returns (+/- 180 angles)
// 1024 : Dimension of the sin(.) array
// 255  : Maximum value accepted from Arduino analogWrite(.,.)

int offset= round(Pout / 180 * 1024);

int pwm[3];

// Forcing offset into array range
offset = offset % 1024;

if (offset < 0)
    offset = 1024 + offset;

uint16_t pwr= 5 * power;

index = offset % 1024;

// Evaluating PWM value based on the sin(.) look up table values
pwm[0] = (sinTable[index]*pwr + (32767/2))/32767 + (255/2);

index = (offset + (1024/3)) % 1024;

// Evaluating PWM value based on the sin(.) look up table values
pwm[1] = (sinTable[index]*pwr + (32767/2))/32767 + (255/2);

index = (offset + ((2 * 1024) / 3)) % 1024;

// Evaluating PWM value based on the sin(.) look up table values
pwm[2] = (sinTable[index]*pwr + (32767/2))/32767 + (255/2);

The all the PWM are applied to the IN pins of my inverter bridge, in order to spin it.

There is a point I really don't understand, when pwr is high the BLDC motor takes currents like 0.8 A at 12 V. The BLDC motor used can be found here (http ://www.dys.hk/ProductShow.asp?ID=109), but there isn't a detailed datasheet.

(sinTable[index]*pwr + (32767/2))/32767 + (255/2)
  1. What does sinTable[index] * pwr mean, in terms of power?
  2. Could you explain the relation between the controller output and the index used in the sin(.) array? (I mean what is the logical relation between the Pout and the index used for choosing the discrete value of the PWM in the sinTable vector).

The code is base on a project which can be found on GitHub, namely EvvGC

Best Answer

What does sinTable[index] * pwr mean, in terms of power?

The AC motor voltage waveforms are created from DC using PWM. pwr scales the sine table values so that at full power the PWM ratio varies from 0% to 100%, which creates a sine wave that goes from 0V to 12V (when using a 12V power supply). If the value of pwr is reduced then the amplitude of the sine wave is reduced, so the motor gets less AC voltage and draws proportionally less current.

what is the logical relation between the Pout and the index used for choosing the discrete value of the PWM in the sinTable vector.

There is no relationship between the index and output power. The purpose of index is simply to create a time-varying sine wave of nominal amplitude (-1 to +1) which is then shifted and scaled to produce a range of PWM ratios that varies from 0-100% at full power.

There is a point I really don't understand, when pwr is high the BLDC motor takes currents like 0.8 A at 12 V.

This is to be expected. Your motor has an internal resistance of 5.5Ω per phase (11Ω between any two terminals). At 12V the voltage applied per phase is 12V peak-to-peak, which equals 4.24Vrms. Current = voltage / resistance so the rms current per phase is 4.24V / 5.5Ω = 0.77A, and power = voltage x current so each phase consumes 4.24V * 0.77A = 3.26W.

Since all 3 phases are powered similarly the total power consumption is 3.26W * 3 = 9.78W. Current = power / voltage, so the expected DC current draw from the power supply is 9.78W / 12VDC = 0.815A.