## Rotor Commutation Using Encoder

7 posts / 0 new
Author
Message

Hi guys,
I am trying to commutate BLDC motor using encoder and one revulation is 1024 encoder value.And motor 10 pole pairs,in this case 18 encoder value(60 electrical degree) equals 6 mechanical degree so that when the rotor reached the 18 alteration I have to perform next stage.

For example now rotor in 0. position and rotate encoder 13 value and then rotate CCW -10(1024-13-10= 1001) I can't decice how can I find the right sequence.I can't find a good solution algorithm for it?How people do it right?

```encoderValue = Get_Encoder_Pos();

if(((encoderValue - xEncoderValue) >= 18) && dir==1)
{
Set_Commutation_and_DutyCycle(table[x],PWM);
}
//This doesn't work,If motor rotate CCW from 0 to in this case enc value will increase 1024-1023 .... like that.
```

Use a table to map the encoder value. In solving for the table, you might observe some patterns hat might lead to some optimisation.

you mean like
for example 0,1,2, for encoder values ,table[0],table[1],table[2] represent like A and C phase to open mosfets.Okay,I am gonna try it.

Encoder resulotion 1024

Poles 20

60 electrical degree equals 8.53 encoder values and table like below and having error because of 0.53

I can't test the program for a few day,but I think it doesn't work well wtih this encoder.Am I right.How result should I expect by motor moving?

6 number is 19 times,It has to be 20 times because of poles number.1,2,3,4,5,6 represent six-commutation step.

8.533334
9
->0
11111111->9
22222222->18
33333333->27
44444444->36
55555555->45
66666666->54
11111111->63
22222222->72
33333333->81
44444444->90
55555555->99
66666666->108
11111111->117
22222222->126
33333333->135
44444444->144
55555555->153
66666666->162
11111111->171
22222222->180
33333333->189
44444444->198
55555555->207
66666666->216
11111111->225
22222222->234
33333333->243
44444444->252
55555555->261
66666666->270
11111111->279
22222222->288
33333333->297
44444444->306
55555555->315
66666666->324
11111111->333
22222222->342
33333333->351
44444444->360
55555555->369
66666666->378
11111111->387
22222222->396
33333333->405
44444444->414
55555555->423
66666666->432
11111111->441
22222222->450
33333333->459
44444444->468
55555555->477
66666666->486
11111111->495
22222222->504
33333333->513
44444444->522
55555555->531
66666666->540
11111111->549
22222222->558
33333333->567
44444444->576
55555555->585
66666666->594
11111111->603
22222222->612
33333333->621
44444444->630
55555555->639
66666666->648
11111111->657
22222222->666
33333333->675
44444444->684
55555555->693
66666666->702
11111111->711
22222222->720
33333333->729
44444444->738
55555555->747
66666666->756
11111111->765
22222222->774
33333333->783
44444444->792
55555555->801
66666666->810
11111111->819
22222222->828
33333333->837
44444444->846
55555555->855
66666666->864
11111111->873
22222222->882
33333333->891
44444444->900
55555555->909
66666666->918
11111111->927
22222222->936
33333333->945
44444444->954
55555555->963
66666666->972
11111111->981
22222222->990
33333333->999
44444444->1008
55555555->1017
666666

Last Edited: Wed. Oct 9, 2019 - 01:51 PM

If you were using 3 hall sensors in a typical BLDC setup, you get a rather coarse angle resolution & it still works fine...so now you have much better possibilities with an encoder...just divide into zones corresponding to where you might have used hall sensors instead.  Once issue is that your encoder (or other signal) needs to know where zero/home is.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

AVRcandies is right about the motor index.   Unless it's an absolute encoder, you will need to find the 'zero' point every time you turn the system on.

You might be interested in something called an 'Odrive' - It's an open-source solution to the problem, and even comes with hardware!

https://odriverobotics.com/

S.