Event ReadHallSensors Count and Crash

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

Event ReadHallSensors Count and Crash

2,698 Views
jjacp
Contributor III

Hello,

 

I’m currently going through dumitru-daniel.popa's excellent Motor Control Class with Model Based Design for the MPC5744P, but I am stuck on Lecture 5, specifically the Event-Based Hall Sensor Reading portion.

 

I can read the three Hall sensors just fine, but as I see in Freemaster, the HallChangeCount variable continuously increases, even if I do not rotate the motor (see screenshot). To be clear, the Hall_(A, B, C) inputs report correctly, but the count is always active. This eventually causes my board to crash after a short while. I know from the lecture videos, that this is not normal behavior.

 

I used both the original model file from the lecture 5 webpage (attached), as well as building the model from scratch following the videos.

 

Has anyone seen this behavior before? Is there a fix?

 

Here are details on my setup:

 

Hardware:

MPC5744P Dev Kit with DEVKIT-MOTORGD

BLDC motor with 3 Hall-Effect sensors

 

Software:

MATLAB R2016b

NXP Model Based Design Toolbox v2.0.0

S32DS Power v1.2 Compiler

Freemaster 2.0

Hotfixes 3 and 5 from https://community.nxp.com/thread/451804#comment-916493

 

Thank you!

6 Replies

2,296 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi jjacp‌,

First off all - thank you for your appreciation.

Now, coming back to your issue I think it is related to the order of block execution: check this topic - https://community.nxp.com/thread/449904#comment-899761 

I've opened your model and i see that "Hall Sensors Initial Position block" is executed after "Hall Event ISR"

pastedImage_2.png

pastedImage_5.png

Please change the priority of the "Chart" to 1 and check if it works.

pastedImage_6.png

Furthermore, if this does not solve your issue, is there any possibility for you to check with an oscilloscope is you have some sort of debouncing on hall input lines ?

Thank you!

Danie 

0 Kudos
Reply

2,296 Views
jjacp
Contributor III

Hi dumitru-daniel.popa,

Thanks for the reply and suggestion! I changed the chart priority to 1 as you instructed, and I could see the execution order updated, but unfortunately the problem still exists (HallChangeCount continuously increases).

I checked the HALL input lines on my scope, and they look clean. In fact, I disconnected all wires from the JP1 header, and the HallChangeCount variable still kept increasing! 

Thanks

0 Kudos
Reply

2,296 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi jjacp‌,

I've looked a little bit deeper in the model. For some unknown reason - MATLAB changed the execution order to the blocks (i do not understand why is that happening).

It generates the code for the ISR before eTIMER peripheric initialization code and cause the application to crash.

Please change the priority field of each blocks to look like this: eTimer configuration and then ISRs blocks

pastedImage_1.png

You can test this very easily using only the MPC5744P DevKit (no shield attached) plus a simple wire that could be connected to a pulse generator for HALL_xxx. (i kept mine near a switching power supply to act as an antenna)

pastedImage_2.png

In the end, with the modified properties + this hw setup I was able to execute the application correctly. Please check this short video.

Best regards,

Daniel

0 Kudos
Reply

2,296 Views
jjacp
Contributor III

Hi dumitru-daniel.popa,

I fixed the priority values of the blocks you mentioned, and ran the code using only the main board (MOTORGD shield removed). It seems to work like in your video! I only see the count increase when I connect a stray wire to the J5 header.

However, once I put the shield back on, the problem of the perpetually increasing counter is still there. 

I think I found a solution though. Since it seems the problem is due to line noise, I enabled the eTimer input filtering mechanism: 

filtering_settings.png

Using these settings make the HallCount variable stable, and the system behaves like it should. This work-around should be acceptable, right?

Also, I noticed in your lecture video that the input power port on your MOTORGD board is a two-wire interface, whereas on my board it is a barrel connector. I bought my board last month (Oct 2017). Could there be a hardware change that was made that affects or adds noise on the HALL input lines?

Thanks!! 

0 Kudos
Reply

2,296 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi jjacp‌,

Glad you made it!

Using these settings make the HallCount variable stable, and the system behaves like it should. This work-around should be acceptable, right?

Yes, it is the correct way to do it in case you're dealing with noisy signals. You might need to tweak the parameters until you get a good balance between reading delay and noise rejection.

Also, I noticed in your lecture video that the input power port on your MOTORGD board is a two-wire interface, whereas on my board it is a barrel connector. I bought my board last month (Oct 2017). Could there be a hardware change that was made that affects or adds noise on the HALL input lines?

I used a rev. A of the Motor GD Development Kit. Between rev. B and rev. A there are a few modifications but nothing to interfere with HALL/ENC signals 

Here is a diff between Rev A/B with electrical components changes.

pastedImage_3.png

Nonetheless, please do a simple test: unplug the hall signals from the sockets (maintain the +5 and GND connection over Motor GD JP1) and check with and oscilloscope if you have noise on the lines. If you do, then perhaps is due to your motor or 5v power supply. 

Hope it helps!

Daniel

0 Kudos
Reply

2,294 Views
jjacp
Contributor III

Hi dumitru-daniel.popa,

I unplugged the signals from the JP1 socket and checked the lines on the scope, and they do look a bit noisy. Nothing crazy, but they're not clean, so I guess it is my motor or power supply. In any case, I'm glad the filtering method will work, and I can continue with the class.

Thank you so much for all of the help! This lecture series really is very good. Keep it up!

Regards,

jj

0 Kudos
Reply