Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Sinusoidal Control of BLDC motor

Status
Not open for further replies.
I am really looking for some support on this application note AN1017A by microchip for sinusoidal control of BLDC motors. I have attached the application note i have progressed little bit but need more support. There are two source codes provided for two micros one for dspic30f4011 and another for dspic33E family. If i compare the implementations of both they are differing in some critical sections. Can someone please tell me why is it so?
There is a PhaseInc value which has to be changed in one project it is something like this
Code:
if (Current_Direction == CW)
           Phase-= PhaseInc;
In another it is
Code:
       if (Current_Direction == CW)
           Phase += PhaseInc;

I have some other doubts but i want to first get over this.
 

Attachments

  • sinusoidal_bldc.pdf
    313.9 KB · Views: 327
  • AN1017_30F3010_V1.zip
    77.5 KB · Views: 295
  • AN1017_dsPIC33EP256MC506_MCHV2_MOTOR80.zip
    675.1 KB · Views: 254
I honestly wouldn't worry about that difference. CW and CCW are just arbitrary labels indicating direction. They could have just as easily named them "forward" and "reverse".

But if I had to guess, I believe it is a typo in the 30F version that was later caught and corrected in the 33F version. Notice that the comments are the same in both the 30F and 33F version, but in the code is doing the opposite of what the comment says in the 30F version, while in the 33F version the comment and code line up.

Both projects also use different dev boards so the wiring to the motor could be different. It only takes swapping any two of the three wires on a BLDC to reverse it's direction. So it could be that.
 
Last edited:
Thank you very much for the reply. My other major doubt is
Code:
// In the sinewave generation algorithm we need an offset to be added to the
// pointer when energizing the motor in CCW. This is done to compensate an
// asymetry of the sinewave
int PhaseOffset = 4100;  /* 22.5 degrees */

I don't understand the Phaseoffset it is different in CW rotation and CCW. What exactly is this? As per the code it is done to compensate asymmetry of sine wave. What is asymmetry? In my project which value shall i choose? Please help. If any detailed explanation is there it will be really useful.
 
It's because of a flaw in the the sine-wave lookup table, or whatever math function they use to calculate their sine wave:
Code:
  Note 2:          For Phase adjustment in CCW, an offset is added to
                   compensate non-symetries in the sine table used.

Because the sine-wave is being approximated with lookup table, there is a discrete number of values. Those values must not be spaced evenly around the max peaks, zeroes, and min peaks of the sine wave. To see what it really is, you are going to have to dog into "sinetable" to see how they calculate their sinewave and graph it out. But if you do, it should be very obvious. You could modify the code and get it to calculate the sine wave in the same way they are doing it and spit it out over a USB-UART serial connection to your PC if you are really curious. Or just have it generate the sine-wave open loop without the offsets and view it on the oscilloscope.

If you were able to use a symmetrical sine-wave lookup table, you would not need to do this. And to be honest, you could probably get rid of that offset and it would still run. It would just not run equally well in both directions. I would ignore this little detail if you're starting out and just trying to get everything to work. This is more of an optimization.
 
Last edited:
This is the lookup table they build their entire sine-wave on:
Code:
SVM.c
// This sinewave lookup table has 171 entries.  (1024 points per
// electrical cycle -- 1024*(60/360) = 171)
// The table covers 60 degrees of the sine function.

int __attribute__((near)) sinetable[172] =
{0,201,401,602,803,1003,1204,1404,1605,1805,
2005,2206,2406,2606,2806,3006,3205,3405,3605,3804,
4003,4202,4401,4600,4799,4997,5195,5393,5591,5789,
5986,6183,6380,6577,6773,6970,7166,7361,7557,7752,
7947,8141,8335,8529,8723,8916,9109,9302,9494,9686,
9877,10068,10259,10449,10639,10829,11018,11207,11395,11583,
11771,11958,12144,12331,12516,12701,12886,13070,13254,13437,
13620,13802,13984,14165,14346,14526,14706,14885,15063,15241,
15419,15595,15772,15947,16122,16297,16470,16643,16816,16988,
17159,17330,17500,17669,17838,18006,18173,18340,18506,18671,
18835,18999,19162,19325,19487,19647,19808,19967,20126,20284,
20441,20598,20753,20908,21062,21216,21368,21520,21671,21821,
21970,22119,22266,22413,22559,22704,22848,22992,23134,23276,
23417,23557,23696,23834,23971,24107,24243,24377,24511,24644,
24776,24906,25036,25165,25293,25420,25547,25672,25796,25919,
26042,26163,26283,26403,26521,26638,26755,26870,26984,27098,
27210,27321,27431,27541,27649,27756,27862,27967,28071,28174,
28276,28377};

Graph it out. I bet you the graph will look a little bit distorted because some of the the maximums, minimums, and zeroes aren't missing because they don't fall perfectly onto one of the the 172 points on the x-axis.)

A little extra work may be required since the lookup table only covers 60 degrees, and they use some extra trig to get 60-90 degrees and the rest of the sine-wave. The distortion might also come from that approximation they are doing to get the full-sine wave out of just 60 degrees worth of lookup values.
 
Last edited:
Thank you very much for the support. Give me some time i will share the source code i have developed and the results i got. I can see the motor running but finding some issues. I will share all those details. Request your support.
 
This is the source code i have developed. The code settings are as follows i tried to follow the sample code
70MIPS,
Number of poles: 16
Open loop speed control i have set the control output at 30000.
I have set phase_zero to 45000
#define PHASE_OFFSET_CW 10000. I am not sure about this.
The hall Sensors are analog and given to comparator which is converted to digital internally. Can you please review the code. Motor runs but does not produce any torque.
 

Attachments

  • Sinusoidal_V1.0_70Mhz_5Mayl18.X.zip
    193.3 KB · Views: 252
Are you referring to phase advance. Currently i am not doing that. But normally sinusoidal control i thought will produce maximum torque as rotor field is at 90 degrees to stator field. Only for speed improvement we need phase advance. Please correct me.
 
This is one of the results.
 

Attachments

  • IMG-20180505-WA0014.jpg
    IMG-20180505-WA0014.jpg
    109.8 KB · Views: 265
I'm afraid at this point you've done more practical work on this than I have so I can only brainstorm rather than offering any definitive answers:

1. I'm assuming you have run the motor with a normal controller so you know how much torque is possible, and the motor just doesn't have "no torque" because it is weaker than you guessed it would be.

2. I remember the example project mentioned about dealing with the latency involved in the hall sensors. Did you do anything like that?

3. What is the blue and red waveform in your scope photo?
 
The blue and red photos are the filtered line voltages. I expected them to be sinusoidal.
Is there a the filtering circuit between the driver and motor? What is the frequency of the "sinusoid" and what frequency is the PWM? Could you post a scope of your PWM waveform (the gate drive voltage) on top of the line voltage?

Did you build the entire circuit yourself or are you using a development board?
 
I have my own board. The filtering circuit was just added to see on the scope. The pwm frequency is 20khz. I did not measure the sine wave frequency. Do you think sine wave should be of particular frequency?
 

Attachments

  • 1525533458175_IMG-20180505-WA0008.jpg
    1525533458175_IMG-20180505-WA0008.jpg
    135.1 KB · Views: 259
I have my own board. The filtering circuit was just added to see on the scope. The pwm frequency is 20khz. I did not measure the sine wave frequency. Do you think sine wave should be of particular frequency?

The sine-wave frequency will be decided by the rotation speed of the motor from the hall sensors. You don't get to pick the sine frequency without also changing the RPM. You need the PWM frequency to be higher than the rotational frequency by enough so that you can filter out all the square harmonics to get an approximate sine-wave (although I think the motor inductance can do that on its own in some cases as well).

Is blue your PWM gate drive signal? Zoom it on and it and look the duty cycle closely. From a distance, to me, it looks like your line voltages are doing what is expected of your gate drive voltage. But your gate drive voltage doesn't look like the duty cycle is varying sinusoidally which would explain the strange waveform. It should kind of look like this:

**broken link removed**

If you built your own board, make sure your gate drive is sufficient to turn your MOSFETs on and off fast enough.
 
Last edited:
Yes i am also concerned about the duty cycle not varying sinusoidally. But in the application note fig 15. If you see the duty cycle it does not vary sinusoidally. Can you please confirm it. It is space vector modulation as per the paper.
 
Oh, I see what you're trying to do. Unfortunately, I never knew such a method existed until now so I can't really help you on it!

But with regards to figure 15, that's not showing the duty cycle of the gate-voltage. It's showing the line voltage produced by each PWM signal. Maybe you mean figure 14?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top