S32K396 adding an ADC to motor control example project

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K396 adding an ADC to motor control example project

1,694 次查看
agus_idiada
Contributor III

Hello,

I am using S32K396-BGA-DC1 board, with Simulink in matlab2024a. I am working on the S32K396_MBDT_BASED_MC_0_9_0 Motor Control Example Project.

In my setup I have the nxp connected with a HIL-RT hardware emulating the power stage and a motor.

My question is regarding the ADC modules. I would like to add several ADC to the motor control example project. However, this is not working for me. After modifying, all the ADCs have and strange behavior so I supposed something is wrong configured.

On the simulink side I add a variable from the the FIFO

agus_idiada_0-1730300749313.png

On EB tresos I configured the adc and pin port.

agus_idiada_1-1730300821620.pngagus_idiada_2-1730300859893.png
agus_idiada_3-1730300900252.pngagus_idiada_4-1730300914680.pngagus_idiada_5-1730300953891.png

 

agus_idiada_6-1730301008177.pngagus_idiada_7-1730301065930.png



Can you please give me support on this and tell me what is missing or wrong in the config?

Thanks, Agustin.

标记 (3)
0 项奖励
回复
7 回复数

1,005 次查看
agus_idiada
Contributor III

Hello @Irina_Costachescu , here is the full mbdt motor example project with the EB Tresos configuration. The idea is to add PTE15 ADC0 P3 for motor temperature and PTA20 ADC1 P3 for inverter temperature. In this project it is only "configured" for motor temp.

I think my error is while assigning the ADCHwTrigger or the BCTU list items.

Thanks a lot.

Agustin.

0 项奖励
回复

967 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hello @agus_idiada 

I have taken a look into the attached project.
For being able to read data from two additional Adc channels, please consider following the suggestions provided in the current thread - BctuListItem3 and BctuListItem4 could be configured to represent the specific channels you would like to address.

For achieving this, could you please follow the steps below?

  • If you would like to use ADC0 Channel 3, and ADC1 Channel 3, please configure them approrpiately by setting the BctuListItems 3 and 4 on P3_ChannelNum3 - physical ADC channel of each instance.

bctulist.png

  • For being able to customize the settings of the channel, please configure each Adc Channel inside its corresponding AdcHwUnit group, in the AdcChannel tab.

adcchannel.png

  • Make sure that your pins are routed to the Adc channels inside the Port component. For routing the pins to the desired functionality, add their corresponding MSCRs inside the PortConainter_0 of the Port component, and configure them as required (functionality, and other specific options).

addnewpin.png

However, please note that PTA20 that you have mentioned can't be used as an ADC channel, as this pin is routed as the SPI SIN - PortPin_LPSPI1_SIN already routes pin with MSCR 20 (PTA 20) to the LPSPI1 peripheral.

lpspi1.png

Moreover, please note that the conversion of the channels specified in the BCTU list, configured in the Adc component, is triggered by AdcHwTrigger0. This implies that the conversion of the sequence of channels configured in the list will be triggered by BCTU which receives its trigger source from EMIOS. If you would like to keep the same approach, you won't need additional Adc Hardware Triggers in your configuration, but of course this would need to match the requirements you have on your application.

If you would like to have some measurements available in your application, independent of the hardware trigger chain, please refer to the examples that we are providing inside our toolbox (e.g s32k3xx_adc_single_read which demonstrates how to perform software conversions for Adc groups)

For more details on the ADC operating modes, please consult the S32K3 Reference Manual, as it provides details on conversion modes, how the peripheral interacts with BCTU, and further information you might find useful.

Thank you,
Irina

0 项奖励
回复

1,574 次查看
Vincent_Deng
NXP Employee
NXP Employee

Hi Agustin,

For the ADC with BCTU FIFO usage, please take care of the conversion rules. For usage in the demo, the BCTU 0 take 3 ADC channels as a group, so you can see there are 6 configured channel(2 group, phase currents as the first group and bus voltage with other no used channel as the second group.) in the BCTU LIST items and only 4 results are used in the demo. For more details, please refer to the Reference Manual, Chapter BCTU. Also, a example demo is supplied in the RTD driver.

As the mentioned above, you can find a quick and easy way to add your channel if you hope the channel is sampled with the phase currents and bus voltage. Replace the unused channel(BctuListItem3 or BctuListItem4) to your correctlly.

Thanks,

Vincent

0 项奖励
回复

1,550 次查看
agus_idiada
Contributor III

Hello @Vincent_Deng , I tried to follow your suggestion to used BctuListItem3 or BctuListItem4. So I configured a new channel (please see the doc attached) but is not working. Sorry but with my limiting knowledge I could not debug what else is missing. Please if you can help me with this would be great. Thanks.

标记 (3)
0 项奖励
回复

1,512 次查看
Vincent_Deng
NXP Employee
NXP Employee

Hi @agus_idiada,

I checked the attachment. You wanted to add the ADC2 Channel 0. However, the ADC2 has been used by the BctuListItem_5 for BusVoltage. First, there is a sequence that needs to be careful. Please see the picture(in Reference Manual, Chapter 57 ADC).

Vincent_Deng_0-1732504849318.png

In the Multiple Parallel Conversion(MPC, Chapter 64 BCTU for more details & example), the configuration for the trigger should be in order from ADC 0 to ADC 2. You can see the configuration in the demo, for the first group(BctuListItem_0 to 2), the trigger for ADC 0 Channel 0, ADC 1 Channel 0 and ADC2 Channel 1 in order(phase currents). For the second group, the demo only needs the BusVoltage(ADC 2 Channel 5), however, the BctuListItem configuration adds 2 unused BctuListItems(BctuListItem_3 & 4), then puts the trigger for ADC 2 Channel 5 on the BctuListItem_5.

 

Hope this can help u get to know more about the BCTU and configuration.

Regards,

Vincent

0 项奖励
回复

1,502 次查看
agus_idiada
Contributor III

Thanks for the answer @Vincent_Deng . Sorry but it is still not clear for me. From your answer and the documentation I got this:

The parallel conversion sequence follows this scheme:


So if I want to add 2 adc for the pre-configured BctuListItem_3 & 4 should be one from ADC0 and other from ADC1. Is this correct?

agus_idiada_0-1732535520999.png

 


Moreover, let's for example add a new channel from the ADC0 in the AdcHwUnit_0. For trigger the new channel conversion should I simply create a new AdcHwTrigger (AdcHwTrigger _5 with BCTU_EMIOS_0_4) and sync them or the AdcHwTrigger should be in order too?

agus_idiada_1-1732535541857.png

 



标记 (2)
0 项奖励
回复

1,470 次查看
Vincent_Deng
NXP Employee
NXP Employee

Hi @agus_idiada,

The first question you understand is correct.

The second one, if it is not the parallel conversion, no order sequence is required. For this, you might find an example in the RTD package created and built in S32Design Studio. 

 

Regards,

Vincent

0 项奖励
回复