利用PDC定时器做BLDC电机的速度计算

发布于:2021-11-29 01:32:26

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC



机 诺 德 单
19, Innovation First Road Tel: 886-3-578-6005

*
BLDC
V1.0 – Dec 8, 2005



Science Park

Hsin-Chu Taiwan 300

Fax: 886-3-578-4418

E-mail: mcu@sunplus.com.cn

http://www.sunplusmcu.com

http://mcu.sunplus.com


R.O.C.



it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC










Sunplus Technology Co., Ltd. PAGE 1 V1.0 – Dec 8, 2005



*





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

2005/12/8

1.0










Sunplus Technology Co., Ltd. PAGE 2 V1.0 – Dec 8, 2005



*





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

1.1 1.2 PDC 1.3 PDC 1.3.1 1.3.2 1.4 1.5 2 2.1 2.2 2.3 DMC 2.4 3

.....................................................................................................2 ................................................................................................................2

.......................................................................................................4 .........................................................................................7

..................................................................................................................10 ............................................................................................................................ 11 ..................................................................................................................... 11 ..................................................................................................................... 11

..................................................................................................................12 ............................................................................................................................14

3.1 DEMO 3.2 3.3 3.4 4







.....................................................................................................................16

............................................................................................................................18



..................................................................................................................14 ...........................................................................................................16 .......................................................................................................16



.................................................................................................................... 11


PAGE 3

*

....................................................................................................................8

Sunplus Technology Co., Ltd.



...................................................................................................................4



1

BLDC

.................................................................................................................2

V1.0 – Dec 8, 2005

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

360

N S 360 180 p 360 p 360 p










Sunplus Technology Co., Ltd. PAGE 1 V1.0 – Dec 8, 2005



*





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

1 BLDC

SPMC75F2413A

PDC

*
0 1 PDC

1.2

PDC


PWM


0 PDC FCK/64 FCK/8 Yes
PAGE 2

PDC

0

1

PDC 1-1 PDC

1-1



PDC

IO



FCK/64

: FCK/1 FCK/4 FCK/16 FCK/256 FCK/1024 : TCLKA TCLKB

: FCK/1 FCK/4 FCK/16 FCK/256 FCK/1024 : TCLKA TCLKB



TIO0A, TIO0B, TIO0C P_TMR0_TGRA P_TMR0_TGRB P_TMR0_TGRC P_TMR0_TBRA P_TMR0_TBRB

TIO1A, TIO1B, TIO1C P_TMR1_TGRA P_TMR1_TGRB P_TMR1_TGRC P_TMR1_TBRA P_TMR1_TBRB P_TMR1_TBRC P_TMR1_TPR P_TMR1_TCNT : FCK/1 FCK/2 FCK/4



P_TMR0_TBRC P_TMR0_TPR P_TMR0_TCNT : FCK/1 FCK/2 FCK/4 FCK/8 P_TMR0_TGRA P_TMR0_TGRB P_TMR0_TGRC P_POS0_DectData P_TMR0_TPR Yes



P_TMR1_TGRA P_TMR1_TGRB P_TMR1_TGRC P_POS1_DectData P_TMR1_TPR

Sunplus Technology Co., Ltd.


1-1 1
V1.0 – Dec 8, 2005

1.1

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

PWM 1 0

Yes Yes Yes

Yes Yes Yes Yes Yes TCLKA/TCLKB Yes, Yes

PWM PWM

Yes Yes Yes, Yes

AD

P_TMR0_TGRA 0 TPR 0 TGRA 0 TGRB 0 TGRC 0 PDC 0 0


PAGE 3











*

P_TMR1_TGRA 1 TPR 1 TGRA 1 TGRB 1 TGRC 1 PDC 1 1

Sunplus Technology Co., Ltd.



TCLK C/TCLKD


V1.0 – Dec 8, 2005

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

FCK 16

TBR

TCNT

PWM

PDC



1.3

PDC

SPMC75F2413A


1-1 PDC PDC 0/1 P_TMRx_Ctrl(x = 0, 1) 0/1 / P_POSx_DectCtrl(x = 0, 1) 0/1 P_TMRx_INT(x = 0, 1) P_POSx_DectCtrl

0/1

P_TMRx_IOCtrl(x = 0, 1)





P_TMRx_Ctrl

1.3.1.1
B15 R/W 0 SPCK B14 R/W 0



1.3.1

P_TMRx_Ctrl(x = 0, 1)
B13 R/W 0 B12 R/W 0 MODE B11 R/W 0 B10 R/W 0 B9 R/W 0 CLEGS B8 R/W 0


Sunplus Technology Co., Ltd. PAGE 4 V1.0 – Dec 8, 2005

*





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

B7 R/W 0
15:14

B6 R/W 0 CCLS
SPCK

B5 R/W 0

B4 R/W 0 CKEGS

B3 R/W 0

B2 R/W 0

B1 R/W 0 TMRPS

B0 R/W 0

00 01 10 11 13:10 MODE 0000 0100 0101 0110 0111 1x0x 1x1x 9:8 CLEGS 00 01 10 11 7:5

FCK/1 FCK/2 FCK/4 FCK/8

1 2 3 4 PWM PWM ( (


PWM / TCNT TCNT TCNT TCNT
PAGE 5



CCLS 000 001 010 011 100 101 110 111





P_TMRx_TGRA (x = 0, 1) P_TMRx_TGRB (x = 0, 1) P_TMRx_TGRC (x = 0, 1) 6 3


TCNT P_TMRx_TPR (x = 0, 1) FCK/1

P_POSx_DectData (x = 0, 1) P_POSx_DectData (x = 0, 1) P_POSx_DectData (x = 0, 1) 1



*
) PWM ) 1 1 TCNT TCNT TCNT 1 TCNT
V1.0 – Dec 8, 2005

(

)

4:3

CKEGS

00 01
Sunplus Technology Co., Ltd.





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

1X 2:0 TMRPS TCNT

000 001 010 011 100 101 110 111

FCK /1 FCK /4 FCK /16 FCK /64 FCK /256 FCK /1024 TCLKA TCLKB

1.3.1.2
0/1

P_TMRx_Ctrl(x = 0, 1)

MODE MODE 0000 CCLS CCLS

机 片
100 101 110 TCNT TCNT BLDC 60 = = = = 0; 6; 0; 3;
PAGE 6


PDC PWM P_POSx_DectData(x = 0, 1) TCNT 360 TCNT TCNT P_POSx_DectData(x = 0, 1) BLDC P_POSx_DectData(x = 0, 1) TCNT BLDC CKEGS CKEGS





TMRPS TMRPS

P_TMR0_Ctrl->B.MODE P_TMR0_Ctrl->B.CCLS P_TMR0_Ctrl->B.CKEGS P_TMR0_Ctrl->B.TMRPS



180

// // P_POSx_DectData // // FCK/64

*
TCNT
V1.0 – Dec 8, 2005

Sunplus Technology Co., Ltd.





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

1.3.2

1.3.2.3
B15 R/W 0 SPLCK B14 RW 0

P_POSx_DectCtrl(x = 0, 1)
B13 R/W 0 B12 R/W 0 B11 R/W 0 B10 R/W 0 B9 B8

R/W 0

SPLMOD

SPLCNT

B7 R/W 0 PDEN
15:14

B6 R/W 0
SPLCK

B5 R/W 0

B4 R/W 0

B3 R/W 0

B2


B1 R/W 0
FCK/128 1 PWM

SPDLY

FCK/4, FCK/8, FCK/32,

00 01 10 11 13:12

FCK/4 FCK/8 FCK/32

FCK/128

SPLMOD




PWM UPWM/VPWM/WPWM (UN, VN, WN) 0 1 / TIOA~C POS_DectData PDR [2:0] PDR [2:0] SPLCK
PAGE 7 V1.0 – Dec 8, 2005

00





01 10 11

11:8

SPLCNT



7

PDEN

0 1 6:0 SPDLY

Sunplus Technology Co., Ltd.



(UN, VN, WN)

P_TMRx_OutputCtrl (x = 3, 4) PWM

N

1

15

*

R/W 0


R/W 0 B0 R/W 0

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

1.3.2.4 P_POSx_DectCtrl(x = 0, 1)
TCNT TGRA

SPLCK FCK/32 SPLCNT FCK/128 SPDLY

SPLMOD

PWM

SPLCNT PDEN SPDLY 0 /

0

15

0

TIOA~C

127

1.4



PDC






Fcap BLDC

P_POS0_DectCtrl->B.SPLCK = 2; P_POS0_DectCtrl->B.SPLMOD = 1; P_POS0_DectCtrl->B.SPLCNT = 10; P_POS0_DectCtrl->B.PDEN = 1 P_POS0_DectCtrl->B.SPDLY = 100;


// // // // //

*
1 FCK/32 10 p m m PDC
V1.0 – Dec 8, 2005

P_POSx_DectData(x = 0, 1) 1 3 6 Ncap



m* rad 3 m* 3
1

rad

d dt d m* 3 dt Ncap Fcap

1

Sunplus Technology Co., Ltd.

PAGE 8




SPLCK

FCK/4 FCK/8

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

p r/min n / n

p 2 n 60 n rad/min 30

rad/min

1

2

1

3 1 4

n

60 * Fcap * m 3 * 2 * Ncap * p
n p

10 * Fcap * m rpm Ncap * p
Fcap m

Ncap


4000rpm TCNT

Eg. PDC 1 60 1 m 1

p 2 DC311V Fcap m

P_POSx_DectData(x = 0, 1) TCNT 4

*
n
FCK/64 1875K 28.6 1 Fcap


1

n

min

Ncap



n

max

Ncap 0xffff

min

1-2

Fcap

FCK/1 120M 1831



1-2 FCK/16 7.5M 114.4 FCK/256 468750 7.2 FCK/1024 117187.5 1.8

FCK/4

max min

rpm



n n

rpm

30M

457.8



2

m 3

P_POSx_DectData(x = 0, 1) TCNT 1 4 m=3

TCNT

180



m 3

1

3 m 6 P_POSx_DectData(x = 0, 1) TCNT 1 4 m=6 TCNT BLDC

360

m

1

6 m

Fcap

FCK/16

Fcap FCK/64

Fcap FCK/256
PAGE 9

FCK/1024
V1.0 – Dec 8, 2005

Sunplus Technology Co., Ltd.


p BLDC BLDC

n

max

Fcap

BLDC

200rpm

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

200rpm

Fcap FCK/16

1.5
PDC SPDLY BLDC SPLCNT SPLCNT SPLCK
SPLCK

P_POSx_DectCtrl(x = 0, 1) PWM

SPLCNT

1

15 0

1

1

1

2


1
0 1 2 3 4 5 6

0 1 2 3 4 5 6 7 8 9 10

Hall3 Hall2 Hall1

Hall3 Hall2 Hall1

1 1 2

2

学 机
SPLCK 111b >011b 011b 0 4 011b 1 0 1 1)
PAGE 10

SPLCNT 10

*
1 3 0 1 011b 111b >011b >111b Hall3
V1.0 – Dec 8, 2005

10 1 3 SPLCNT 10

10

SPLCK/SPLCNT(SPLCNT





Sunplus Technology Co., Ltd.






3

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

2

AN_SPMC75_0013 PDC Timer

BLDC

2.2

Main ISR Spmc75 _SPDET_V100 Spmc75_dmc_lib_V100.lib DMC

* 学
PAGE 11


C C lib lib

2.3

DMC

Speed1_Now User_R0 PDC










V1.0 – Dec 8, 2005

Sunplus Technology Co., Ltd.



2.1

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

2.4
Spmc75_System_Init ( ) void Spmc75_System_Init(void) PDC Timer DMC

Spmc75_SPDET.h Spmc75_ SPDET _V100 Timer0 PDC

Spmc75_System_Init();










Sunplus Technology Co., Ltd. PAGE 12 V1.0 – Dec 8, 2005



*





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

Spmc75_PDCETSPD_ISR ( ) void Spmc75_PDCETSPD_ISR(void)

Spmc75_SPDET.h Spmc75_SPDET_V100 PDC Spmc75_PDCETSPD_ISR();










Sunplus Technology Co., Ltd. PAGE 13 V1.0 – Dec 8, 2005



*





it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

3

3.1

DEMO





//================================================================= // Description: IRQ1 interrupt source is XXX,used to XXX // Notes: PDC //================================================================= void IRQ1(void)__attribute__((ISR)); void IRQ1(void) { if(P_TMR0_Status->B.PDCIF && P_TMR0_INT->B.PDCIE) { Spmc75_PDCETSPD_ISR(); //PDC } } //================================================================= // Description: IRQ6 interrupt source is XXX,used to XXX // Notes:DMC //================================================================= void IRQ6(void) __attribute__ ((ISR)); void IRQ6(void) { if(P INT Status->B.UARTIF)
PAGE 14 V1.0 – Dec 8, 2005

Sunplus Technology Co., Ltd.







main() { Spmc75_System_Init(); while(1) { MC75_DMC_UART_Service(); } }

//


//DMC

*



/*=============================================*/ // /*=============================================*/ #include "Spmc75_regs.h" #include "Spmc_typedef.h" #include "unspmacro.h" #include "Spmc75_SPDET.h"



it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

{ if(P_UART_Status->B.RXIF) } } MC75_DMC_RcvStream();



P_TMR0_Status->B.PDCIF = 1; // original = P_TMR0_TGRA->W; // PDC // if(original > P_TMR0_TCNT->W && original > MAXRPM) { // summation -= *ptr; *ptr = original; summation += *ptr; // if((++ptr) > (aFilter+CAPBSIZE-1)) ptr = aFilter; // original = (UInt16)(summation >> SHIFTDIV); uiSpeed = (UInt32)RADIX/original; //





SPMC_DMC_Save_Aux(0, original); SPMC_DMC_Save_SpdNow(1, uiSpeed); // }






// DMC DMC
PAGE 15 V1.0 – Dec 8, 2005

void Spmc75_PDCETSPD_ISR(void) { static UInt32 summation=0; UInt16 original,uiSpeed;

}

Sunplus Technology Co., Ltd.

*

#define RADIX (UInt32)((TMRPSFCK*60*PDCCLEAR)/(6*PAIRPOLE)) #define MAXRPM (UInt16)(RADIX/SPDLIMIT) static UInt16 aFilter[CAPBSIZE]; // static UInt16 *ptr = aFilter; //



#define #define #define #define

TMRPSFCK PAIRPOLE PDCCLEAR SPDLIMIT

(24.0E+6)/64 2 1 5000

// //BLDC //CNT //



it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

3.2
DMC 3 1

API Spmc75_System_Init

3-1

3.3
PDC

* 学
Y
TIO0C TIO0B TIO0A SPMC75F2413A

PDC

N

API





3.4

3

3



VCC R1 MCU Hall3 Hall2 Hall1




3-2 3 3

PDC Spmc75_PDCETSPD_ISR

Txd Rxd

Sunplus Technology Co., Ltd.

PAGE 16


3-2
PC DMC RS232

API MC75_DMC_UART_Service


V1.0 – Dec 8, 2005

it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

BLDC 3 4 ADC
Hall3

MCU 4 MCU

3

Hall2

Hall1

010

011

001

101

100

110

010

3 3 4 Hall3 Hall2 Hall1

4 010b

Hall3

Hall2

Hall1

110

100


101 001 011

3

3 BLDC

4



Hall3

Hall2

Hall1


010 110

4

110b

Hall.spj

SPMC75F2413A IOD15 IOD14 IOD13

*

>011b->001b->101b->100b->110b

>100b->101b->001b->011b->010b



Hall3 Hall2

ADC





Sunplus Technology Co., Ltd.

PAGE 17


ADC0 Hall1 IOA0/AN0
V1.0 – Dec 8, 2005



it502.com/study 专业单片机,计算机资料网

SPMC75

PDC

BLDC

4 1 2 SUNPLUS SPMC75F2413A V1.0 Oct 12 2004










Sunplus Technology Co., Ltd. PAGE 18 V1.0 – Dec 8, 2005



*






相关推荐

最新更新

猜你喜欢