Excuse me,can you give me an example  how to use encoder to measure speed of the PMSM vector motor  on professional expert in codewarrior 10.4? thank you very much.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Excuse me,can you give me an example  how to use encoder to measure speed of the PMSM vector motor  on professional expert in codewarrior 10.4? thank you very much.

Jump to solution
2,303 Views
guochunhua
Contributor II

excuse me. in code warrior v10.4, I want to measure the speed of 3-phase pmsm vector  motor ,how can I use the encoder on PE? can you give me an example?

Labels (1)
0 Kudos
Reply
1 Solution
1,568 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Guo,

I suggest you use quadTimer to get position and speed of rotor, as you know, when the motor run in low speed mode, you have to use tick clock to fill the sensor output signals, so the capture function is needed. But the ENC does not have capture function, in other words, the PhaseA/PhaseB signal pins on the ENC can not trigger an interrupt, but the quadTimer has capture function.

Hope it can help you.

BR

Xiangjun Rong

View solution in original post

0 Kudos
Reply
8 Replies
1,568 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Guo

As you know that the Encoder can output two signals:PhaseA/PhaseB for incremental encoder sensor, the PhaseA/PhaseB are phase shift with 90 degree. Different chip uses different peripheral to count the falling/rising edges of both PhaseA and PhaseB, furthermore, you have to consider the Very Low speed case.

If you use DSC for example MC56F84xxx/MC56F82xxx, we use quadTimer or Quadrature Encoder/Decoder peripherals to count the encoder signals to get position of rotor and figure out the speed.

If you use Kinetis family, for example KVxx, they use FTM modules to decode the encoder signals.

If you use MPC5xxx family, they use eTPU to decode the Encoder signals.

This is the website of NXP home page:

NXP Semiconductors | Automotive, Security, IoT

I also attach the example code for PMSM control with encoder sensor.

For the hardware connection for the example based on MC56F84789, it consists of TWR-56F8400 board, TWR-MC-LV3PH power stage board(it also includes the signal conditional circuit), PMSM motor with encoder.

Hope it can help you.

BR

Xiangjun Rong

0 Kudos
Reply
1,568 Views
limheesun
Contributor II

Hi. Can I get an example code of MPC5xxx family?

I have MPC5553 and use eTPU to decode the Encoder Signals.

But I can't reset the position counter when the Index signal is received.

And I can't get the revolution counter.

However, the position counter with A & B signals is working well.

I can't know what I'm missing.

err_code = fs_etpu_qd_init (QD0_PRIMARY, /* engine: A; channel: 10 */
ETPU_CHAN_NOT_USED, /* This channel is not used */
QD0_INDEX, /* engine: A; channel: 12 */
FS_ETPU_QD_PRIM_SEC_INDEX, /* Index, primary and secondary. */
FS_ETPU_PRIORITY_HIGH, /* priority: High */
FS_ETPU_QD_CONFIGURATION_1, /* configuration: Both QD pins are 1 when the INDEX is reached. */
FS_ETPU_TCR1, /* timer: FS_ETPU_TCR1 */
0, /* pc_max: 0 */
0, /* slow_normal_threshold: 0 */
0, /* normal_slow_threshold: 0 */
0, /* normal_fast_threshold: 0 */
0, /* fast_normal_threshold: 0 */
0, /* window_ratio1: 0 */
0, /* window_ratio2: 0 */
FS_ETPU_QD_HOME_TRANS_LOW_HIGH, /* home_transition: Detection of low-high transition. */
FS_ETPU_QD_INDEX_PULSE_POSITIVE, /* index_pulse: Index pulse of positive polarity. */
FS_ETPU_QD_INDEX_PC_RESET, /* index_pc_reset: Position Counter is reset on Index transition. */
FS_ETPU_QD_ETPU_A_TCR1_FREQ, /* etpu_tcr_freq: frequency of eTPU engine A - TCR1 */
0); /* pc_per_rev: 0 */

mnew2 = fs_etpu_qd_get_pc(QD0_PRIMARY);
dirEnc = fs_etpu_qd_get_direction(QD0_PRIMARY);
EncZCnt = fs_etpu_qd_get_rc(QD0_PRIMARY);
testEnc = fs_etpu_qd_get_pc_sc(QD0_PRIMARY);

QD0_PRIMARY is 10th channel of eTPU_A .

QD0_INDEX is 12th channel of eTPU_A.

Please, check this.

I'm waiting for your comment.

Thanks,

Heesun. 

0 Kudos
Reply
1,568 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Lim,

Unfortunately, I am not familiar with ETPU module, pls create a ticket in MPC community:

I am sorry for not helping you.

BR

XiangJun Rong

0 Kudos
Reply
1,568 Views
limheesun
Contributor II

Oh, I see ; )

Thank you for your kind.

Have a nice day!

0 Kudos
Reply
1,568 Views
guochunhua
Contributor II

Hi,Rong

thank you very much for your answer, the example attached is based on Quadtimer encoder to count the encoder signals to get position of rotor, but I want an example base on ENC for MC56f84789, also the example is based on professional expert, thank you very much.

0 Kudos
Reply
1,568 Views
guochunhua
Contributor II

Hi,Rong

thank you very much for your answer, the example attached is based on Quadtimer encoder to count the encoder signals to get position of rotor, but I want an example base on ENC encoder for MC56f84789 , also the example is based on professional expert, thank you very much.

0 Kudos
Reply
1,569 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Guo,

I suggest you use quadTimer to get position and speed of rotor, as you know, when the motor run in low speed mode, you have to use tick clock to fill the sensor output signals, so the capture function is needed. But the ENC does not have capture function, in other words, the PhaseA/PhaseB signal pins on the ENC can not trigger an interrupt, but the quadTimer has capture function.

Hope it can help you.

BR

Xiangjun Rong

0 Kudos
Reply
1,568 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Guo,

Could you tell us which MCU are you using?

Thanks in advance!

Best Regards,

Carlos Mendoza

Technical Support Engineer

0 Kudos
Reply