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
已解决! 转到解答。
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:
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).
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.
Hope this helps,
Irina
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
Thanks for the reply!
I have replaced the files as instructed. Can you please provide example usage of this fix?
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!
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:
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).
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.
Hope this helps,
Irina
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