S32K344 Multi-channel ADC read group

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

S32K344 Multi-channel ADC read group

Jump to solution
1,079 Views
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 Solution
861 Views
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

View solution in original post

0 Kudos
Reply
5 Replies
939 Views
LyingCake
Contributor II

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

0 Kudos
Reply
874 Views
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

867 Views
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 Kudos
Reply
862 Views
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 Kudos
Reply
749 Views
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 Kudos
Reply