S32K344 Multi-channel ADC read group

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

S32K344 Multi-channel ADC read group

跳至解决方案
1,426 次查看
RegulusCheng
Contributor III

Hi,

I am using S32K344 in MCSPTE1AK344 board, with Simulink in matlab2021b.

I have configured 3 ADC channels in S32CT, three channels are all set into ADC1Group0. 

However, I found the "AdcGroupRead" Model can only output 1 dimension uint16 data, which only contain the first channel of the three. I wonder how to get all channels' data with this model? Or I must use other models?

I would be better if there are demos except those in MBDT tools.

 

regards,

Regulus

1 解答
1,208 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hi @LyingCake 

The output of the Simulink block represents the address where the converted data, of type uint16, will be stored. ADC results of all channels of the group selected in the block mask are stored in a buffer addressed with that pointer.

For being able to store the data inside a variable, you could use a Data Store Memory Simulink block, that, depending on the number of channels your group contains, can be declared with different sizes. For example, I have declared the variable Group0, for the case in which you have 2 channels, with its initial value set as illustrated below:

Irina_Costachescu_0-1713200634735.png

Then, inside the Simulink application, connect the block output to a Data Store Write block, for enabling the converted data to be stored inside the Group0 variable (the naming represents just an example).

Irina_Costachescu_2-1713200750684.png

Now, you should be able to access both values, corresponding to the two channels that your group contains, each of them being represented by Group0[0] and Group0[1] respectively. You could use FreeMASTER for inspecting the values corresponding to each channel.

Irina_Costachescu_3-1713200974172.png

 

Hope this helps,

Irina

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,286 次查看
LyingCake
Contributor II

Hi there! Did you ever figure out how to access multiple channels within the same group using the MBDT?

0 项奖励
回复
1,221 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hi @LyingCake 

There are some known issues with the Adc functionalities for reading channels groups, fixed in the attached .zip file. Please download the attached archive and copy the contents to their right locations inside the toolbox, as it follows:

adc.tlc and adc.c       to <toolbox_root>/mbdtbx_s32k3/+mbd_s32k3/+common/blocks/adc
s32k3_adc.mexw64  to <toolbox_root>/mbdtbx_s32k3/blocks/adc

Let us know if this helps,

Irina

1,214 次查看
LyingCake
Contributor II

Hi @Irina_Costachescu 

Thanks for the reply!

I have replaced the files as instructed. Can you please provide example usage of this fix?

LyingCake_0-1713197243977.png

Using this fix, I am still not seeing individual channels for the 'Adc_ReadGroup' block. The above 'TEMP_MONITOR' group contains two ADC channels, however the output of the block is a single uint16.

Thanks!

0 项奖励
回复
1,209 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hi @LyingCake 

The output of the Simulink block represents the address where the converted data, of type uint16, will be stored. ADC results of all channels of the group selected in the block mask are stored in a buffer addressed with that pointer.

For being able to store the data inside a variable, you could use a Data Store Memory Simulink block, that, depending on the number of channels your group contains, can be declared with different sizes. For example, I have declared the variable Group0, for the case in which you have 2 channels, with its initial value set as illustrated below:

Irina_Costachescu_0-1713200634735.png

Then, inside the Simulink application, connect the block output to a Data Store Write block, for enabling the converted data to be stored inside the Group0 variable (the naming represents just an example).

Irina_Costachescu_2-1713200750684.png

Now, you should be able to access both values, corresponding to the two channels that your group contains, each of them being represented by Group0[0] and Group0[1] respectively. You could use FreeMASTER for inspecting the values corresponding to each channel.

Irina_Costachescu_3-1713200974172.png

 

Hope this helps,

Irina

0 项奖励
回复
1,096 次查看
RegulusCheng
Contributor III

Hi, Irina

Thanks for your support. This solution solved the problem and I  can read all ADC channels' data in Simulink now.

However, it needs to be noted that the "Set ADC result buffer" module also needs an input of n*unit8 type data, which means we have to modify the related data store memory module if we copy them from the demo program, or we will get several result data of the same channel.

 

Regulus

 

0 项奖励
回复