0
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ What are the specifications of your motor (rpm/V, resistance per phase etc.), and what voltage are you running it on? What do you mean by 'high currents'? \$\endgroup\$ – Bruce Abbott Nov 14 '16 at 20:43
  • \$\begingroup\$ Also, your second question ("What is the meaning of using the controller output for choosing the sin(.) index?") is unclear. Consider rephrasing it. \$\endgroup\$ – Sagie Nov 14 '16 at 21:04
  • \$\begingroup\$ @BruceAbbott there is not a detailed datasheet of the BLDC. The inverter bridge is supplied by 12 V and by "high currents" I mean values such as 0.8/0.9 A. \$\endgroup\$ – starScream Nov 14 '16 at 21:42
  • \$\begingroup\$ @Sagie my question refers to the relation there is between the P controller output (Pout) and the index of the sinTable array. \$\endgroup\$ – starScream Nov 14 '16 at 21:43
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your answer, may I ask one more thing about such a solution: What is the parameter I should control in order to vary the speed of the motor for getting the setpoint faster? \$\endgroup\$ – starScream Nov 15 '16 at 15:10
  • \$\begingroup\$ Motor speed is determined by the applied AC voltage. This is set via the variable 'power' in functions SetRollMotor(), SetPitchMotor(), SetYawMotor(). The power settings are extracted from ConfigData[6,7,8]. The power of each gimbal is set In EwGC GUI numberboxes 'Pitch Power', 'Roll Power' and 'Yaw Power', apparently as a number from 0-100 representing 0 to 100% power (I say 'apparently' because EwGC_GUI is unresponsive for me and I can't find any user documentation for it). \$\endgroup\$ – Bruce Abbott Nov 15 '16 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.