Electronic – spwm look up table {For bldc control}

brushless-dc-motormicrocontrollermotor controllerpwm

I am trying to implement sinusoidal control in BLDC motor. After doing some research about sine wave controller. spwm and svpwm are the better controlling methods for sine wave controller.

  • So I first wanted to try with spwm method.
  • I have designed inverter bridge circuit which was working fine with 6 step commutation.
  • Now I have to work more on algorithm side for generating spwm with 120 phase shift.

I have used this LUT for SPWM…,

unsigned char sin_LUT[256]={0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,89,92,95,98,101,104,106,109,112,115,117,120,123,125,128,131,133,136,138,141,143,146,148,151,153,156,158,160,163,165,167,170,172,174,176,178,181,183,185,187,189,191,193,195,197,198,200,202,204,206,207,209,211,212,214,215,217,219,220,221,223,224,225,227,228,229,230,232,233,234,235,236,237,238,239,240,240,241,242,243,243,244,245,245,246,246,247,247,248,248,248,249,249,249,249,249,249,249,250,249,249,249,249,249,249,249,248,248,248,247,247,246,246,245,245,244,243,243,242,241,240,240,239,238,237,236,235,234,233,232,230,229,228,227,225,224,223,221,220,219,217,215,214,212,211,209,207,206,204,202,200,198,197,195,193,191,189,187,185,183,181,178,176,174,172,170,167,165,163,160,158,156,153,151,148,146,143,141,138,136,133,131,128,125,123,120,117,115,112,109,106,104,101,98,95,92,89,87,84,81,78,75,72,69,66,63,60,57,54,51,48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3};

Now I get a good spwm with the above one.

  • since this is my first try in spwm technique in BLDC.
  • I am little confused how to use this, inverter consist of 6 FETs/3 legs spwm will be generated for only 3 high side FETs and that will be complemented for low side one.
  • For phase shift, i started the second spwm with 170th value. Because of 120 phase shift.

= 120 / 180 = 0.666

=0.666 * 256 = 170.6 value

  • Now I am confused how to activate the 3-spwm signal accordingly with hall sensor position. How do I send signal depends on the position. I knew that something I want to do with speed.

Could any clearly explain me regarding spwm signal generation accordingly with hall sensor? And I also don't know to whether to use spwm for 180 or 360 degree for high side FET, if so then how to use the LUT.

Guide me guys where I am wrong.

EDITED

  • what is correct formula or technique for generating 3 phase sine pwm.
  • Because in sine look up table {for 256} start from (+127)—(0)—-(-127) and some from 0 to 255.
  • which is the correct one for 3 phase sine LUT.

  • The below one is from saddle waveform(3rd harmonic rejection) which contains 1/3rd period to zero (reduces noise and ripples)

static unsigned char SinusoidalWaveTable[384]={
127,131,135,138,142,145,149,152,155,159,162,165,168,171,174,177,180,183,186,189,192,194,197,200,
202,205,207,210, 212,214,217,219,221,223,225,227,229,231,232,234,236,237,239,240,242,243,244,245,
247,248,249,250,250,251,252,253,253,254,254,255,255,255,255,255,255,255,255,255,255,255,254,254,
253,253,252,252,251,250,249,248,247,246,245,244,242,241,240,238,237,235,233,232,230,228,226,224,
222,222,225,226,228,230,232,234,235,237,238,240,241,243,244,245,246,247,248,249,250,251,252,252,
253,254,254,254,255,255,255,255,255,255,255,255,255,255,254,254,254,253,252,252,251,250,249,248, 
247,246,245,244,243,241,240,238,237,235,234,232,230,228,227,225,223,220,218,216,214,212,209,207,
204,202,199,197,194,191,188,185,183,180,177,174,171,167,164,161,158,154,151,148,144,141,137,134,
130,127,123,119,116,112,108,104,101, 97, 93, 89, 85, 81, 77, 73, 69, 65, 61, 57, 53, 49, 45, 41,
36, 32, 28, 24, 20, 16, 12, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 10, 15, 19, 23, 27, 31,
35, 39, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 99,103,107,111,115,118,121,124 
}
  • Could any one give a simple sin table for 3 phase with explanation?

Edited 2
spwm for 360 degree…

= 127.5 + 127.5 * sin( 2 * 3.14 * i / 360 ) 0 < i < 360

By using the above one i get the good spwm. I will store that in one array (say sin_lut[360]). Then i will start the second wave when i reaches i=120 and third one as i=240.By using single array.

  • I am getting the 3 sine wave with 120 degree shifted waves.
  • [PLL] Now i want to control the bldc motor by synchronizing phase sine(feedback) with hall sensor position.
  • Need to learn phase locked loop

Guys do i in a right direction??? Or i want to change something.

Best Answer

I'd start based on Fig. 6 in this paper.

You'd simply calculate a speed estimate from the hall effect readings. That gives you how fast you'll be stepping through your LUT.
Hint: this becomes a lot easier if you use a reasonably large LUT – I think you're using an STM32F103? You've got plenty of flash and at least 20 kB of RAM - your LUT can be much larger, so that you get a better sine with less ad hoc calculations. Also you really don't need to store a symmetrical piece of sine – ΒΌ of a period is sufficient (the rest's just mirrored and/or sign-inverted).

In the end, you could implement that as PLL – your hall effect sensors give you a phase, and you'd subtract the phase that your current reading point in your LUT corresponds to, and low pass filter that error, and then subtract the error from how you increase the pointer into your LUT.