s32k144 pmsm closed loop - sine cosine encoder interfacing

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

s32k144 pmsm closed loop - sine cosine encoder interfacing

Jump to solution
5,837 Views
Sriram
Contributor IV

Hello 

I am trying to interface nxp pmsm closed loop model with sine cosine encoder present in my motor and get the rotor postion data visualized in freemaster.

I am able to add the variables to the freemaster but it is not changing when i rotate the motor. 

i ll add some pics of my setup and the slx file. Can anyone help me with interfacing the encoder with the s32k and display the results in freemaster . Thanks

the sine cosine encoder has 4 pin outs ( sine cosine 5v and GND)

i have connected the sine and cosine pins with the respective adc pins ( here it is  PTD2 and PTD3)

Is there anything i should change in the matlab model to get it working with free master? 

 

Thanks 

@adriantudor @Daniel_Popa 

0 Kudos
Reply
1 Solution
5,759 Views
adriantudor
NXP Employee
NXP Employee

Hi Sriram,

Here is your model updated to read ADCs for the CoSine resolver. Try to start from this model and add incrementally data from your resolver to replace the default hall resolver.

Please let me know if it works.

 

Best regards,

Adrian

View solution in original post

8 Replies
4,450 Views
Dcshhi
Contributor I

Man I wish I knew this stuff! I'm stuck with a Kelly kbs trying to turn a pmsm with encoders . My controller only accepts hall signal any suggestions? 

0 Kudos
Reply
5,788 Views
Sriram
Contributor IV

I am able to get the cosine encoder reading from the adc by rotating the shaft of the motor  when i build encoder model and deploy it . Only when interfacing the cosine encoder with the pmsm closed loop model i am facing this problem . 

0 Kudos
Reply
5,760 Views
adriantudor
NXP Employee
NXP Employee

Hi Sriram,

Here is your model updated to read ADCs for the CoSine resolver. Try to start from this model and add incrementally data from your resolver to replace the default hall resolver.

Please let me know if it works.

 

Best regards,

Adrian

5,746 Views
Sriram
Contributor IV

Thank you sir , It is working perfectly. 

Tags (1)
5,830 Views
adriantudor
NXP Employee
NXP Employee

Hello Sriram,

In order to visualize a variable, used in the MBDT project, in FreeMaster you have to declare it as "volatile". To do that you have to click on those three gray rectangles on the right side down on your work screen. There will pop up a few small square windows like in the photo. Then on the downside will appear a collapsed window named "Code Mappings - Component Interface", click on that, and will raise a window, click on the "Data Stores" tab, and here you will have to find your variable name on the left side, and on the right side, you have to select class of respective variable as "volatile". The build the project and you can add the variable to variable watch in FreeMaster after selecting the latest binary file.

Best regards,

Adrian

5,828 Views
Sriram
Contributor IV

Thanks fr the reply sir , I got the variables in the watch by making the code optimization as minimum. But the issue is i'm not able to get a reading from the adc pins (sine cosine - ptd 2 and ptd 3) when i try to view them in oscilloscope in freemaster. it is either stuck at 0 or is at a random value. I want to see the theta variation when i rotate the shaft of the motor. In the matlab model , Theta_EST should output the theta value but in freemaster it is not varying with motor rotation . Is there anything wrong with the matlab model or should i do anything different to get the position value in free master

 

thanks  

ps - im using the matlab model sent by you sir @adriantudor 

Tags (1)
0 Kudos
Reply
5,826 Views
adriantudor
NXP Employee
NXP Employee

Hi Sriram,

If you are using the model that you posted here, then you must be aware that ADC readings are triggered by the PDB module which is also triggered by PWM. That means, the ADC is functional only when the motor is running and if you turn the shaft of the motor with your hand, the ADC will not read anything because it's not triggered even if the CoSine encoder is functional. My recommendation is to remove the "speed feedback" that you feed in "SlowLoopControl" block and feed that with the default block. That means you should use the default motor with the default Hall sensors, but you will have to attach somehow (if it's possible) the cosine encoder to the motor shaft. And you can still use your added blocks for the cosine encoder to monitor and debug the cosine encoder.

Let me know if that works.

 

Best regards,

Adrian

5,822 Views
Sriram
Contributor IV

Ok sir will try that 

0 Kudos
Reply