Motor Control Class: Lecture 10 - Speed Estimator

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

Motor Control Class: Lecture 10 - Speed Estimator

11,775 Views
dumitru-daniel_
NXP Employee
NXP Employee

In this 10th lecture of the motor control course we discuss about to build, simulate and test a Speed Estimator based on hall sensors information related to rotor position. The speed estimator is first tested under Matlab Simulink environment where its functionality and precision can be easily tested for a multiple of input frequencies. Once its operation is validated in the simulated environment the estimator is ported into the Open Loop Control model and tested on the real HW platform MPC5744 Development Kit with the BLDC motor spinning at various levels. The estimator accuracy is compared against the real motor speed measured with an oscilloscope. 

 

Main topics:

    - What is a speed estimator and how it works;

    - Mathematical model behind the Hall based speed estimator;

    - Build the Simulink model for Speed Estimator;

    - Test the Speed Estimator on the real hardware;

    

Objectives:

    - Understand the concept of speed estimation;

    - Measure the motor speed;   

    - Confirm the speed estimator results against the one measured in real time;

 

NOTE: Chinese viewers can watch the video on YOUKU using this link

注意:中国观众可以使用此链接观看YOUKU上的视频

 

187871_187871.JPGCapture.JPG187872_187872.JPG3.JPG187873_187873.JPG2.JPG

 

Additional information:

    - pdf attached with slides shown in this video;

    - Simulink models used in this video;

Original Attachment has been moved to: Lecture10.zip

Update revisions:

February 25, 2019

May 06, 2020

22 Replies

8,645 Views
jimduanva
Contributor II

dumitru-daniel.popa

Hi Daniel,

Can you add/upload the elf file from your build? I have problem to connecting FreeMaster with CAN, and would like to try your build.

Thanks.

Jim

0 Kudos

8,646 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi jimduanva‌,

In general i would avoid uploading pre-build images since might be dangerous for some purpose. Some might try to upload the elf directly and expect to work out-of-the-box for their particular setup. Hence, these models are not intended for application purpose but rather for learning how to design in Simulink using different concepts. The fact that we target the motor control is just a coincidence.

Anyhow, please find attached the generated code for this lecture. 

Hope it helps!

Daniel

0 Kudos

8,648 Views
tanveerahmed
Contributor I

Hi Daniel,

Very good lectures first of all. Good job!

I was trying lecture number 10 and I found my actual speed (measured using a tachometer) to be different from the displayed speed. could it be due to the number of poles? My motor has 4 poles. How can I fix this?

Thanks,

Tanveer

0 Kudos

8,646 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Tanweer, 

Thank you!

The motor used in the lecture has 2 pole pairs. So if your motor has 4 poles (N-S-N-S) which meas 2 pole pairs the speed should be identical.

Now, the speed Omega = 60*electrical_frequency/number_of_pole_pair so depending on your readout we may conclude what is the actual number of pole pairs of your motor. 

Can you attach here the data sheet of your motor and your tachometer ? 

Best regards,

Daniel

0 Kudos

8,653 Views
petrfajmon-b173
NXP Employee
NXP Employee

Hi dumitrupopa‌ ,

  I have "Kvaser Leaf Light" interface so I can test the basic example application for MPC5744P which is available in the FreeMASTER Communication Driver .

Best Regards,

Petr

0 Kudos

8,653 Views
petrfajmon-b173
NXP Employee
NXP Employee

Hi mahdkhalid‌, dumitrupopa‌,

  I have retested MPC5744P example application which is available in the  FreeMASTER Communication Driverlocated here: c:\NXP\FreeMASTER_Serial_Communication_Driver_V2.0\examples\SCI_driver_examples\MPC57xx\MPC574xP_EVB. The example project works correctly with "Kvaser Leaf Light" interface on 500kbs.

  The MPC574xP_EVB project is created in S32 Design Studio for Power and by default is prepared for communication over UART, so the only thing what needs to be configured is communication channel to CAN in the freemaster_cfg.h file:

  • #define FMSTR_USE_SCI 0 /* To select SCI communication interface */
  • #define FMSTR_USE_FLEXCAN 1 /* To select FlexCAN communication interface */

Regards,

Petr

0 Kudos

8,653 Views
mahdkhalid
Contributor III

Hi,

I am having trouble communicating to with the FreeMaster using CAN. I have a KVASER LEAF LIGHT V2 which is supposed to be compatible. Can anyone help with any troubleshooting steps please

Regards,

Mahd

0 Kudos

8,653 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Madh, 

Do you have a CAN bus termination 120 Ohms ? 

Have your scanned to CAN for different bit rates. Please note that there is a difference between the speed set in the model and the one from FreeMASTER: https://community.nxp.com/message/992547?commentID=992547&et=watches.email.thread#comment-965260 

Best regards,
Daniel

0 Kudos

8,653 Views
mahdkhalid
Contributor III

Thank you for the reply. I have soldered the resistor for termination and have tried different baud combinations. I get the errors, ''No data received'' and ''Can not set CAN/LIN channel bitrate.

CAN settings.PNG500kb.PNG800kb.PNG1Mb.PNG

0 Kudos

8,653 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Mahd, 

Since you have set the Simulink model to 500kB bit rate then the FreeMASTER should work with 1Mb assuming you are using the small development board as i did in the video.

The CAN interface looks like this:

pastedImage_1.png

Assuming the CAN HI/LO are connected correctly, have you powered the board with 12V by making the appropriate settings  on the board? https://www.nxp.com/docs/en/supporting-information/DEVKIT-MPC5744P-QSG.pdf 

If everything is fine up to this point, then perhaps we should check if the boards transmits something over the CAN. You can load the CAN demo: can_model_pnt.mdl and check with a CAN sniffer if you receive anything over the CAN with your adapter.

Hope this helps!
Daniel

0 Kudos

8,653 Views
mahdkhalid
Contributor III

2/2
I have tried another thing. Without plugging in the controller and without loading any elf file I just plugged in my CAN adapter and tested connection on FreeMaster. It detects the CAN adapter and the driver but gives error ''Could not open the communication port''.

0 Kudos

8,653 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi petrfajmon-b17364‌,

In the release notes and change.txt of the FreeMASTER 2.0.7.0 Jan 2 2018 it is stated that KVASER CAN Devices are supported, hence the customer can't initiate a connection between MPC5744P and FreeMASTER. 

The MCP5744 CAN works because has been tested with a simple CAN application and the messages are received correctly by a can sniffer, but the FreeMASTER can't seems to be able to connect.

Do you know to tested the support and if there is any embedded application that can be used to verify the setup? A simple application that allows FreeMASTER to communicate with.

Thank you!

Daniel

0 Kudos

8,653 Views
mahdkhalid
Contributor III

Hi dumitru-daniel.popa‌ and petrfajmon-b17364


Thank you so much for the help and quick replies. I really appreciate it.

I could not get the freemaster to work with the lecture 10 files despite all the help so I went ahead to lecture 13. I have realised that the freemaster works on CAN as long as I use MOT and ELF file which is given by you. If I rebuild the code on my computer and use the updated MOT and ELF files, it stops working. I have made sure that I am using the correct paths but I have had no luck with it.

Thanks,

Mahd Khalid

0 Kudos

8,653 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Mahd, 

Are you sure you have this patch applied https://community.nxp.com/thread/451804#comment-916493 and S32DS for Power Architecture 1.2 GCC compiler ?

The only scenario plausible at this point is that one you compile the code with a newer compiler the application stops working properly.

Best regards,
Daniel

0 Kudos

8,653 Views
mahdkhalid
Contributor III

dumitru-daniel.popa

Alternatively, can you please tell me the exact build of the compiler you have so I can also move to that one?

Thanks,

Mahd

0 Kudos

8,653 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Mahd, 

Lets make it easier. please sent me your Simulink Model (to have your settings) and the Generated Folder after your press the Build button. I'll check it against mine for the differences. 

Thank you!

Daniel

0 Kudos

8,656 Views
mahdkhalid
Contributor III

Hi dumitru-daniel.popa

Thank you for your reply. I have previously applied HotFix_3. should I also apply HotFix_7 or HotFix_8?

0 Kudos

8,656 Views
mahdkhalid
Contributor III

Hi Daniel,

I have now tested the can_model_pnt.mdl using a can sniffer and I can see messages coming from the board. However, connection with FreeMaster is still not working.

0 Kudos

8,651 Views
jjacp
Contributor III

Hi dumitru-daniel.popa,

I noticed in the MPC5744P config block, you set the FreeMASTER CAN bus speed is set to 500K, but in FreeMASTER, you have it set to 1M. I confirmed that this is the same on my setup (FreeMASTER can't connect if you set the speed to 500K). Also, if I set the config block to 1M, FreeMASTER doesn't connect even if set to 1M. Is this a bug with the model config block?

Thanks!

0 Kudos

8,650 Views
dumitru-daniel_
NXP Employee
NXP Employee

Good catch jjacp

There is an issue with the toolbox. The same same toolbox supports 2 type of MPC5744P development boards. Between these 2 boards the CAN tranceiver is different - and we found that after the toolbox release. The idea is that the same timings set for MCU cause different CAN baud rates on the boards. In particual for the small MPC5744P DevKit the baud rate is going to double. That is why the model has the 500K and the FreeMASTER is set to 1M. 

We choose to let it that way, assuming that customers will create their own designs with the MCU and will handle correctly the CAN tranceiver circuits. In that case you should get the same CAN baud rate as the one set in the MCU.

The alternative would be to have the toolbox to support different board characteristics. This is something we are thinking about too.

Hope this clarify your concerns.

Best regards,

Daniel