How can I adjust the setting of analog signal sampling with STM32 using Matlab Simulink.

15 次查看(过去 30 天)
Hi everyone,
I want to see the AC signal I measured with STM32F746ZG in matlab simulink. The AC signal has offset and its frequency is 50 Hz. For example, I want to measure this AC signal with a 10 kHz sample. In the Matlab simulink analog input (MBED) block, only the pin and sample time (Note: The sample time in the block is entered as 1e-4) can be set. When I run it with Monitor and Tune, it measures with a sample of around 500 Hz in the data inspector section. Naturally, the graph is quite far from sinusoidal waveform. How should I configure in matlab simulink to measure this signal in real time and with 10 kHz sampling. The figure below shows the shape of the AC signal monitored in the data inspector.
Thank you for your advice.

回答(2 个)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023-12-30
Increase data sampling rate, e.g., 2.5kHz or higher and re-collect your data. It will solve the problem.
  1 个评论
Eyke
Eyke 2023-12-31
Thank you for the answer.
The block shown below reads the analog value directly as seen. There is no setting on the block for quantization and sample time etc. for setting. Besides, I could not find a setting in the model configuration parameters. What I want to ask is which steps can I follow to solve these problems on matlab. Also, setting the sample time does not make any difference when I run it with monitor and tune.

请先登录,再进行评论。


Goutham Varanasi
Goutham Varanasi 2024-1-9
Hi,
This is because logging with external mode is done at higher sample rate which requires higher data speeds along with the overhead of external mode.
As a workaround you may use the two-model approach where data logging is handled by a different model there by reducing the overhead of logging on the main model.
You may follow these examples for reference.

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by